libdatadog icon indicating copy to clipboard operation
libdatadog copied to clipboard

Suspected performance degradation with `ddprof_ffi_Profile_add`

Open ivoanjo opened this issue 3 years ago • 1 comments

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.

ivoanjo avatar Aug 08 '22 08:08 ivoanjo

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.

paullegranddc avatar Aug 10 '22 13:08 paullegranddc

Can I close this one ? @ivoanjo fyi

r1viollet avatar Sep 09 '24 09:09 r1viollet

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.

ivoanjo avatar Sep 09 '24 10:09 ivoanjo