simplify some proc_macro things#157271
Conversation
|
rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
simplify some `proc_macro` things
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (aba743d): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 0.4%, secondary -5.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.9%, secondary -2.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 511.375s -> 517.888s (1.27%) |
|
|
||
| fn ts_drop(&mut self, stream: Self::TokenStream) { | ||
| drop(stream); | ||
| } |
There was a problem hiding this comment.
Wouldn't this cause all tokenstreams to be unnecessarily retained on the server side until the end of the proc macro invocation even if the client drops it earlier?
There was a problem hiding this comment.
Yeah, the motivation is missing for this change now - what did this drop do, what happens now when it's removed, why it's good.
There was a problem hiding this comment.
The main reason for this change is that currently all TokenStream implementations are wrapped in an Arc or Rc and I would not expect that to change. So none of them need anything special happening to drop them.
It seemed wasteful to me to have to go through the bridge just to drop the value considering this and the assumption that in most of these cases, dropping a token stream would just decrease the Arcs refcount by 1 without actually freeing the underlying value already. So I expected the perf gain from no longer going through the bridge to drop them to outweigh the cost of storing them a little longer. But I may very well be mistaken here.
There was a problem hiding this comment.
The server side needs to be notified somehow that the client side dropped the TokenStream. Otherwise it will stick around in the OwnedStore until the proc macro finishes. This notifying is done by passing it to ts_drop.
| // We have the array method separate from extending from a slice. This is | ||
| // because in the case of small arrays, codegen can be more efficient | ||
| // (avoiding a memmove call). With extend_from_slice, LLVM at least | ||
| // currently is not able to make that optimization. |
There was a problem hiding this comment.
Any specific reason to remove this optimization?
It would probably be better to benchmark it separately in any case.
There was a problem hiding this comment.
I've removed this change from this PR. It's not too important either.
| len: usize, | ||
| capacity: usize, | ||
| reserve: extern "C" fn(Buffer, usize) -> Buffer, | ||
| drop: extern "C" fn(Buffer), |
There was a problem hiding this comment.
Why is it better to directly manage Buffer memory without using Vec?
There was a problem hiding this comment.
Locally, this showed some promising improvements of instruction counts for some crates. I've removed it from this PR again for now since it seems to affect others negatively, its now in #157451.
This comment has been minimized.
This comment has been minimized.
7f9f32a to
750ea38
Compare
mark `Encode`, `Decode`, `Mark` impls as `#[inline]` Related to rust-lang#157271 (though it was not a part of it). This looked pretty promising locally.
mark `Encode`, `Decode`, `Mark` impls as `#[inline]` Related to rust-lang#157271 (though it was not a part of it). This looked pretty promising locally.
mark `Encode`, `Decode`, `Mark` impls as `#[inline]` Related to rust-lang#157271 (though it was not a part of it). This looked pretty promising locally.
mark `Encode`, `Decode`, `Mark` impls as `#[inline]` Related to rust-lang#157271 (though it was not a part of it). This looked pretty promising locally.
mark `Encode`, `Decode`, `Mark` impls as `#[inline]` Related to rust-lang#157271 (though it was not a part of it). This looked pretty promising locally.
mark `Encode`, `Decode`, `Mark` impls as `#[inline]` Related to rust-lang#157271 (though it was not a part of it). This looked pretty promising locally.
Each commit should be reviewable on its own. Locally, this also resulted in some slightly better perf results.