libdatadog
libdatadog copied to clipboard
Suspected performance degradation with `ddprof_ffi_Profile_add`
Describe the bug:
As reported by @nsavoire via slack:
I observe a strange behaviour with libdatadog where ddprof_ffi_Profile_add is getting slower and slower even after resetting the profile. At start it takes around ~100us per call (stacks are ~200 frames deep), and after it slowly increase up to ~125us per call.
If I force a restart of our worker process that collect profiles, then this behaviour disappears. Could this be explained by memory allocator performance degrading with time ?
and @r1viollet also added
We discussed this. Memory fragmentation was mentioned using different allocators could help We also mentioned that we need to re-engineer part of the aggregation regardless.
Expected behavior:
Performance should not degrade with a new or newly reset profile.
I have been playing around to write a more efficient string interner. https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e0d9de41fe195efc6a3c72b0ed39efe8
It keeps the interned strings in a contiguous array of memory, which should reduce memory pressure.
Can I close this one ? @ivoanjo fyi
Yeah let's go ahead and close this one. It's been a long while, rust changed, how we store data changed (including to take into account fragmentation), etc, so if this comes up again we'll look into it then.