Skip to content

Multiple optimizations - #62

Open
cataphract wants to merge 1 commit into
masterfrom
glopes/opt
Open

Multiple optimizations#62
cataphract wants to merge 1 commit into
masterfrom
glopes/opt

Conversation

@cataphract

@cataphractcataphract commented Mar 8, 2023

Copy link
Copy Markdown
Contributor
  • Introduce two types to aid efficient serialization: MapIterableWithSize and NativeStringAddressable. The first is an entry iterable that doesn't need to be iterated twice, as it has a size(). This alleviates the need to implement Map. The second is a CharSequence that also provides a nul-terminated byte buffer with the UTF-8 representation of the string.
  • Always allocate the initial object in the beginning of the first segment. On a second WAF run, the initial object is replaced. This is allowed by the WAF (the root element, and only the root element, can be replaced between runs), saves a little bit of space and avoids creating a new ByteBuffer slice() on each run.
  • Save memory by not caching PWArgsBuffer objects. To avoid creating many of them, they are reused when possible.
  • Reduce the number of native calls to getByteBufferAddress.
  • Introduce a memory stats function.

@codecov

codecovBot commented Mar 8, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 85.93% and project coverage change: +0.89 🎉

Comparison is base (2c2c4dc) 56.16% compared to head (9573836) 57.05%.

Additional details and impacted files
@@ Coverage Diff @@## master #62 +/- ##
============================================
+ Coverage 56.16% 57.05% +0.89% - Complexity 116 127 +11 
============================================
Files 31 31 Lines 2767 2836 +69 Branches 638 651 +13 ============================================
+ Hits 1554 1618 +64 - Misses 762 763 +1 - Partials 451 455 +4 
FlagCoverage Δ
helper57.05% <85.93%> (+0.89%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted FilesCoverage Δ
src/main/java/io/sqreen/powerwaf/Powerwaf.java85.24% <ø> (ø)
src/main/c/powerwaf_jni.c52.33% <68.00%> (+0.21%)⬆️
.../java/io/sqreen/powerwaf/ByteBufferSerializer.java83.91% <89.89%> (+0.76%)⬆️
src/main/java/io/sqreen/powerwaf/Additive.java75.71% <100.00%> (+3.65%)⬆️
.../main/java/io/sqreen/powerwaf/PowerwafContext.java94.54% <100.00%> (+0.10%)⬆️
src/main/c/debug_helpers.c60.00% <0.00%> (+2.22%)⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@cataphract