Skip to content

feat(dotnet): keep only most recently used strings in memory LRU cache#1338

Open
danielpacak wants to merge 1 commit intoopen-telemetry:mainfrom
danielpacak:feat/dotnet-strings-lru-cache
Open

feat(dotnet): keep only most recently used strings in memory LRU cache#1338
danielpacak wants to merge 1 commit intoopen-telemetry:mainfrom
danielpacak:feat/dotnet-strings-lru-cache

Conversation

@danielpacak
Copy link
Copy Markdown
Contributor

Resolves: #1329

@danielpacak danielpacak requested review from a team as code owners April 9, 2026 11:37
peStringsCacheSize = 1024

// TTL of entries in the LRU cache holding the dotnet strings.
peStringsCacheTTL = 1 * time.Hour
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if these configurations should be exposed in some way as different environment might require different options.
Also, should these settings a bit more aligned? peInfoCacheTTL uses 6 hours and prStringsCacheTTL uses 1 hour.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes perfect sense. The PE cache should be longer to avoid doing the heavy reparsing of PE files. This needs to be smaller to reduce memory usage.

Comment on lines +279 to +283
// stringsReader is the io.SectionReader starting at the dotnet string heap.
stringsReader io.ReaderAt

// file is the reference to the backing file so we can close it when evicted from cache.
file process.ReadAtCloser
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This keeps the file descriptor open. I'm not sure if this causes other problems when the PE cache gets too many cached files and open FDs?

I wonder if it would be possible instead to get only the file offset where the strings section starts. And when reading the string, then use mappings to determine where in the target process this file is mapped and use the remotememory primitive to read it from the running process.

Copy link
Copy Markdown
Contributor Author

@danielpacak danielpacak Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fabled ! That's a good point. In the "worst" case we may end up with at least peInfoCacheSize = 16384 files opened by the ebpf-profiler process. Given that soft and hard limits vary across environments, it's going to crash in the wild sooner than later. So I think holding opened file descriptors is not super scalable.

That said, I'm also leaning towards remote memory access. I'll give it a try and use the remote memory primitive instead.

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.

[.NET] Keep only most recently used strings in memory LRU cache

3 participants