Skip to content

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

Merged
bors merged 1 commit into
rust-lang:masterfrom
Veykril:vfs2
Jan 8, 2024
Merged

bors merged 1 commit into
rust-lang:masterfrom
Veykril:vfs2

Conversation

@Veykril

@Veykril Veykril commented Jan 8, 2024 •

Copy link
Copy Markdown
Member

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
Comment thread crates/vfs/src/lib.rs Outdated
Comment thread crates/rust-analyzer/tests/slow-tests/main.rs Outdated
Comment thread crates/vfs/src/lib.rs Outdated
@lnicola

lnicola commented Jan 8, 2024 •

Copy link
Copy Markdown
Member

@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

Veykril commented Jan 8, 2024

Copy link
Copy Markdown
Member Author

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

@davidbarsky davidbarsky left a comment

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.

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

@lnicola

lnicola commented Jan 8, 2024

Copy link
Copy Markdown
Member

Let's get it in the nightly.

@bors r+

@bors

bors commented Jan 8, 2024

Copy link
Copy Markdown
Contributor

📌 Commit 1c40ac7 has been approved by lnicola

It is now in the queue for this repository.

@bors

bors commented Jan 8, 2024

Copy link
Copy Markdown
Contributor

⌛ Testing commit 1c40ac7 with merge c1c2421...

@bors

bors commented Jan 8, 2024

Copy link
Copy Markdown
Contributor

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

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

roife commented Jan 15, 2024 •

Copy link
Copy Markdown
Member

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

Veykril commented Jan 15, 2024

Copy link
Copy Markdown
Member Author

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

roife commented Jan 15, 2024

Copy link
Copy Markdown
Member

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

Veykril commented Jan 15, 2024

Copy link
Copy Markdown
Member Author

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