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

Store all strings in a cache #439

Merged
merged 1 commit into from
Nov 28, 2024
Merged

Store all strings in a cache #439

merged 1 commit into from
Nov 28, 2024

Conversation

blairsteven
Copy link
Contributor

Save on memory allocations by storing all keys and values in a hashtable and reusing them.

Saves ~15-20% RSS in some real world test cases.

string-cache.h Outdated Show resolved Hide resolved
string-cache.c Outdated Show resolved Hide resolved
string-cache.c Outdated Show resolved Hide resolved
string-cache.c Show resolved Hide resolved
string-cache.c Outdated Show resolved Hide resolved
string-cache.c Outdated Show resolved Hide resolved
Apteryxd can end up storing a lot of duplicated strings. This commit
adds a cache to remove this duplication - it is called the same way
strdup / free would be and will take care of allocating, reference
counting and releasing strings.

This cache has no locking, so needs to be called under an external lock.
At the moment this used solely in code inside the db_lock in database.c
@carlgsmith carlgsmith merged commit 7597a6e into master Nov 28, 2024
1 check passed
@carlgsmith carlgsmith deleted the string_cache branch November 28, 2024 19:35
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.

2 participants