Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc_metadata: Support non-Option nullable values in metadata tables #107166

Merged
merged 1 commit into from
Jan 25, 2023

Conversation

petrochenkov
Copy link
Contributor

This is a convenience feature for cases in which "no value in the table" and "default value in the table" are equivalent.
Tables using Table<DefIndex, ()> are migrated in this PR, some other cases can be migrated later.
This helps DocFlags in #107136 in particular.

@rustbot
Copy link
Collaborator

rustbot commented Jan 21, 2023

r? @oli-obk

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 21, 2023
@petrochenkov
Copy link
Contributor Author

This shouldn't affect performance if inlining is decent, but let's check.
@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 21, 2023
@bors
Copy link
Contributor

bors commented Jan 21, 2023

⌛ Trying commit cb57ec1aea24c81c20fd61e2aac5e2840d34bf77 with merge 377b124a5ae81e42de3f95818dea84ff400107f1...

@bors
Copy link
Contributor

bors commented Jan 21, 2023

☀️ Try build successful - checks-actions
Build commit: 377b124a5ae81e42de3f95818dea84ff400107f1 (377b124a5ae81e42de3f95818dea84ff400107f1)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (377b124a5ae81e42de3f95818dea84ff400107f1): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 2
Improvements ✅
(secondary)
-0.7% [-0.8%, -0.3%] 7
All ❌✅ (primary) -0.3% [-0.3%, -0.3%] 2

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.7% [-4.9%, -2.5%] 2
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
6.1% [5.1%, 6.9%] 3
Regressions ❌
(secondary)
2.4% [2.4%, 2.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 6.1% [5.1%, 6.9%] 3

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 22, 2023
@petrochenkov
Copy link
Contributor Author

@bors rollup=maybe

is_intrinsic: Table<DefIndex, bool>,
is_macro_rules: Table<DefIndex, bool>,
is_type_alias_impl_trait: Table<DefIndex, bool>,
may_have_doc_links: Table<DefIndex, bool>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can explicit_item_bounds and inferred_outlives_of be migrated to this setup?

Copy link
Contributor Author

@petrochenkov petrochenkov Jan 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's a bit more involved because you need to make the table.get(...).decode(...).process_decoded(...) chain fast for LazyArrays without using None to skip all the extra work.
I'll try, but probably closer to the next weekend.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me on this PR if you want to do that in a separate PR

}

impl<I: Idx, const N: usize, T: FixedSizeEncoding<ByteArray = [u8; N]>> TableBuilder<I, T> {
pub(crate) fn set_nullable(&mut self, i: I, value: T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have a convenience wrapper around set_nullable for TableBuilder<I, bool> to just set it to true. Invoking set_nullable(val, false) is never done and likely a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Together with #107166 (comment) I'll try to move the true/false conditions to inside the set methods.
So it will look approximately like this

fn set(value) {
    if value.is_default() {
        return;
    }
    // possibly resize the buffer and set the non-default value
}

and false/None/etc arguments will be accepted but result in doing nothing.

The "reset to None" semantic is never currently used for metadata tables, but if it will be needed it will require a separate method like fn clear in this case.

@petrochenkov
Copy link
Contributor Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Jan 23, 2023

📌 Commit cb57ec1aea24c81c20fd61e2aac5e2840d34bf77 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 23, 2023
@bors

This comment was marked as resolved.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 23, 2023
This is a convenience feature for cases in which "no value in the table" and "default value in the table" are equivalent.
Tables using `Table<DefIndex, ()>` are migrated in this PR, some other cases can be migrated later.

This helps `DocFlags` in rust-lang#107136 in particular.
@petrochenkov
Copy link
Contributor Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Jan 23, 2023

📌 Commit 91fdbd7 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 23, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jan 24, 2023
rustc_metadata: Support non-`Option` nullable values in metadata tables

This is a convenience feature for cases in which "no value in the table" and "default value in the table" are equivalent.
Tables using `Table<DefIndex, ()>` are migrated in this PR, some other cases can be migrated later.
This helps `DocFlags` in rust-lang#107136 in particular.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 25, 2023
Rollup of 9 pull requests

Successful merges:

 - rust-lang#105552 (Add help message about function pointers)
 - rust-lang#106583 (Suggest coercion of `Result` using `?`)
 - rust-lang#106767 (Allow setting CFG_DISABLE_UNSTABLE_FEATURES to 0)
 - rust-lang#106823 (Allow fmt::Arguments::as_str() to return more Some(_).)
 - rust-lang#107166 (rustc_metadata: Support non-`Option` nullable values in metadata tables)
 - rust-lang#107213 (Add suggestion to remove if in let..else block)
 - rust-lang#107223 (`sub_ptr()` is equivalent to `usize::try_from().unwrap_unchecked()`, not `usize::from().unwrap_unchecked()`)
 - rust-lang#107227 (`new_outside_solver` ->  `evaluate_root_goal`)
 - rust-lang#107232 (rustdoc: simplify settings popover DOM, CSS, JS)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a788ce2 into rust-lang:master Jan 25, 2023
@rustbot rustbot added this to the 1.69.0 milestone Jan 25, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 7, 2023
rustc_metadata: Encode/decode some `LazyArrays` without an `Option`

and a couple of related changes, see individual commits.

Addresses comments in rust-lang#107166 (comment) and rust-lang#107166 (comment), cc `@cjgillot` `@oli-obk.`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants