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

Add global string de-duplication cache #3470

Open
tiif opened this issue Apr 16, 2024 · 3 comments
Open

Add global string de-duplication cache #3470

tiif opened this issue Apr 16, 2024 · 3 comments
Labels
A-interpreter Area: affects the core interpreter C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement E-good-first-issue A good way to start contributing, mentoring is available

Comments

@tiif
Copy link
Contributor

tiif commented Apr 16, 2024

Currently, in localtime_r and also for some cases where we raise panics, we allocate a fresh string each time. These strings never get deallocated so they just keep accumulating. Conceptually these are static strings so we can deduplicate them with a global cache.

The cache should be used everywhere that allocate_str is called with MiriMemoryKind::Machine.

@RalfJung RalfJung changed the title String de-duplication for localtime_r Add global string de-duplication cache Apr 16, 2024
@RalfJung
Copy link
Member

(I have updated the issue title and description.)

@RalfJung RalfJung added the E-good-first-issue A good way to start contributing, mentoring is available label Apr 16, 2024
@RalfJung RalfJung added C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement A-interpreter Area: affects the core interpreter labels Apr 18, 2024
@dev-ardi
Copy link

There exist many string interning crates, are you leaning towards any specific one?

@RalfJung
Copy link
Member

RalfJung commented Apr 19, 2024

None of them are usable I think, since the strings need to be interned in machine memory.

This should be just a FxHashMap<Vec<u8>, Pointer<Option<Provenance>>>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-interpreter Area: affects the core interpreter C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement E-good-first-issue A good way to start contributing, mentoring is available
Projects
None yet
Development

No branches or pull requests

3 participants