fix(opencode): avoid search retention for file reads#32238
Open
hereswilson wants to merge 1 commit into
Open
Conversation
172f32e to
03a70b1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #32237
This may also be related to #20695, but this PR only addresses repeated file route reads initializing and retaining search state.
Type of change
What does this PR do?
Repeated
/file/contentreads were going through the cached location file system service. That service can initialize and retain file search state, even though reading one file does not need search.This changes the file system service so search is loaded lazily.
readandlistno longer initialize search.find,glob, andgrepstill load search when they need it.The HTTP file handlers now use a direct file system layer for
/file/contentand/file./find/filestill uses the cached location services because search benefits from being warm.I also added tests for the important behavior:
How did you verify your code works?
I verified this with focused tests, type checks, and a local workload harness.
The harness is outside this repo. It creates temporary workspaces, starts
opencode serve, calls file routes, and samplesopencode-serveResident Set Size during the run.Focused
/file/contentworkload:Before this change:
523.1 MB993.0 MBAfter this change:
59.2 MB522.8 MB0Warm read latency did not regress in the same run. Warm
/file/contentreads were p5034.2 ms, p9555.5 ms, p9966.4 ms.I also checked adjacent file routes.
/find/filestill uses the cached search path, and warm search latency stayed in the same range.Local checks:
bun test test/location-filesystem.test.tsfrompackages/corebun test --timeout 30000 test/server/httpapi-file.test.ts test/server/httpapi-sdk.test.tsfrompackages/opencodebun typecheckfrompackages/corebun typecheckfrompackages/opencodegit diff --checkScreenshots / recordings
N/A. This is not a UI change.
Checklist