Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Increase `Span` from 4 bytes to 8 bytes. #59693
Conversation
|
I was pleasantly surprised how large the improvements are. Some instruction counts results for Check builds:
Here is part of a Cachegrind diff showing the changes for a Check-CleanIncr build of
Mostly TLS stuff and interning stuff, which makes sense. |
|
@bors try |
Increase `Span` from 4 bytes to 8 bytes. This increases the size of some important types, such as `ast::Expr` and `mir::Statement`. However, it drastically reduces how much the interner is used, and the fields are more natural sizes that don't require bit operations to extract. As a result, instruction counts drop across a range of workloads, by as much as 10% for `script-servo` incremental builds. Peak memory usage goes up a little for some cases, but down by more for some other cases -- as much as 18% for non-incremental builds of `packed-simd`. The commit also: - removes the `repr(packed)`, because it has negligible effect, but can cause undefined behaviour; - replaces explicit impls of common traits (`Copy`, `PartialEq`, etc.) with derived ones. r? @petrochenkov
|
It's interesting that TLS is so expensive. Makes me wonder if other TLS data (e.g. symbols) could be done some other way. |
|
Actually, I don't understand |
|
Previous discussion for reference - #58458. |
That's entirely @Zoxc's creation, I don't understand our threading setup. |
|
@nnethercote |
|
Is the interned case uncommon enough to throw |
|
|
Yes! It's very rare for len to hit 16 bits in any code. But ctxt depends on the crate size, so in very large crates a decent number of ctxts could require 16 bits. In fact, ideally I'd probably use something like 11 bits for len and 20 for ctxt, but those sizes aren't as natural. I'll add a comment about this. |
It's fine by me, though I thought they were generally frowned upon in Rust code... |
|
@rust-timer build cfa7765 |
|
Success: Queued cfa7765 with parent f717b58, comparison URL. |
That's what I expected, ctxt behaves in a similar way to base and can just grow and grow, and that's different from len. |
|
Finished benchmarking try commit cfa7765 |
|
The CI results are even better than what I saw locally, yay. |
This increases the size of some important types, such as `ast::Expr` and `mir::Statement`. However, it drastically reduces how much the interner is used, and the fields are more natural sizes that don't require bit operations to extract. As a result, instruction counts drop across a range of workloads, by as much as 12% for incremental "check" builds of `script-servo`. Peak memory usage goes up a little for some cases, but down by more for some other cases -- as much as 18% for non-incremental builds of `packed-simd`. The commit also: - removes the `repr(packed)`, because it has negligible effect, but can cause undefined behaviour; - replaces explicit impls of common traits (`Copy`, `PartialEq`, etc.) with derived ones.
|
@petrochenkov: I have updated the comments as per the suggestions above. And thanks for suggesting 64-bits in the first place! :) |
|
The previous measurements (#44646 (comment)) for 64 bits looked very different (that's why 32 was selected in the first place). I wonder what changed since Sep 2017. (I'll review the code this evening.) |
|
Code LGTM, but I'd want to run #59749 through perf before merging this. |
|
They are not thread-specific. There is one per rustc session, which can have multiple threads. TLS is just used to avoid explicitly passing arguments to libsyntax functions. |
|
I see, then I'm not sure why it's per-session and not global. |
|
There can be multiple rustc sessions in a process. RLS and rustdoc does that. |
|
I mean, why can't multiple sessions share a single interner? |
|
@bors rollup |
…enkov Increase `Span` from 4 bytes to 8 bytes. This increases the size of some important types, such as `ast::Expr` and `mir::Statement`. However, it drastically reduces how much the interner is used, and the fields are more natural sizes that don't require bit operations to extract. As a result, instruction counts drop across a range of workloads, by as much as 10% for `script-servo` incremental builds. Peak memory usage goes up a little for some cases, but down by more for some other cases -- as much as 18% for non-incremental builds of `packed-simd`. The commit also: - removes the `repr(packed)`, because it has negligible effect, but can cause undefined behaviour; - replaces explicit impls of common traits (`Copy`, `PartialEq`, etc.) with derived ones. r? @petrochenkov
Rollup of 17 pull requests Successful merges: - #59675 (Stabilize the `alloc` crate.) - #59693 (Increase `Span` from 4 bytes to 8 bytes.) - #59708 (Mark variables captured by reference as mutable correctly) - #59735 (remove lookup_char_pos_adj) - #59747 (Copy book.toml unstable book generator) - #59752 (Limit dylib symbols) - #59796 (Retire `IsNotConst` naming) - #59804 (Clean up jobserver integration) - #59818 (Eliminate `FnBox` usages from libstd.) - #59830 (Fix links on keyword docs.) - #59835 (Re-export NonZero signed variant in std) - #59852 (std: Add `{read,write}_vectored` for more types) - #59855 (Fix attributes position in type declaration) - #59858 (Make duplicate matcher bindings a hard error) - #59879 (Use SecRandomCopyBytes instead of /dev/urandom on MacOS) - #59899 (In `-Zprint-type-size` output, sort enum variants by size.) - #59912 (MaybeUninit: remove deprecated functions) Failed merges: r? @ghost
|
It's too late now, but for next time: PRs with significant perf effects are better landed on their own, rather than in a rollup, to keep the perf data clear. For example, if some other PR in the rollup introduces a perf regression, that would be masked by the improvement in this PR. |
|
@bors rollup- |
|
@bors p=1 |
Increase `Span` from 4 bytes to 8 bytes. This increases the size of some important types, such as `ast::Expr` and `mir::Statement`. However, it drastically reduces how much the interner is used, and the fields are more natural sizes that don't require bit operations to extract. As a result, instruction counts drop across a range of workloads, by as much as 10% for `script-servo` incremental builds. Peak memory usage goes up a little for some cases, but down by more for some other cases -- as much as 18% for non-incremental builds of `packed-simd`. The commit also: - removes the `repr(packed)`, because it has negligible effect, but can cause undefined behaviour; - replaces explicit impls of common traits (`Copy`, `PartialEq`, etc.) with derived ones. r? @petrochenkov
|
|
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
"warning: spurious network error" @bors retry |
Increase `Span` from 4 bytes to 8 bytes. This increases the size of some important types, such as `ast::Expr` and `mir::Statement`. However, it drastically reduces how much the interner is used, and the fields are more natural sizes that don't require bit operations to extract. As a result, instruction counts drop across a range of workloads, by as much as 10% for `script-servo` incremental builds. Peak memory usage goes up a little for some cases, but down by more for some other cases -- as much as 18% for non-incremental builds of `packed-simd`. The commit also: - removes the `repr(packed)`, because it has negligible effect, but can cause undefined behaviour; - replaces explicit impls of common traits (`Copy`, `PartialEq`, etc.) with derived ones. r? @petrochenkov
|
|
|
Btw, there may be a way to fit The reason is that we could allocate new "files" (or maybe even just one chunk, since it should often suffice) for the version with a And so two values (file + |
swc_common: - apply patch from rust-lang/rust#59693 swc: - use &Options instead of Options - configures commons::CM - exposes `handler`
This increases the size of some important types, such as
ast::Exprandmir::Statement. However, it drastically reduces how much the interneris used, and the fields are more natural sizes that don't require bit
operations to extract.
As a result, instruction counts drop across a range of workloads, by as
much as 10% for
script-servoincremental builds.Peak memory usage goes up a little for some cases, but down by more for
some other cases -- as much as 18% for non-incremental builds of
packed-simd.The commit also:
repr(packed), because it has negligible effect, but cancause undefined behaviour;
Copy,PartialEq, etc.)with derived ones.
r? @petrochenkov