Closed gkorland closed 1 year ago
Thanks for the PR! I'll try to look at this ASAP but feel free to bug me if I don't get around to it in the next few days.
I looked into this, and there are two reasons why it errors:
1) There is some lazily initialized static data from the ahash
crate (simd_json
-> halfbrown
-> hashbrown
-> ahash
) which was being counted as a leak. I resolved this by forcing this to be initialized outside of the tracked region.
2) There is a soundness bug in simd_json
's AlignedBuf
implementation, which triggered mockalloc
to raise an error: https://github.com/simd-lite/simd-json/issues/213
@Diggsey it seems like the bug was fixed in simd_json
This is the fix for the mockalloc
issue:
fn test_simd_decode(data: &[u8]) -> (AllocInfo, AllocInfo) {
+ // `simd_json` uses `hashbrown` which uses `ahash` as the default hasher,
+ // which lazily initializes some static data. Force the initialization to
+ // happen early, or else it will be considered a memory leak.
+ let _ = simd_json::OwnedValue::Object(Default::default());
The new dependencies should also be dev dependencies.
I'd be open to a PR in future to make serde_json
a dev dependency too - currently it's only used for its Error type.
@Diggsey do you think we should move ahead with this PR?
Happy to merge if the errors are fixed and those dependencies are made dev-dependencies.
Closing due to inactivity. Feel free to re-open.
@Diggsey I added two more libraries to the benchmark, but it seems like on simd there is some error.