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

internal: VFS no longer stores all source files in memory #16307

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Jan 8, 2024

Turns out there is no need to keep the files around. We either upload them to salsa once processed, or we need to keep them around for the DidChangeTextDocumentNotification, but that notification is only valid for opened documents, so instead we can just keep the files around in the MemDocs!

Fixes #16301

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 8, 2024
crates/vfs/src/lib.rs Outdated Show resolved Hide resolved
crates/vfs/src/lib.rs Outdated Show resolved Hide resolved
@lnicola
Copy link
Member

lnicola commented Jan 8, 2024

@Veykril looks like the sync PR is unlikely to get merged today, so feel free to merge anything that doesn't touch the proc macro server parts.

@Veykril
Copy link
Member Author

Veykril commented Jan 8, 2024

It's fine, I'm done for the day anyways.

Copy link
Contributor

@davidbarsky davidbarsky left a comment

Choose a reason for hiding this comment

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

having touched this side of things, this is a great improvement :)

@lnicola
Copy link
Member

lnicola commented Jan 8, 2024

Let's get it in the nightly.

@bors r+

@bors
Copy link
Contributor

bors commented Jan 8, 2024

📌 Commit 1c40ac7 has been approved by lnicola

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jan 8, 2024

⌛ Testing commit 1c40ac7 with merge c1c2421...

@bors
Copy link
Contributor

bors commented Jan 8, 2024

☀️ Test successful - checks-actions
Approved by: lnicola
Pushing c1c2421 to master...

@bors bors merged commit c1c2421 into rust-lang:master Jan 8, 2024
10 checks passed
@Veykril Veykril deleted the vfs2 branch January 8, 2024 17:34
@roife
Copy link
Member

roife commented Jan 15, 2024

After this PR, if we read a file (Vec<u8>) from vfs-notify, we may store the text in two places (mem_docs and salsa). The text stored in salsa is of type Arc<str>, while in mem_docs it is of type Vec<u8>. Every time we operate on the Vec<u8> retrieved from mem_docs, we need to convert it to String or &str using from_utf8; and after that we need to convert it back to bytes with Vec<u8> to store in mem_docs. Thus, perhaps we can convert the incoming file to UTF-8 in vfs-notify itself, so that we don't have to frequently perform conversions between into_bytes() and from_utf8 in subsequent operations.

Furthermore, I noticed a FIXME in global_state.rs: Consider doing (LineEndings) normalization in the vfs instead? We could also merge this step into vfs-notify, thereby reducing locking on main_loop.

@Veykril
Copy link
Member Author

Veykril commented Jan 15, 2024

Hmm, ye we do one round trip unnecessarily there. We can fix that, though that won't really matter too much I believe.

Regarding the FIXME, that might work though I'm unsure whether that will get rid of any locking (though it might make the lock holding shorter which would also be nice).

@roife
Copy link
Member

roife commented Jan 15, 2024

Hmm, ye we do one round trip unnecessarily there. We can fix that, though that won't really matter too much I believe.

Regarding the FIXME, that might work though I'm unsure whether that will get rid of any locking (though it might make the lock holding shorter which would also be nice).

If this will not have any negative impact on the project, perhaps I can try to do it; at least it can make the project more concise.

@Veykril
Copy link
Member Author

Veykril commented Jan 15, 2024

Feel free to take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VFS takes too much memory
6 participants