Commit Graph

428 Commits

Author SHA1 Message Date
Camille GILLOT
4224b4b1f5 Re-allow computing fed queries. 2023-04-20 17:09:26 +00:00
bors
d7f9e81650 Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco
Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`

Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-19 08:26:47 +00:00
bors
b3f1379509 Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot
Encode hashes as bytes, not varint

In a few places, we store hashes as `u64` or `u128` and then apply `derive(Decodable, Encodable)` to the enclosing struct/enum. It is more efficient to encode hashes directly than try to apply some varint encoding. This PR adds two new types `Hash64` and `Hash128` which are produced by `StableHasher` and replace every use of storing a `u64` or `u128` that represents a hash.

Distribution of the byte lengths of leb128 encodings, from `x build --stage 2` with `incremental = true`

Before:
```
(  1) 373418203 (53.7%, 53.7%): 1
(  2) 196240113 (28.2%, 81.9%): 3
(  3) 108157958 (15.6%, 97.5%): 2
(  4)  17213120 ( 2.5%, 99.9%): 4
(  5)    223614 ( 0.0%,100.0%): 9
(  6)    216262 ( 0.0%,100.0%): 10
(  7)     15447 ( 0.0%,100.0%): 5
(  8)      3633 ( 0.0%,100.0%): 19
(  9)      3030 ( 0.0%,100.0%): 8
( 10)      1167 ( 0.0%,100.0%): 18
( 11)      1032 ( 0.0%,100.0%): 7
( 12)      1003 ( 0.0%,100.0%): 6
( 13)        10 ( 0.0%,100.0%): 16
( 14)        10 ( 0.0%,100.0%): 17
( 15)         5 ( 0.0%,100.0%): 12
( 16)         4 ( 0.0%,100.0%): 14
```

After:
```
(  1) 372939136 (53.7%, 53.7%): 1
(  2) 196240140 (28.3%, 82.0%): 3
(  3) 108014969 (15.6%, 97.5%): 2
(  4)  17192375 ( 2.5%,100.0%): 4
(  5)       435 ( 0.0%,100.0%): 5
(  6)        83 ( 0.0%,100.0%): 18
(  7)        79 ( 0.0%,100.0%): 10
(  8)        50 ( 0.0%,100.0%): 9
(  9)         6 ( 0.0%,100.0%): 19
```

The remaining 9 or 10 and 18 or 19 are `u64` and `u128` respectively that have the high bits set. As far as I can tell these are coming primarily from `SwitchTargets`.
2023-04-18 22:27:15 +00:00
Nilstrieb
b5d3d970fa Add rustc_fluent_macro to decouple fluent from rustc_macros
Fluent, with all the icu4x it brings in, takes quite some time to
compile. `fluent_messages!` is only needed in further downstream rustc
crates, but is blocking more upstream crates like `rustc_index`. By
splitting it out, we allow `rustc_macros` to be compiled earlier, which
speeds up `x check compiler` by about 5 seconds (and even more after the
needless dependency on `serde_json` is removed from
`rustc_data_structures`).
2023-04-18 18:56:22 +00:00
Ben Kimock
0445fbdd83 Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
Josh Soref
e09d0d2a29 Spelling - compiler
* account
* achieved
* advising
* always
* ambiguous
* analysis
* annotations
* appropriate
* build
* candidates
* cascading
* category
* character
* clarification
* compound
* conceptually
* constituent
* consts
* convenience
* corresponds
* debruijn
* debug
* debugable
* debuggable
* deterministic
* discriminant
* display
* documentation
* doesn't
* ellipsis
* erroneous
* evaluability
* evaluate
* evaluation
* explicitly
* fallible
* fulfill
* getting
* has
* highlighting
* illustrative
* imported
* incompatible
* infringing
* initialized
* into
* intrinsic
* introduced
* javascript
* liveness
* metadata
* monomorphization
* nonexistent
* nontrivial
* obligation
* obligations
* offset
* opaque
* opportunities
* opt-in
* outlive
* overlapping
* paragraph
* parentheses
* poisson
* precisely
* predecessors
* predicates
* preexisting
* propagated
* really
* reentrant
* referent
* responsibility
* rustonomicon
* shortcircuit
* simplifiable
* simplifications
* specify
* stabilized
* structurally
* suggestibility
* translatable
* transmuting
* two
* unclosed
* uninhabited
* visibility
* volatile
* workaround

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17 16:09:18 -04:00
Matthias Krüger
0790996a07
Rollup merge of #110394 - scottmcm:less-idx-new, r=WaffleLapkin
Various minor Idx-related tweaks

Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify.

cc https://github.com/rust-lang/compiler-team/issues/606
r? `@WaffleLapkin`
2023-04-17 18:13:35 +02:00
Ben Kimock
84facac97a Remove some unnecessary hash truncations 2023-04-16 20:05:02 -04:00
Scott McMurray
c98895d9f2 Various minor Idx-related tweaks
Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify.
2023-04-16 02:42:50 -07:00
bors
661b33f524 Auto merge of #109935 - michaelwoerister:fix-feed-in-eval-always, r=cjgillot
incr.comp.: Make sure dependencies are recorded when feeding queries during eval-always queries.

This PR makes sure we don't drop dependency edges when feeding queries during an eval-always query.

Background: During eval-always queries, no dependencies are recorded because the system knows to unconditionally re-evaluate them regardless of any actual dependencies. This works fine for these queries themselves but leads to a problem when feeding other queries: When queries are fed, we set up their dependency edges by copying the current set of dependencies of the feeding query. But because this set is empty for eval-always queries, we record no edges at all -- which has the effect that the fed query instances always look "green" to the system, although they should always be "red".

The fix is to explicitly add a dependency on the artificial "always red" dep-node when feeding during eval-always queries.

Fixes https://github.com/rust-lang/rust/issues/108481
Maybe also fixes issue https://github.com/rust-lang/rust/issues/88488.

cc `@jyn514`

r? `@cjgillot` or `@oli-obk`
2023-04-12 11:16:35 +00:00
Nilstrieb
81c320ea77 Fix some clippy::complexity 2023-04-09 23:22:14 +02:00
John Kåre Alsaker
6d99dd9189 Address comments 2023-04-06 08:25:53 +02:00
John Kåre Alsaker
36b4199a8e Don't rely on Debug impl for Erased 2023-04-06 08:25:53 +02:00
John Kåre Alsaker
785459d630 Erase query cache values 2023-04-06 08:25:52 +02:00
Michael Woerister
6117c06306 incr.comp.: Make sure dependencies are recorded when feeding queries during eval-always queries. 2023-04-04 14:38:46 +02:00
Oli Scherer
aad33198ff Remove a fishy Clone impl 2023-04-04 09:01:44 +00:00
Nicholas Nethercote
08dec8969f Remove an out-of-date comment on QueryCache::lookup. 2023-03-30 21:14:43 +11:00
nils
c31f75209f
Rollup merge of #108480 - Zoxc:rayon-tlv, r=cuviper
Use Rayon's TLV directly

This accesses Rayon's `TLV` thread local directly avoiding wrapper functions. This makes rustc work with https://github.com/rust-lang/rustc-rayon/pull/10.

r? `@cuviper`
2023-03-28 12:51:12 +02:00
Michael Goulet
f738b44c6d no shadow plz 2023-03-27 20:47:15 +00:00
Matthias Krüger
32aa4c03d9
Rollup merge of #109587 - cjgillot:no-hashmap-fingerprint, r=Nilstrieb
Use an IndexVec to debug fingerprints.

Uncontroversial part of https://github.com/rust-lang/rust/pull/109050
2023-03-27 08:46:52 +02:00
bors
b72e896268 Auto merge of #109100 - Zoxc:merge-query-try, r=cjgillot
Refactor `try_execute_query`

This merges `JobOwner::try_start` into `try_execute_query`, removing `TryGetJob` in the processes. 3 new functions are extracted from `try_execute_query`: `execute_job`, `cycle_error` and `wait_for_query`. This makes the control flow a bit clearer and improves performance.

Based on https://github.com/rust-lang/rust/pull/109046.

<table><tr><td rowspan="2">Benchmark</td><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></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.7134s</td><td align="right">1.7061s</td><td align="right"> -0.43%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2519s</td><td align="right">0.2510s</td><td align="right"> -0.35%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9517s</td><td align="right">0.9481s</td><td align="right"> -0.38%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.5389s</td><td align="right">1.5338s</td><td align="right"> -0.33%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">5.9488s</td><td align="right">5.9258s</td><td align="right"> -0.39%</td></tr><tr><td>Total</td><td align="right">10.4048s</td><td align="right">10.3647s</td><td align="right"> -0.38%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9962s</td><td align="right"> -0.38%</td></tr></table>

r? `@cjgillot`
2023-03-25 12:04:46 +00:00
Camille GILLOT
5e49f099a9 Use an IndexVec to debug fingerprints. 2023-03-25 09:22:40 +00:00
John Kåre Alsaker
820e3a8d6a Pass tcx directly 2023-03-25 03:13:05 +01:00
John Kåre Alsaker
afe4c16b29 Split the if to release the lock earlier 2023-03-25 03:12:41 +01:00
John Kåre Alsaker
dfae9c993d Remove DebugArg 2023-03-25 02:59:54 +01:00
John Kåre Alsaker
8f294066b3 Optimize incremental_verify_ich 2023-03-25 02:59:53 +01:00
John Kåre Alsaker
27c44d2e28 Update indexmap and rayon crates 2023-03-25 02:12:13 +01:00
John Kåre Alsaker
ced33ad289 Refactor try_execute_query 2023-03-21 03:29:19 +01:00
bors
822c10feb7 Auto merge of #109046 - Zoxc:split-execute-job, r=cjgillot,michaelwoerister
Split `execute_job` into `execute_job_incr` and `execute_job_non_incr`

`execute_job` was a bit large, so this splits it in 2. Performance was neutral locally, but this may affect bootstrap times.
2023-03-20 23:53:09 +00:00
bors
13b7aa4d7f Auto merge of #108524 - Zoxc:node-backtrace, r=cjgillot
Optimize dep node backtrace and ignore fatal errors

This attempts to optimize https://github.com/rust-lang/rust/pull/91742 while also passing through fatal errors.

r? `@cjgillot`
2023-03-20 11:54:00 +00:00
John Kåre Alsaker
c4bcac628c Add some assertions 2023-03-19 17:39:34 +01:00
John Kåre Alsaker
486a38723b Split execute_job into execute_job_incr and execute_job_non_incr 2023-03-19 17:39:34 +01:00
bors
938afba899 Auto merge of #108845 - Zoxc:par-fix-2, r=cjgillot
Check that a query has not completed and is not executing before starting it

This fixes a race in the query system where we only checked if the query was currently executing, but not if it was already completed, causing queries to re-execute.

r? `@cjgillot`
2023-03-12 17:03:44 +00:00
bors
f41927f309 Auto merge of #108820 - cjgillot:ensure-on-disk, r=oli-obk
Ensure value is on the on-disk cache before returning from `ensure()`.

The current logic for `ensure()` a query just checks that the node is green in the dependency graph.
However, a lot of places use `ensure()` to prevent the query from being called later. This is the case before stealing a query result.

If the query is actually green but the value is not available in the on-disk cache, `ensure` would return, but a subsequent call to the full query would run the code, and attempt to read from a stolen value.

This PR conforms the query system to the usage by checking whether the queried value is loadable from disk before returning.

Sadly, I can't manage to craft a proper test...

Should fix all instances of "attempted to read from stolen value".
2023-03-12 14:00:28 +00:00
John Kåre Alsaker
f48ff4a2cf Use Debug for formatting the dep nodes 2023-03-12 09:55:35 +01:00
John Kåre Alsaker
867de8bbb8 Remove graph parameter from try_force_from_dep_node 2023-03-12 09:55:35 +01:00
John Kåre Alsaker
8dd0f20ee6 Optimize dep node backtrace and ignore fatal errors 2023-03-12 09:55:35 +01:00
bors
501ad021b9 Auto merge of #108682 - est31:simplify_dirs, r=davidtwco
Simplify message paths

This makes it easier to open the messages file. Right now I have to first click on the `locales` dir to open it, and then on the `en-US.ftl` file. `Cargo.toml` and `build.rs` files are also in the top level, and I think there should not be more than one file, so a directory isn't really needed. The [chosen strategy for pontoon adoption](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/pontoon.20and.20next.20steps) is out of tree. Even if this descision is changed in the future, the `messages.ftl` approach is also compatible with non-english translations living in-tree, as long as the non-english translations don't live in the `compiler/rustc_foo/` directories but in different ones. That would also be helpful for grepability purposes.

The commit was the result of automated changes:

```
for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done

for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
```

r? `@davidtwco`
2023-03-12 03:51:21 +00:00
Camille GILLOT
382cc909d5 Make the check for cache opt-in. 2023-03-11 22:41:01 +00:00
Camille GILLOT
1ca103a168 Ensure value is on the on-disk cache before returning. 2023-03-11 22:41:01 +00:00
est31
7e2ecb3cd8 Simplify message paths
This makes it easier to open the messages file while developing on features.

The commit was the result of automatted changes:

for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done

for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-11 22:51:57 +01:00
John Kåre Alsaker
42a0aaa934 Remove dep_node_index_of_opt and dep_node_index_of 2023-03-09 08:00:54 +01:00
John Kåre Alsaker
62e4bcb168 Address comments 2023-03-09 08:00:40 +01:00
John Kåre Alsaker
60ed37c2e1 Move dep graph methods to DepGraphData to avoid branches and unwraps 2023-03-09 06:14:34 +01:00
John Kåre Alsaker
955549955f Check that a query has not completed and is not executing before starting it 2023-03-08 07:33:38 +01:00
bors
e3dfeeaa45 Auto merge of #108167 - Zoxc:query-config-instance-slim, r=cjgillot
Make `rustc_query_system` take `QueryConfig` by instance.

This allows for easy switching between virtual tables and specialized instances for queries. It also has the benefit of less turbofish. `QueryStorage` has also been merged with `QueryCache`.

Split out from https://github.com/rust-lang/rust/pull/107937.

r? `@cjgillot`
2023-03-07 18:55:36 +00:00
John Kåre Alsaker
10b08e3c9c Fix a race in the query system 2023-02-28 07:47:58 +01:00
John Kåre Alsaker
3b26d71e04 Avoid implementing Debug for QueryConfig 2023-02-26 23:35:52 +01:00
John Kåre Alsaker
3fd7c4a17d Make rustc_query_system take QueryConfig by instance. 2023-02-26 23:35:47 +01:00
John Kåre Alsaker
dd73080cc0 Don't inline try_execute_query 2023-02-25 06:11:02 +01:00