-
Notifications
You must be signed in to change notification settings - Fork 13.3k
proc_macro/bridge: remove client->server &HandleCounters
passing.
#98223
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
This comment was marked as off-topic.
This comment was marked as off-topic.
(rust-highfive has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit b251053 with merge d75ab565e15dc39a3d43092f34ca45733cf34a90... |
☔ The latest upstream changes (presumably #98186) made this pull request unmergeable. Please resolve the merge conflicts. |
☀️ Try build successful - checks-actions |
Queued d75ab565e15dc39a3d43092f34ca45733cf34a90 with parent ff86b27, future comparison URL. |
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.
This looks good and should make future bridge mechanism changes a bit easier :-)
FWIW this does conflict with (one of the more sketchy) ideas from my (very old) PR #86816. Specifically the handling of non-blocking RPC for calls like TokenStream::clone()
or stream concatenation was implemented in that PR by atomically generating a new handle to use for the response object on the client side, and sending it to the server to use for the result.
That approach was probably not the right one either way, and there are other ways to generate non-conflicting IDs on server and client if that turns out to be valuable in the future (e.g. count down starting at u32::MAX
for client-generated IDs), but I figured it was worth noting :-)
// FIXME(eddyb) these counters are server-side, so they don't | ||
// protect against the same proc macro dylib being used with | ||
// multiple servers - however, that's very unlikely, and should | ||
// be protected against through other means (e.g. forcing a | ||
// specific proc macro dylib to always talk to the same server | ||
// that initially loaded it). |
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.
Perhaps mention "the same dylib" or something like that? This could be interpreted as "the proc_macro_server::Rustc
object should be the same for every invocation of a macro from each crate", which I don't think is what you're suggesting (as ideally I'd imagine that we we want to throw out HandleStore
after each invocation of a proc macro, and only keep around the handle counter to avoid conflicts, which is done here by using a static for the counter).
Finished benchmarking commit (d75ab565e15dc39a3d43092f34ca45733cf34a90): comparison url. Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Footnotes |
I don't see any problems here, but I won't pretend to understand this code well enough to properly review changes, and it's clear that @mystor understands it better than I do. Having said that:
|
Anyway, if @mystor is happy with this then I am happy to give r+. |
LGTM. Only comment I have is the one I mentioned above (#98223 (comment)) about the misleading FIXME comment, but it's fine as-is. |
✌️ @eddyb can now approve this pull request |
(FWIW there should be no need for a Also, I've been meaning to reply to #98223 (comment) - I'd already forgotten how much that PR did (I only remembered the "moving |
True, but I chose to use the official delegation mechanism because it's clearer than the alternatives. |
Hello @eddyb and @nnethercote! Just checking in on how this is coming along. From reading over the PR, it sounds like this (partially?) subsumes #97445 which we visited during this PR review in this week's compiler team triage meeting. If not, we're thinking of re-rolling reviewers on that PR as it seems to be straightforward cleanups. |
This PR has r+ from me, it just needs to be rebased and a couple of comments added. Once that merges I will rebase #97445. |
(the merge conflicts aren't the issue) When I said "the weekend" back in #98223 (comment) that turned out to be several weeks and I still haven't been able to catch up with a lot of |
friendly ping @eddyb when you have a a chance for the last touches (IIRC we're close to merge this 🙂 ) |
@eddyb |
Triage: I'm closing this due to inactivity @rustbot label: +S-inactive |
Just like #97461, this was inspired by @nnethercote's efforts in this area (see #97004 (comment)).
The purpose of the counters was never to protect from server-side misuse, only client-side misuse (e.g. a proc macro storing a
proc_macro
public API type in TLS), so the FIXME comment should suffice for now.As this PR removes
get_handle_counters
(the only non-ZSTClient
field other thanrun
, since #97461), it will allow a#[repr(transparent)]
Client
that only newtypes therun
C ABI entry-pointfn
pointer (and in the context of e.g. wasm isolation, that's all you want, since you can reason about it from outside the wasm VM, as just a 32-bit "function table index", that you can pass to the wasm VM to call that function).However, I haven't changed any
#[repr]
attributes in this PR to avoid unforseen perf interactions.cc @mystor @bjorn3