Skip to content

perf: shrink global statements cache to size if mostly empty - #1769

Merged
levkk merged 1 commit into
mainfrom
levkk-prep-stmt-hashmap-churn
Oct 9, 2026
Merged

levkk merged 1 commit into
mainfrom
levkk-prep-stmt-hashmap-churn

Conversation

@levkk

@levkk levkk commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

If an app sends a bunch of prepared statements and then immediately closes them (e.g., tokio-postgres does this), we don't clean up the memory from the global prepared statements hashmap. This can cause the memory to grow indefinitely if bursts become larger over time, i.e., more unique statements are generated per run.

Shrink the hashmap to expected size if 75% or more of the space is wasted.

@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@levkk
levkk enabled auto-merge October 9, 2026 21:34
@levkk
levkk added this pull request to the merge queue Oct 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 9, 2026
@levkk
levkk added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit 21979b4 Oct 9, 2026
49 of 51 checks passed
@levkk
levkk deleted the levkk-prep-stmt-hashmap-churn branch October 9, 2026 21:58
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.

1 participant