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

Nhse main i1 dirtynifflag #2

Merged
merged 2 commits into from
Jan 23, 2024
Merged

Conversation

martinsumner
Copy link

Only add the DIRTY_NIF flag when attempting to compress/decompress a relatively large binary - threshold set to 250KB (compression), 50KB (decompression). For small (and one would expect quick) compress/decompress options the overhead of making the call a DIRTY_NIF erodes the performance advantages of using zstd.

https://www.erlang.org/doc/man/erl_nif.html documentation indicates the threshold for being a dirty NIF should be about 1ms.  Generally compress/decompress is much quicker than this.

Testing indicates a significant overhead from using this flag when compress/decompress is in fact very fast.
Using a dirty_nif for smaller objects has a performance penalty so:

- by default don't use the dirty nif if compressing < 250KB or uncompressing < 50KB
- allow application to override and specifically request either dirty or quick method.
@martinsumner martinsumner merged commit 0893569 into nhs-develop Jan 23, 2024
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.

2 participants