Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bytes intern pool to reduce memory consumption #165

Merged
merged 5 commits into from
Jul 28, 2024
Merged

Conversation

vthib
Copy link
Owner

@vthib vthib commented Jul 28, 2024

Intern literal bytes in a pool to reduce the memory it takes in compiled rules. This is used for literals in conditions, but mainly for metadata keys and values.

For example, the icewater ruleset have a lot of metadata for each rule, which always the same names. With this optimization, the memory consumption of the icewater compiled rules goes from 76MB to 62MB.

There is no need to allocate a string for this key.
Those types will change from boreal-parser so copy them internally
beforehand.
Add a bytes pool object to use a single allocation to store all bytes
used in rule metadatas.
Add a map on top of the bytes pool to avoid storing the same string
multiple times. This is extremely useful for metadata keys, which tends
to always be the same in a set of rules.
Repository owner deleted a comment from codecov-commenter Jul 28, 2024
Copy link

codecov bot commented Jul 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.60%. Comparing base (78435bb) to head (d5e8a0b).

Additional details and impacted files
@@           Coverage Diff            @@
##           master     #165    +/-   ##
========================================
  Coverage   98.60%   98.60%            
========================================
  Files          79       80     +1     
  Lines       24364    24471   +107     
========================================
+ Hits        24023    24130   +107     
  Misses        341      341            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vthib vthib merged commit 44028ce into master Jul 28, 2024
20 checks passed
@vthib vthib deleted the intern-bytes branch July 28, 2024 23:34
Sign up for free to 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