Add arg splat experiment initial tuple impl#153697
Conversation
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
It should be better for someone on https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/On.20overloading/with/573924937 to review this, @oli-obk could you take over? |
|
Let's wait for the ongoing discussion on Zulip to figure out whether we need to have a proc macro, an AST manipulating attribute (like |
89102bf to
c784a57
Compare
c784a57 to
2d9e563
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@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.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (2bd9dab): comparison URL. Overall result: ❌ regressions - 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 4.1%, secondary 3.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 5.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.1%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 482.613s -> 483.026s (0.09%) |
This comment has been minimized.
This comment has been minimized.
Perf UpdateWe expect a 0.1% regression on 5 primary and 0.2% regression on 4 secondary benchmarks in this PR, based on this perf run. We tried a number of different ways to improve perf. Limiting splat to the 255th or lower argument is a simple hack that gives good perf, and is good enough for an experiment. This PR series already has significant perf wins in #155223 - 0.3% perf improvement across 45 primary benchmarks. We're spending a small amount of that perf for the new feature in this PR. @rustbot ready |
|
Umm? @rustbot reviewer |
This comment has been minimized.
This comment has been minimized.
And remove redundant const fn
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| None => { | ||
| if !tuple_arguments.is_splatted() { | ||
| // FIXME(splat): when the arg is splatted, adjust its index | ||
| use_splat_fallback = true; |
There was a problem hiding this comment.
how does this case happen?
There was a problem hiding this comment.
does it only happen in error cases?
There was a problem hiding this comment.
I expanded these comments to clarify it's only for better error handling
|
|
||
| let tupled_args = Expr { | ||
| ty: Ty::new_tup_from_iter(tcx, tupled_arg_tys), | ||
| temp_scope_id: method.temp_scope_id, |
There was a problem hiding this comment.
except for this line, everything leading up to it is 100% equivalent to the function call logic, pull everything into a method and add a flag/enum to make the differences clear (and pass in the receiver as an option, then you can just chain all the pieces together and collect them)
There was a problem hiding this comment.
wait actually even this is equivalent, just loading the same id via different means. so yea, it should just be the receiver that's the difference?
There was a problem hiding this comment.
Yeah the receiver is optional, and it determines:
- the temp_scope_id
- the start of the args list (receiver or just function args)
- the generated call span
The segment was only used for debugging in a span bug, so I removed it.
|
I pushed some fixups for each comment, and resolved the comments that seemed trivial or straightforward. @rustbot ready |
- const, async, and unsafe functions - const generics, complex types, and where clauses (including impl Tuple)
Description
View all comments
This PR is part of the argument splatting lang experiment, and FFI overloading / C++ interop project goals:
Example code using existing unstable features:
Discussion of implementation strategy:
The PR is the initial implementation of the feature:
splatincomplete feature gate#[splat]attribute on function arguments#[splat]function parameter check at THIR levelOnce this PR merges, we can add further functionality, then test it out in interop tools.
Perf Impact
We expect a 0.1% regression on 5 primary and 0.2% regression on 4 secondary benchmarks in this PR, based on this perf run.
We tried a number of different ways to improve perf. Limiting splat to the 255th or lower argument is a simple hack that gives good perf, and is good enough for an experiment.
This PR series already has significant perf wins in #155223 - 0.3% perf improvement across 45 primary benchmarks. We're spending a small amount of that perf for the new feature in this PR.
Out of Scope for this PR