GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(app): skip the eviction pass when it cannot evict by Te-River · Pull Request #54302 · anomalyco/opencode

Conversation

@Te-River

@Te-River Te-River commented Oct 10, 2026 •
edited by opencode-agent Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Refs #54295. This does not close it: the pass is not what causes the stall, and the rendering cost is tracked in #54305.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

runEviction runs on every event that carries a location. It walks the directory stores, filters the pinned ones (a comparablePath call each), builds a Set and sorts — even when nothing can be evicted.

pickDirectoriesToEvict now returns early when the store count is at or under max and no store is idle past the ttl: in that state it can only return idle directories, so the result is empty. The rule lives in that one function, using its own max / ttl / now; child-store.ts keeps only the call.

How did you verify your code works?

  • Equivalence: a randomized harness over 7400 store/pin/idle/skip combinations, comparing the old and new paths — no mismatch.
  • bun test --conditions=solid --preload ./happydom.ts ./src/runtime/server/global-sync: 28 passed, 0 failed, the same as the stashed baseline.
  • tsgo -b: only the pre-existing src/custom-elements.d.ts TS1128.

The profile that motivated this puts the whole pass at 0.6ms over 1401 events, so this is a cleanup rather than a fix — paired runs are inside the noise. The benchmark that measures it is in #54328.

Screenshots / recordings

n/a

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #54295, #54305, #51423

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Te-River
Te-River requested review from Brendonovich and Hona as code owners October 10, 2026 12:32
@github-actions github-actions Bot added the needs:title label Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title perf(app): skip the eviction pass when it cannot evict doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 10, 2026
app: every server event walks the whole directory store, so parallel sessions multiply main-thread work #54295
Open
app: each visible streaming delta re-walks the whole markdown node array in the session-ui store #54305
Open
opencode-agent[bot]
opencode-agent Bot reviewed Oct 10, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The early return is correct. It returns only when there is no overflow and no store is idle past the TTL, and in that state pickDirectoriesToEvict always returns an empty list. I checked this by reading the code. I did not measure performance: the stall in #54295 needs the desktop app on Windows with real streaming sessions. The global-sync tests show the same result as on the base (the one bootstrap.test.ts failure is a module export problem in this environment), and typecheck passes. The public API is unchanged.

Concerns:

  • The guard adds a second copy of the eviction rule for no measurable gain. The overflow and idle check now lives in both child-store.ts and eviction.ts, and the two must stay in sync. Your own profile puts the whole pass at 0.6ms over 1,401 events, with paired runs inside the noise. If you want the shortcut, return early at the top of pickDirectoriesToEvict so the rule stays in one place. Otherwise this part can be dropped (see inline).
  • This should not close #54295. You and the earlier investigation both found that this pass isn't what causes the stall: the cost is in rendering visible deltas (markdown.tsx updateBlock and the solid-js/store unwrap walk). Merging with Closes #54295 would close an issue that is still open. Please change it to a plain reference, and consider opening the issue about the rendering cost that you suggested.
  • The 261-line benchmark is a separate change. It doesn't show any difference for this fix, and it is large for one change. Please move it into its own PR so this one stays minimal.

Related: #51423

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/app/src/runtime/server/global-sync/child-store.ts Outdated
if (stores.length === 0) return
const now = Date.now()

// A store is only evictable when the count is over the cap or it has been idle

@opencode-agent opencode-agent Bot Oct 10, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This adds a second copy of the overflow and idle rule from pickDirectoriesToEvict (eviction.ts), and the two now have to stay in sync. The benefit is within noise by your own measurements (0.6ms over 1,401 events). If you keep the shortcut, put it at the top of pickDirectoriesToEvict, before the filter and sort. That skips the same work without a second copy of the rule and makes the comment unnecessary. Otherwise I'd drop this part.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Te-River Te-River changed the title perf(app): skip the eviction pass when it cannot evict refactor(app): skip the eviction pass when it cannot evict Oct 10, 2026
@github-actions github-actions Bot removed the needs:title label Oct 10, 2026
@Te-River

Te-River commented Oct 10, 2026

Copy link
Copy Markdown
Author

All three addressed.

The guard now lives in one place. It moved to the top of pickDirectoriesToEvict, using that function's own max / ttl / now; child-store.ts keeps only the call. Equivalence checked with a randomized harness over 7400 store/pin/idle/skip combinations — no mismatch. global-sync tests: 28 passed, same as the stashed baseline.

Closes #54295 is now a plain reference. You are right that merging this would close an issue that is still open. The rendering cost has its own issue: #54305.

The benchmark moved to #54328. This PR is now +11/−1 across two files.

The profile that motivated the shortcut puts the whole pass at 0.6ms over 1401 events, so the description now says cleanup rather than fix.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@opencode-agent opencode-agent Bot mentioned this pull request Oct 10, 2026
test(app): add a parallel-session event benchmark #54328
Closed
3 of 7 tasks
@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:41
@Te-River
Te-River force-pushed the session-event-fanout branch 6 times, most recently from a6a01b3 to e82301b Compare October 17, 2026 13:09
@Te-River
Te-River force-pushed the session-event-fanout branch 3 times, most recently from 7321719 to 1d1a683 Compare October 22, 2026 00:57
opencode-agent[bot]
opencode-agent Bot reviewed Oct 22, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The earlier points are addressed. The shortcut now lives only in pickDirectoriesToEvict and returns early only when the existing loop would also return an empty list, so behaviour is unchanged. The PR no longer closes #54295, and the benchmark moved to #54328. The global-sync tests give the same results as on the base, and typecheck passes. The public API is unchanged. No further concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Te-River
Te-River force-pushed the session-event-fanout branch from 1d1a683 to 7abc837 Compare October 23, 2026 11:11
opencode-agent[bot]
opencode-agent Bot reviewed Oct 23, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Earlier points are still addressed: the shortcut lives only in pickDirectoriesToEvict, and this push is just a rebase, with the change itself unchanged. I re-checked that it returns early only when the existing loop would also return an empty list, so behaviour is unchanged. The global-sync tests give the same results as on the base, and tsc -b in packages/app passes. The public API is unchanged. No further concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Te-River
Te-River force-pushed the session-event-fanout branch from 7abc837 to a3e9922 Compare October 24, 2026 02:59
opencode-agent[bot]
opencode-agent Bot reviewed Oct 24, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This push is a rebase and the change itself is unchanged. The shortcut lives only in pickDirectoriesToEvict and returns early only when the existing loop would also return an empty list, so behaviour is unchanged. The global-sync tests give the same results as on the base, and tsc -b in packages/app passes. The public API is unchanged. No further concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Te-River
Te-River force-pushed the session-event-fanout branch from a3e9922 to 94bf330 Compare October 24, 2026 11:52
opencode-agent[bot]
opencode-agent Bot reviewed Oct 24, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This push is a rebase and the change itself is unchanged. The shortcut lives only in pickDirectoriesToEvict and returns early only when the existing loop would also return an empty list, so behaviour is unchanged. The global-sync tests give the same results as on earlier versions, and tsc -b in packages/app passes. The public API is unchanged. No further concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Te-River
perf(app): skip the eviction pass when it cannot evict
0d72196
runEviction runs on every event that carries a location. It walks the directory stores, filters the pinned ones (a comparablePath call each), builds a Set and sorts, even when nothing can be evicted.

Skip it when the store count is at or under the cap and no store is idle past the TTL: pickDirectoriesToEvict can then only return idle directories, so the result is empty.

Adds a benchmark for the parallel-session event path. A renderer profile of it puts this pass at 0.6ms over 1401 events; the dominant cost is the visible session's markdown re-render, not the fan-out.
Te-River added 2 commits October 25, 2026 18:55
@Te-River
test(app): move the parallel-session benchmark to its own PR
6d48502
It shows no difference for the eviction skip, and 261 lines is large for this change. Now in anomalyco#54328.
@Te-River
refactor(app): move the eviction shortcut into pickDirectoriesToEvict
7ea8800
The guard was a second copy of the rule that pickDirectoriesToEvict already owns, and the two had to stay in sync. It now sits at the top of that function, using its own max/ttl/now, and child-store.ts keeps only the call.

Equivalence checked with a randomized harness over 7400 store/pin/idle/skip combinations: no mismatch. The global-sync tests are 28 pass / 0 fail, the same as the stashed baseline.
@Te-River
Te-River force-pushed the session-event-fanout branch from 94bf330 to 7ea8800 Compare October 25, 2026 11:17
opencode-agent[bot]
opencode-agent Bot reviewed Oct 25, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This push is a rebase and the change itself is unchanged. The shortcut lives only in pickDirectoriesToEvict and returns early only when the existing loop would also return an empty list, so behaviour is unchanged. The global-sync tests give the same results as on earlier versions, and tsc -b in packages/app passes. The public API is unchanged. No further concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Te-River

Te-River commented Oct 25, 2026

Copy link
Copy Markdown
Author

Closing to stay under this repository's open pull request limit. The branch is unchanged and can be reopened when there is room; the change and its measurement are recorded in #54295.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Te-River Te-River closed this Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments
@Hona Hona Awaiting requested review from Hona
@Brendonovich Brendonovich Awaiting requested review from Brendonovich

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Te-River
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.