Skip to content

fix(apollo-forest-run): fix perf regression from new auto-eviction#657

Merged
vladar merged 3 commits intomainfrom
vladar/fr-fix-autoevict-perf
Apr 9, 2026
Merged

fix(apollo-forest-run): fix perf regression from new auto-eviction#657
vladar merged 3 commits intomainfrom
vladar/fr-fix-autoevict-perf

Conversation

@vladar
Copy link
Copy Markdown
Contributor

@vladar vladar commented Mar 27, 2026

Overview

A follow up for #653 Fixes a minor perf regression by changing how operations per partition are tracked.

Details

With #653 every write was leading to auto-eviction attempt. And the "size" of every partition had to be calculated every time "lazily" because partition was not "assigned" to a tree until eviction time.

With this PR partition is assigned when the tree is added to the forest. This way we can skip auto eviction if partition is not big enough yet.

Current threshold: auto-eviction kicks-in when partition grows 2x of the configured partition size. After eviction it shrinks to 1x and doesn't try to auto-evict until it reaches 2*x again.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 27, 2026

📊 Benchmark Analysis Report

🔍 Found 2 significant change(s)

🎯 Same Configuration Comparisons

Comparing against baseline with the same cache configuration

Benchmark ID Configuration Execution Memory
write-no-changes_0 Default 🟢 12727.68 ns → 11877.43 ns (-6.7%) 🟢 4606.12 bytes → 3700.19 bytes (-19.7%)
modify-affecting-0-objects_0 Default 🟢 3866.64 bytes → 3441.88 bytes (-11.0%)

Threshold: 5% change


Updated: 2026-04-09T11:25:18.380Z

@vladar vladar marked this pull request as ready for review March 27, 2026 16:06
Comment on lines -170 to +130
// Process each partition
for (const {
options: partitionConf,
operations: evictableOperationIds,
} of partitionsOps.values()) {
// During auto-eviction, respect per-partition autoEvict settings
if (isAutoEvict) {
if (!partitionConf.autoEvict) {
continue;
}
}
const maxCount = partitionConfig.maxOperationCount;
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.

I think we may need to restore the

if (isAutoEvict && !partitionConfig.autoEvict) { continue; }

check here.

if partition A { autoEvict: false } is over maxOpCount and partition B { autoEvict: true } is written to and also over maxOpCount * 2 this would cause partition A to auto evict

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See 7c2a6ef, also added a test for this case

…viction

evictOldData now respects per-partition autoEvict flag when triggered automatically

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vladar vladar merged commit 07fc20b into main Apr 9, 2026
6 checks passed
@vladar vladar deleted the vladar/fr-fix-autoevict-perf branch April 9, 2026 15:00
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.

3 participants