Commit Graph

742 Commits

Author SHA1 Message Date
Stuart Cook
9ace0de26b Rollup merge of #147489 - chenyukang:yukang-prefer-repeat-n, r=Kivooeo,oli-obk
Prefer to use repeat_n over repeat().take()

More from https://github.com/rust-lang/rust/pull/147464, but batch processed with `ast-grep` to find and replace.

second commit add notes for library: affaf532f9

r? ``@RalfJung``
2025-10-09 18:43:26 +11:00
yukang
1654cce210 prefer to use repeat_n over repeat and take 2025-10-09 01:24:55 +08:00
Nicholas Nethercote
19423b7f7f Simplify DepNodeColorMap::try_mark_green.
It uses a different implementation depending on whether the compiler
front-end is running single-threaded or multi-threaded. The two
implementations are equivalent and I think the multi-threaded one
expresses the intent more clearly, and I imagine the perf is similar. So
this commit removes the single-threaded code.
2025-10-07 15:32:34 +11:00
Nicholas Nethercote
ed6a137a32 Tweak DepNodeColorMap::get.
The most common `get` case is green. This commit changes `get` to use
use `if`/`else` instead of match, so that getting green requires one
comparison instead of two.
2025-10-07 15:32:33 +11:00
Nicholas Nethercote
659b758be7 Make DepNodeColor tri-value.
Currently it's binary, either `Green` or `Red`. But it's almost always
used within an `Option`. So it's a bit neater, and possibly slightly
faster, to make it tri-value with `Unknown` as a first-class variant.
2025-10-07 09:37:45 +11:00
Nicholas Nethercote
a4162d9a82 Change DepNodeColorMap::insert to insert_red.
Because it's only ever used for inserting red. (`None` is only used as a
starting value, and `Green` is inserted by `try_mark_green` and
friends.)
2025-10-07 09:33:33 +11:00
Nicholas Nethercote
f644f2c1f3 Avoid passing Option<&MarkFrame<'_>>.
Two functions take arguments of this type, but the `Option` is always
`Some`, so we can just pass `&MarkFrame<'_>` instead.
2025-10-07 09:32:15 +11:00
Nicholas Nethercote
3a287e6034 Remove some unnecessary locals.
They both have a single use. (They can't be united, though, because
`self.colors` might change between the two `get` calls.)
2025-10-03 20:36:21 +10:00
Nicholas Nethercote
cb0f969b62 Avoid getting dep_dep_node unnecessarily.
It's gotten on a hot path but only for use within `debug!`.
2025-10-03 20:34:56 +10:00
Jana Dönszelmann
6087d89004 fixup limit handling code 2025-09-08 15:07:12 -07:00
Stuart Cook
6f490f7ae1 Rollup merge of #146112 - scrabsha:push-utkysktvulto, r=WaffleLapkin
don't uppercase error messages
2025-09-04 10:01:59 +10:00
Sasha Pourcelot
5c4b61b4b4 don't uppercase error messages
a more general version of https://github.com/rust-lang/rust/pull/146080.

after a bit of hacking in [`fluent.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_fluent_macro/src/fluent.rs), i discovered that i'm not the only one that is bad at following guidelines 😅. this pr lowercases the first letter of all the error messages in the codebase.

(i did not change things that are traditionally uppercased such as _MIR_, _ABI_ or _C_)

i think it's reasonable to run a `@bors try` so all the test suite is checked, as i cannot run some of the tests on my machine. i double checked (and replaced manually) all the old error messages, but better be safe than sorry.

in the future i will try to add a check in `x test tidy` that errors if an error message starts with an uppercase letter.
2025-09-03 15:24:49 +02:00
Nicholas Nethercote
301655eafe Revert introduction of [workspace.dependencies].
This was done in #145740 and #145947. It is causing problems for people
using r-a on anything that uses the rustc-dev rustup package, e.g. Miri,
clippy.

This repository has lots of submodules and subtrees and various
different projects are carved out of pieces of it. It seems like
`[workspace.dependencies]` will just be more trouble than it's worth.
2025-09-02 19:12:54 +10:00
Nicholas Nethercote
c50d2cc807 Add tracing to [workspace.dependencies]. 2025-08-27 14:21:19 +10:00
Jana Dönszelmann
e1d3ad89c7 remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
bors
d242a8bd5a Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLii
Some `let chains` clean-up

Not sure if this kind of clean-up is welcoming because of size, but I decided to try out one

r? compiler
2025-07-28 05:25:23 +00:00
Kivooeo
b8eb046e6e use let chains in mir, resolve, target 2025-07-28 06:10:36 +05:00
Cameron Steffen
b8d628c1e1 Use LocalKey<Cell> methods more 2025-07-24 13:21:25 -05:00
Folkert de Vries
226b0fbe11 use is_multiple_of instead of manual modulo 2025-07-05 10:55:35 +02:00
klensy
c76d032f01 setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
Trevor Gross
7b355110df Rollup merge of #142384 - celinval:chores-rayon-mv, r=oli-obk
Bringing `rustc_rayon_core` in tree as `rustc_thread_pool`

This PR moves [`rustc_rayon_core`](https://github.com/rust-lang/rustc-rayon/tree/5fadf44/rayon-core) from commit `5fadf44` as suggested in [this zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/187679-t-compiler.2Fparallel-rustc/topic/Bringing.20.60rustc_rayon_core.60.20in.20tree). I tried to split the work into separate commits so it is easy to review. The first commit is a simple copy and paste from the fork, and subsequent changes were made to use the new crate and to ensure the new crate complies with different format and lint expectations.

**Call-out:** I was also wondering if I need to make any further changes to accommodate licensing requirements.

r? oli-obk
2025-06-20 23:25:54 -04:00
Camille GILLOT
a5ff3cc3f5 Do not clone Arc when hashing span. 2025-06-11 23:44:22 +00:00
Celina G. Val
4aa62ea9e9 Use rustc_thread_pool instead of rustc-rayon-core 2025-06-11 12:26:42 -07:00
bjorn3
9223704f4b Remove all unused feature gates from the compiler 2025-06-08 14:50:42 +00:00
Michael Goulet
cbb3a847d2 Ensure query keys are printed with reduced queries 2025-06-03 20:56:52 +00:00
ismailarilik
85efae7302 Handle rustc_query_system cases of rustc::potential_query_instability lint 2025-05-14 08:59:55 +03:00
Pietro Albini
2ce08ca5d6 update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
bors
3ef8e64ce9 Auto merge of #139758 - Zoxc:thread-local-graph, r=oli-obk
Use thread local dep graph encoding

This adds thread local encoding of dep graph nodes. Each thread has a `MemEncoder` that gets flushed to the global `FileEncoder` when it exceeds 64 kB. Each thread also has a local cache of dep indices. This means there can now be empty gaps in `SerializedDepGraph`.

Indices are marked green and also allocated by the new atomic operation `DepNodeColorMap::try_mark_green` as the encoder lock is removed.
2025-05-07 12:39:54 +00:00
John Kåre Alsaker
cdd104922d Use the portable AtomicU64 2025-05-06 18:36:14 +02:00
Zalathar
9e7fb67838 Rename graph::implementation::Graph to LinkedGraph 2025-05-06 14:35:06 +10:00
John Kåre Alsaker
e1e8857d54 Add some comments about thread local indices 2025-05-05 21:01:43 +02:00
John Kåre Alsaker
aeab2819f6 Tweak index chunk allocation 2025-05-05 20:50:32 +02:00
John Kåre Alsaker
c43a6f05d6 Add some comments 2025-05-01 10:20:34 +02:00
John Kåre Alsaker
d3ec14bbec Use thread local dep graph encoding 2025-05-01 10:20:31 +02:00
John Kåre Alsaker
08b27ffbe8 Add some comments 2025-04-29 12:04:33 +02:00
John Kåre Alsaker
cff9efde74 Add a jobserver proxy to ensure at least one token is always held 2025-04-29 07:20:13 +02:00
bors
e3e432d4d6 Auto merge of #139756 - Zoxc:out-of-order-dep-graph, r=oli-obk
Allow out of order dep graph node encoding

This allows out of order dep graph node encoding by also encoding the index instead of using the file node order as the index.

`MemEncoder` is also brought back to life and used for encoding.

Both of these are done to enable thread-local encoding of dep graph nodes.

This is based on https://github.com/rust-lang/rust/pull/139636.
2025-04-25 15:38:58 +00:00
est31
7493e1cdf6 Make #![feature(let_chains)] bootstrap conditional in compiler/ 2025-04-23 16:40:30 +02:00
John Kåre Alsaker
9a6e8b3807 Make sure there's no duplicate indices in the dep graph 2025-04-22 16:57:28 +02:00
John Kåre Alsaker
36fa327623 Tweak edges 2025-04-22 16:57:28 +02:00
John Kåre Alsaker
4ec74df81f Use IndexVec::from_elem_n 2025-04-22 16:57:28 +02:00
John Kåre Alsaker
c6735f92c1 Add index to the dep graph format and encode via MemEncoder 2025-04-22 16:57:28 +02:00
Matthias Krüger
844b7c7935 Rollup merge of #139236 - Zoxc:anon-counter, r=davidtwco
Use a session counter to make anon dep nodes unique

This changes the unique session hash used to ensure unique anon dep nodes per session from a timestamp to a counter.

This is nicer for debugging as it makes the dep graph deterministic.
2025-04-17 00:14:24 +02:00
Jacob Pratt
5c494aa5c8 Rollup merge of #139636 - Zoxc:graph-edges-len-u32, r=compiler-errors
Encode dep node edge count as u32 instead of usize

This encodes the dep node edge count as u32 instead of usize. It doesn't need to be usize as the count is limited the the unique number of dep nodes which we use a 32-bit index for. It probably saves some branches for encoding / decoding, but it isn't too hot as the count gets packed in with other fields when it's low.

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th><td align="right">Physical Memory</td><td align="right">Physical Memory</td><td align="right">%</th><td align="right">Committed Memory</td><td align="right">Committed Memory</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check:unchanged</td><td align="right">0.3343s</td><td align="right">0.3343s</td><td align="right"> -0.00%</td><td align="right">97.02 MiB</td><td align="right">96.89 MiB</td><td align="right"> -0.13%</td><td align="right">167.93 MiB</td><td align="right">167.80 MiB</td><td align="right"> -0.08%</td></tr><tr><td>🟣 <b>hyper</b>:check:unchanged</td><td align="right">0.1353s</td><td align="right">0.1350s</td><td align="right"> -0.19%</td><td align="right">61.91 MiB</td><td align="right">61.83 MiB</td><td align="right"> -0.13%</td><td align="right">124.64 MiB</td><td align="right">124.64 MiB</td><td align="right"> 0.00%</td></tr><tr><td>🟣 <b>regex</b>:check:unchanged</td><td align="right">0.2479s</td><td align="right">0.2481s</td><td align="right"> 0.10%</td><td align="right">78.34 MiB</td><td align="right">78.35 MiB</td><td align="right"> 0.02%</td><td align="right">145.20 MiB</td><td align="right">145.31 MiB</td><td align="right"> 0.08%</td></tr><tr><td>🟣 <b>syn</b>:check:unchanged</td><td align="right">0.5347s</td><td align="right">0.5333s</td><td align="right"> -0.26%</td><td align="right">118.63 MiB</td><td align="right">118.66 MiB</td><td align="right"> 0.02%</td><td align="right">193.05 MiB</td><td align="right">193.11 MiB</td><td align="right"> 0.03%</td></tr><tr><td>Total</td><td align="right">1.2521s</td><td align="right">1.2507s</td><td align="right"> -0.11%</td><td align="right">355.90 MiB</td><td align="right">355.74 MiB</td><td align="right"> -0.05%</td><td align="right">630.83 MiB</td><td align="right">630.87 MiB</td><td align="right"> 0.01%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9991s</td><td align="right"> -0.09%</td><td align="right">1 byte</td><td align="right">1.00 bytes</td><td align="right"> -0.06%</td><td align="right">1 byte</td><td align="right">1.00 bytes</td><td align="right"> 0.01%</td></tr></table>
2025-04-13 23:57:37 -04:00
John Kåre Alsaker
22dd86c015 Encode dep node edge count as u32 instead of usize 2025-04-10 20:59:22 +02:00
John Kåre Alsaker
1c568bbe6f Reuse the index from promoted nodes when coloring executed tasks 2025-04-05 14:41:08 +02:00
John Kåre Alsaker
927ad1659a Add a dep kind for use of the anon node with zero dependencies 2025-04-02 07:35:05 +02:00
John Kåre Alsaker
027251ff7d Use a session counter to make anon dep nodes unique 2025-04-02 07:12:01 +02:00
Michael Goulet
897acc3e5d Encode synthetic by-move coroutine body with a different DefPathData 2025-03-30 22:53:21 +00:00
Jacob Pratt
3a8621d681 Rollup merge of #138844 - petrochenkov:cfgtrace2, r=nnethercote
expand: Leave traces when expanding `cfg` attributes

This is the same as https://github.com/rust-lang/rust/pull/138515, but for `cfg(true)` instead of `cfg_attr`.

The difference is that `cfg(true)`s already left "traces" after themselves - the `cfg` attributes themselves, with `expanded_inert_attrs` set to true, with full tokens, available to proc macros.
This is not a reasonably expected behavior, but it could not be removed without a replacement, because a [major rustdoc feature](https://github.com/rust-lang/rfcs/pull/3631) and a number of clippy lints rely on it. This PR implements a replacement.

This needs a crater run, because it changes observable behavior (in an intended way) - proc macros can no longer see expanded `cfg(true)` attributes.

(Some minor unnecessary special casing for `sym::cfg_attr` is also removed in this PR.)

r? `@nnethercote`
2025-03-27 13:11:17 -04:00