Uh oh!
There was an error while loading. Please reload this page.
Add a "cheap" mode for compute_missing_ctors. - #55167
Conversation
nnethercote
commented
Oct 18, 2018
Some local benchmarking results: |
varkor
commented
Oct 18, 2018
This is a nice performance win, but I'm hesitant about just duplicating the logic. What do you think about changing the return type of enumMissingCtors<'tcx>{Empty,Nonempty,NonemptyWithCtors(Vec<Constructor<'tcx>>),}and then passing an extra parameter to |
nnethercote
commented
Oct 18, 2018
Ok, I can do that tomorrow. |
c75a8a0 to
6ab1941Compareis_missing_ctors_empty.compute_missing_ctors.nnethercote
commented
Oct 19, 2018
@varkor: I've updated the code as requested. |
There was a problem hiding this comment.
I feel naming the variants of the function in terms of cost, rather than behaviour, is unhelpful — you can't guess what difference in behaviour might result from providing Cheap rather than Expensive (even if that is the motivation for the change). I'd rather stick with the comment about performance above compute_missing_ctors and give the variants more descriptive names.
varkor
commented
Oct 19, 2018
r=me after the comment about naming. Thanks for investigating this! |
nnethercote
commented
Oct 19, 2018
What names do you suggest instead of |
varkor
commented
Oct 22, 2018
(Sorry, GitHub's been preventing me from commenting.) Perhaps something like the following for the input, with #55167 (comment) as the output. /// A request for missing constructor data in terms of either:/// (a) Simply whether there are any missing constructors./// (b) Exactly which constructors are missing./// This is to improve performance in cases where the full constructor information is unnecessary.enumMissingCtorsInfo{/// Corresponds to `MissingCtors::Empty` and `MissingCtors::Nonempty`.Emptiness,/// Corresponds to `MissingCtors::NonemptyWithCtors`.Ctors,} |
nnethercote
commented
Oct 22, 2018
Ok, but I'll change |
`compute_missing_ctors` is called a lot. It produces a vector, which can be reasonably large (e.g. 100+ elements), but the vector is almost always only checked for emptiness. This commit changes `compute_missing_ctors` so it can be called in a cheap way that just indicates if the vector would be empty. If necessary, the function can subsequently be called in an expensive way to compute the full vector. This change reduces instruction counts for several benchmarks up to 2%.
6ab1941 to
b5336c0Comparennethercote
commented
Oct 22, 2018
Updated as requested. |
varkor
commented
Oct 22, 2018
Thanks for looking into this! @bors r+ |
bors
commented
Oct 22, 2018
📌 Commit b5336c0 has been approved by |
… r=varkor Add a "cheap" mode for `compute_missing_ctors`. `compute_missing_ctors` produces a vector. It is called a lot, but the vector is almost always only checked for emptiness. This commit introduces a specialized variant of `compute_missing_ctors` (called `is_missing_ctors_empty`) that determines if the resulting set would be empty, and changes the callsite so that `compute_missing_ctors` is only called in the rare cases where it is needed. The code duplication is unfortunate but I can't see a better way to do it. This change reduces instruction counts for several benchmarks up to 2%. r? @varkor
… r=varkor Add a "cheap" mode for `compute_missing_ctors`. `compute_missing_ctors` produces a vector. It is called a lot, but the vector is almost always only checked for emptiness. This commit introduces a specialized variant of `compute_missing_ctors` (called `is_missing_ctors_empty`) that determines if the resulting set would be empty, and changes the callsite so that `compute_missing_ctors` is only called in the rare cases where it is needed. The code duplication is unfortunate but I can't see a better way to do it. This change reduces instruction counts for several benchmarks up to 2%. r? @varkor
… r=varkor Add a "cheap" mode for `compute_missing_ctors`. `compute_missing_ctors` produces a vector. It is called a lot, but the vector is almost always only checked for emptiness. This commit introduces a specialized variant of `compute_missing_ctors` (called `is_missing_ctors_empty`) that determines if the resulting set would be empty, and changes the callsite so that `compute_missing_ctors` is only called in the rare cases where it is needed. The code duplication is unfortunate but I can't see a better way to do it. This change reduces instruction counts for several benchmarks up to 2%. r? @varkor
… r=varkor Add a "cheap" mode for `compute_missing_ctors`. `compute_missing_ctors` produces a vector. It is called a lot, but the vector is almost always only checked for emptiness. This commit introduces a specialized variant of `compute_missing_ctors` (called `is_missing_ctors_empty`) that determines if the resulting set would be empty, and changes the callsite so that `compute_missing_ctors` is only called in the rare cases where it is needed. The code duplication is unfortunate but I can't see a better way to do it. This change reduces instruction counts for several benchmarks up to 2%. r? @varkor
Rollup of 21 pull requests Successful merges: - #54816 (Don't try to promote already promoted out temporaries) - #54824 (Cleanup rustdoc tests with `@!has` and `@!matches`) - #54921 (Add line numbers option to rustdoc) - #55167 (Add a "cheap" mode for `compute_missing_ctors`.) - #55258 (Fix Rustdoc ICE when checking blanket impls) - #55264 (Compile the libstd we distribute with -Ccodegen-unit=1) - #55271 (Unimplement ExactSizeIterator for MIR traversing iterators) - #55292 (Macro diagnostics tweaks) - #55298 (Point at macro definition when no rules expect token) - #55301 (List allowed tokens after macro fragments) - #55302 (Extend the impl_stable_hash_for! macro for miri.) - #55325 (Fix link to macros chapter) - #55343 (rustbuild: fix remap-debuginfo when building a release) - #55346 (Shrink `Statement`.) - #55358 (Remove redundant clone (2)) - #55370 (Update mailmap for estebank) - #55375 (Typo fixes in configure_cmake comments) - #55378 (rustbuild: use configured linker to build boostrap) - #55379 (validity: assert that unions are non-empty) - #55383 (Use `SmallVec` for the queue in `coerce_unsized`.) - #55391 (bootstrap: clean up a few clippy findings)
compute_missing_ctorsproduces a vector. It is called a lot, but thevector is almost always only checked for emptiness.
This commit introduces a specialized variant of
compute_missing_ctors(called
is_missing_ctors_empty) that determines if the resulting setwould be empty, and changes the callsite so that
compute_missing_ctorsis only called in the rare cases where it is needed. The code
duplication is unfortunate but I can't see a better way to do it.
This change reduces instruction counts for several benchmarks up to 2%.
r? @varkor