about summary refs log tree commit diff
path: root/src/librustc_data_structures/obligation_forest
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-1322/+0
2020-06-30Rewrite a few manual index loops with while-letJosh Stone-6/+4
There were a few instances of this pattern: ```rust while index < vec.len() { let item = &vec[index]; // ... } ``` These can be indexed at once: ```rust while let Some(item) = vec.get(index) { // ... } ``` Particularly in `ObligationForest::process_obligations`, this mitigates a codegen regression found with LLVM 11 (#73526).
2020-06-02Rename the crates in source codeVadim Petrochenkov-1/+1
2020-05-02fix rustdoc warningsTshepang Lekhonkhobe-1/+1
2020-02-24remove redundant clones in librustc_mir_build and librustc_data_structuresMatthias Krüger-2/+2
2020-02-15Rollup merge of #68475 - Aaron1011:fix/forest-caching, r=nikomatsakisYuki Okushi-15/+20
Use a `ParamEnvAnd<Predicate>` for caching in `ObligationForest` Previously, we used a plain `Predicate` to cache results (e.g. successes and failures) in ObligationForest. However, fulfillment depends on the precise `ParamEnv` used, so this is unsound in general. This commit changes the impl of `ForestObligation` for `PendingPredicateObligation` to use `ParamEnvAnd<Predicate>` instead of `Predicate` for the associated type. The associated type and method are renamed from 'predicate' to 'cache_key' to reflect the fact that type is no longer just a predicate.
2020-02-06Remove `RefCell` usage from `ObligationForest`.Nicholas Nethercote-5/+5
It's not needed.
2020-02-01Use BufWriterShotaro Yamada-1/+2
2020-01-22Use a `ParamEnvAnd<Predicate>` for caching in `ObligationForest`Aaron Hill-15/+20
Previously, we used a plain `Predicate` to cache results (e.g. successes and failures) in ObligationForest. However, fulfillment depends on the precise `ParamEnv` used, so this is unsound in general. This commit changes the impl of `ForestObligation` for `PendingPredicateObligation` to use `ParamEnvAnd<Predicate>` instead of `Predicate` for the associated type. The associated type and method are renamed from 'predicate' to 'cache_key' to reflect the fact that type is no longer just a predicate.
2019-12-31Revert parts of #66405.Nicholas Nethercote-111/+80
Because it caused major performance regressions in some cases. That PR had five commits, two of which affected performance, and three of which were refactorings. This change undoes the performance-affecting changes, while keeping the refactorings in place. Fixes #67454.
2019-12-22Format the worldMark Rousskov-243/+274
2019-12-13Avoid re-processing nodes in `find_cycles_from_node`.Nicholas Nethercote-4/+8
2019-12-13Remove an unnecessary local variable.Nicholas Nethercote-2/+1
2019-12-13Remove some `debug!` statements.Nicholas Nethercote-19/+1
Because I am tired of looking at them.
2019-12-13Move functions around.Nicholas Nethercote-59/+59
In particular, it has bugged me for some time that `process_cycles` is currently located before `mark_still_waiting_nodes` despite being called afterwards.
2019-12-13Remove `NodeState::{Waiting,Done}`.Nicholas Nethercote-87/+126
`NodeState` has two states, `Success` and `Done`, that are only used within `ObligationForest` methods. This commit removes them, and renames the existing `Waiting` state as `Success`. We are left with three states: `Pending`, `Success`, and `Error`. `Success` is augmented with a new `WaitingState`, which indicates when (if ever) it was last waiting on one or more `Pending` nodes. This notion of "when" requires adding a "process generation" to `ObligationForest`; it is incremented on each call to `process_obligtions`. This commit is a performance win. - Most of the benefit comes from `mark_as_waiting` (which the commit renames as `mark_still_waiting_nodes`). This function used to do two things: (a) change all `Waiting` nodes to `Success`, and (b) mark all nodes that depend on a pending node as `Waiting`. In practice, many nodes went from `Waiting` to `Success` and then immediately back to `Waiting`. The use of generations lets us skip step (a). - A smaller benefit comes from not having to change nodes to the `Done` state in `process_cycles`.
2019-11-15Make `process_obligations()` greedier.Nicholas Nethercote-10/+33
`process_obligations()` adds new nodes, but it does not process these new nodes until the next time it is called. This commit changes it so that it does process these new nodes within the same call. This change reduces the number of calls to `process_obligations()` required to complete processing, sometimes giving significant speed-ups. The change required some changes to tests. - The output of `cycle-cache-err-60010.rs` is slightly different. - The unit tests required extra cases to handle the earlier processing of the added nodes. I mostly did these in the simplest possible way, by making the added nodes be ignored, thus giving outcomes the same as with the old behaviour. But I changed `success_in_grandchildren()` more extensively so that some obligations are completed earlier than they used to be.
2019-10-01Rollup merge of #64805 - nnethercote:ObligForest-still-more, r=nikomatsakisTyler Mandry-126/+115
Still more `ObligationForest` improvements. Following on from #64627, more readability improvements, but negligible effects on speed. r? @nikomatsakis
2019-09-30Avoid the popping loop at the end of `compress()`.Nicholas Nethercote-34/+40
By collecting the done obligations (when necessary) in the main loop. This makes the code cleaner. The commit also changes the order in which successful obligations are returned -- they are now returned in the registered order, rather than reversed. Because this order doesn't actually matter, being only used by tests, the commit uses `sort()` to make the test agnostic w.r.t. the order.
2019-09-30Remove an out-of-date sentence in a comment.Nicholas Nethercote-3/+2
2019-09-30Rename `nodes_len` and use it in a few more places.Nicholas Nethercote-9/+9
2019-09-30Convert some `match` expressions to `if`s.Nicholas Nethercote-36/+21
These make the code more concise.
2019-09-30Introduce some intermediate variables that aid readability.Nicholas Nethercote-3/+5
2019-09-30Remove unnecessary uses of `ObligationForest::scratch`.Nicholas Nethercote-12/+8
They don't help performance at all, and just complicate things.
2019-09-30Use `filter` and `map` in `to_errors`.Nicholas Nethercote-11/+11
2019-09-30Tweak the control flow in `process_obligations()`.Nicholas Nethercote-4/+4
2019-09-30Inline `mark_as_waiting_from`.Nicholas Nethercote-12/+13
It has a single call site, and the code is easier to read this way.
2019-09-30Rename `node_index` as `index`.Nicholas Nethercote-2/+2
For consistency with other variables in this file.
2019-09-30Remove `NodeState::OnDfsStack`.Nicholas Nethercote-19/+19
It's not necessary; cycles (which are rare) can be detected by looking at the node stack. This change speeds things up slightly, as well as simplifying the code a little.
2019-09-29remove indexed_vec re-export from rustc_data_structurescsmoe-1/+1
2019-09-20Rename a variable.Nicholas Nethercote-2/+2
Because the meaning of this `index` variable is quite different to all the other `index` variables in this file.
2019-09-20Rename `waiting_cache`.Nicholas Nethercote-14/+14
The name `waiting_cache` sounds like it is related to the states `NodeState::Waiting`, but it's not; the cache holds nodes of various states. This commit changes it to `active_state`.
2019-09-20Rename a loop variable.Nicholas Nethercote-7/+7
We normally use `index` for indices to `ObligationForest::nodes`, but this is a `Nodes::dependents` index.
2019-09-20Remove some unnecessary `backtrace` intermediate variables.Nicholas Nethercote-4/+2
2019-09-20Reorder the state handling in `process_cycles()`.Nicholas Nethercote-6/+9
This gives a slight speed-up.
2019-09-17Rename some index variables.Nicholas Nethercote-44/+44
Now that all indices have type `usize`, it makes sense to be more consistent about their naming. This commit removes all uses of `i` in favour of `index`.
2019-09-17Remove `NodeIndex`.Nicholas Nethercote-36/+27
The size of the indices doesn't matter much here, and having a `newtype_index!` index type without also using `IndexVec` requires lots of conversions. So this commit removes `NodeIndex` in favour of uniform use of `usize` as the index type. As well as making the code slightly more concise, it also slightly speeds things up.
2019-09-17Move a `Node`'s parent into the descendents list.Nicholas Nethercote-43/+36
`Node` has an optional parent and a list of other descendents. Most of the time the parent is treated the same as the other descendents -- error-handling is the exception -- and chaining them together for iteration has a non-trivial cost. This commit changes the representation. There is now a single list of descendants, and a boolean flag that indicates if there is a parent (in which case it is first descendent). This representation encodes the same information, in a way that is less idiomatic but cheaper to iterate over for the common case where the parent doesn't need special treatment. As a result, some benchmark workloads are up to 2% faster.
2019-09-16Move `impl Node` just after `struct Node`.Nicholas Nethercote-16/+16
2019-09-16Minor comment tweaks.Nicholas Nethercote-10/+6
2019-09-16Use `retain` for `waiting_cache` in `apply_rewrites()`.Nicholas Nethercote-6/+4
It's more concise, more idiomatic, and measurably faster.
2019-09-16Use iterators in `error_at` and `process_cycle`.Nicholas Nethercote-16/+18
This makes the code a little faster, presumably because bounds checks aren't needed on `nodes` accesses. It requires making `scratch` a `RefCell`, which is not unreasonable.
2019-09-16Add comments about `waiting_cache`.Nicholas Nethercote-2/+14
2019-09-16Fix incorrect comment about contents of a `Node`.Nicholas Nethercote-5/+5
2019-09-16Fix some out-of-date names of things in comments.Nicholas Nethercote-7/+7
2019-09-16Remove out-of-date comments.Nicholas Nethercote-16/+0
These refer to code that no longer exists.
2019-09-16Factor out repeated `self.nodes[i]` expressions.Nicholas Nethercote-15/+14
2019-09-16Redefine `NodeIndex` as a `newtype_index!`.Nicholas Nethercote-41/+34
This commit removes the custom index implementation of `NodeIndex`, which probably predates `newtype_index!`. As well as eliminating code, it improves the debugging experience, because the custom implementation had the property of being incremented by 1 (so it could use `NonZeroU32`), which was incredibly confusing if you didn't expect it. For some reason, I also had to remove an `unsafe` block marker from `from_u32_unchecked()` that the compiler said was now unnecessary.
2019-09-16Name index variables consistently.Nicholas Nethercote-50/+47
Those with type `usize` are now called `i`, those with type `NodeIndex` are called `index`.
2019-09-13Inline `mark_neighbours_as_waiting_from`.Nicholas Nethercote-4/+13
This function is very hot, doesn't get inlined because it's recursive, and the function calls are significant. This commit splits it into inlined and uninlined variants, and uses the inlined variant for the hot call site. This wins several percent on a few benchmarks.