-
Notifications
You must be signed in to change notification settings - Fork 14k
Make CrateMetadata and CStore thread-safe #48936
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
Conversation
0d9b6ee to
2de21be
Compare
michaelwoerister
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @Zoxc! Looks good to me.
What do you think of adding an InitOnce<T> primitive to rustc_data_structures::sync? Especially things like codemap_import_info would profit from this, I think. I haven't done any performance testing but even if it's not significantly faster, it makes the semantics much clearer which is always a win.
src/librustc_metadata/creader.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add a separate primitive for state that is initialized once and then never modified again. There must be more efficient ways to do this than a mutex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parking_lot::Once looks like a good building block for such a thing.
|
I did think about adding something like |
| } | ||
|
|
||
| /// You cannot use this function to allocate a CrateNum in a thread-safe manner. | ||
| /// It is currently only used in CrateLoader which is single-threaded code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment about this function. next_crate_num is used once in CrateLoader to get the next free CrateNum. CrateLoader may then create multiple CrateNums based on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
At least for |
|
📌 Commit 5b8f9c5 has been approved by |
Make CrateMetadata and CStore thread-safe r? @michaelwoerister
|
☀️ Test successful - status-appveyor, status-travis |
r? @michaelwoerister