Skip to content

internal: Reduce the size of HirFileId from 8 to 4 bytes #13678

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

Merged
merged 1 commit into from
Nov 25, 2022

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Nov 25, 2022

This saves 10mb on self analysis, while this does limit us to 2billion real files and 2 billion macro expansions, I doubt we will ever hit that limit :) HirFileId is used a lot, so going from 8 bytes to 4 is a decent win.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 25, 2022
@Veykril
Copy link
Member Author

Veykril commented Nov 25, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Nov 25, 2022

📌 Commit 7bf2a25 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Nov 25, 2022

⌛ Testing commit 7bf2a25 with merge d2281f0...

@Veykril Veykril changed the title Encode the variants of HirFileId in a u32 with MSB as the tag internal: Reduce the size of HirFileId from 8 to 4 bytes Nov 25, 2022
@bors
Copy link
Contributor

bors commented Nov 25, 2022

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing d2281f0 to master...

@bors bors merged commit d2281f0 into rust-lang:master Nov 25, 2022
@Veykril Veykril deleted the hir-file-encode branch November 25, 2022 22:51
@lnicola
Copy link
Member

lnicola commented Nov 26, 2022

Dashboard confirms 10 MB:

image

Does this mean we have 10 MB / 4 bytes = 2.5M instances?

@Veykril
Copy link
Member Author

Veykril commented Nov 26, 2022

well, it is used a lot. But it is also used in some enum variants I think so there it might also affect the max size of the enum.

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.

4 participants