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

feat: env var to control libxml2 memory management #2843

Merged
merged 3 commits into from
Apr 7, 2023

Conversation

flavorjones
Copy link
Member

What problem is this PR intended to solve?

This allows a user to opt into configuring libxml2 to use system malloc instead of ruby's ruby_xmalloc (which is the default on all platforms except windows using system DLLs).

This addresses a few problems:

Parsing benchmarks:

default memory html4 parse 656:    27145.8 i/s
   ruby memory html4 parse 656:    24287.1 i/s - 1.12x  (± 0.04) slower

default memory html4 parse 70095:      605.9 i/s
   ruby memory html4 parse 70095:      450.5 i/s - 1.34x  (± 0.13) slower

default memory html4 parse 681406:       73.7 i/s
   ruby memory html4 parse 681406:       56.2 i/s - 1.31x  (± 0.09) slower

default memory html4 parse 1929522:       52.3 i/s
   ruby memory html4 parse 1929522:       43.7 i/s - 1.20x  (± 0.06) slower

Serialization benchmarks:

default memory html4 srlze 656:    78223.0 i/s
   ruby memory html4 srlze 656:    77631.2 i/s - same-ish: difference falls within error

default memory html4 srlze 70095:     1749.3 i/s
   ruby memory html4 srlze 70095:     1619.7 i/s - 1.08x  (± 0.01) slower

default memory html4 srlze 681406:      179.8 i/s
   ruby memory html4 srlze 681406:      162.1 i/s - 1.11x  (± 0.01) slower

default memory html4 srlze 1929522:      184.1 i/s
   ruby memory html4 srlze 1929522:      172.9 i/s - 1.06x  (± 0.01) slower

I'm not making this the default right now -- though we should consider doing so in the future -- because in production environments, it may change the memory usage behavior.

Have you included adequate test coverage?

Yes!

Does this change affect the behavior of either the C or the Java implementations?

No functional changes.


cc @byroot and @tenderlove

@flavorjones flavorjones force-pushed the flavorjones-env-var-to-control-libxml-memmgmt branch from 8d6419a to 42c8274 Compare April 7, 2023 20:57
@flavorjones flavorjones force-pushed the flavorjones-env-var-to-control-libxml-memmgmt branch from 42c8274 to 3b3de33 Compare April 7, 2023 21:14
@flavorjones flavorjones merged commit 0c1ee6b into main Apr 7, 2023
@flavorjones flavorjones deleted the flavorjones-env-var-to-control-libxml-memmgmt branch April 7, 2023 21:15
@flavorjones flavorjones added this to the v1.15.0 milestone Apr 8, 2023
@flavorjones flavorjones mentioned this pull request Aug 28, 2023
3 tasks
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