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

refactor: drop DynRef and move fs into Workspace #4493

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

arendjr
Copy link
Contributor

@arendjr arendjr commented Nov 9, 2024

Summary

The reason DynRef existed was primarily because of tests: It allowed for dynamic ownership which was used to let the Session own the fs under normal execution, which in tests the test owned the fs for snapshot purposes. With this PR, the Workspace has become the owner of the fs, while everywhere else we use references. To resolve the situation in the tests, I've wrapped the files of the MemoryFileSystem in an Arc, which allows me to reconstruct the MemoryFileSystem for the snapshot, even though the original instance was consumed during the test run.

The reason I wanted to place the fs into Workspace is so that we can start doing I/O from inside the workspace server, which this solution also allows for.

Test Plan

CI should remain green.

@arendjr arendjr requested review from a team November 9, 2024 18:22
@github-actions github-actions bot added A-CLI Area: CLI A-Core Area: core A-Project Area: project A-LSP Area: language server protocol labels Nov 9, 2024
&mut console,
Args::from([("check"), "--write", file.as_os_str().to_str().unwrap()].as_slice()),
Args::from(["check", "--write", file.as_os_str().to_str().unwrap()].as_slice()),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: I ran a search-and-replace on the args to remove these odd parentheses. My refactor had to touch all these call sites anyway, so I figured it was a good time to do this. This probably resulted in most of the reduction in line count in this PR.

Copy link

codspeed-hq bot commented Nov 9, 2024

CodSpeed Performance Report

Merging #4493 will not alter performance

Comparing arendjr:drop-dyn-ref (0347941) with next (5407ad4)

Summary

✅ 99 untouched benchmarks

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Let's just merge it as soon as possible since this PR touches many files.

That's a great refactor; thank you, @arendjr, for tackling it!

// Q: We can't use a real filesystem here, but is the memory
// filesystem the right choice? It might be, since I guess it
// will allow us to inject plugins if we wanted to.
inner: workspace::server(Box::new(MemoryFileSystem::default())),
Copy link
Member

Choose a reason for hiding this comment

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

Yeah it should be safe to use the memory file system

@arendjr arendjr merged commit af07896 into biomejs:next Nov 11, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Core Area: core A-LSP Area: language server protocol A-Project Area: project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants