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

Use a separate interner type for UniqueTypeId #87867

Merged
merged 1 commit into from
Sep 15, 2021

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Aug 8, 2021

Using symbol::Interner makes it very easy to mixup UniqueTypeId symbols
with the global interner. In fact the Debug implementation of
UniqueTypeId did exactly this.

Using a separate interner type also avoids prefilling the interner with
unused symbols and allow for optimizing the symbol interner for parallel
access without negatively affecting the single threaded module codegen.

@rust-highfive
Copy link
Collaborator

r? @wesleywiser

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 8, 2021
@bjorn3
Copy link
Member Author

bjorn3 commented Aug 8, 2021

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

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

bors commented Aug 8, 2021

⌛ Trying commit a35943dfb8749ea72b73d4b77eb0a039e0b69424 with merge 476bbb073a2cb29fca275fdb4960f71270623a3c...

@bors
Copy link
Contributor

bors commented Aug 8, 2021

☀️ Try build successful - checks-actions
Build commit: 476bbb073a2cb29fca275fdb4960f71270623a3c (476bbb073a2cb29fca275fdb4960f71270623a3c)

@rust-timer
Copy link
Collaborator

Queued 476bbb073a2cb29fca275fdb4960f71270623a3c with parent e8c25f2, future comparison URL.

use rustc_arena::DroplessArena;

#[derive(Copy, Hash, Eq, PartialEq, Clone)]
pub(super) struct UniqueTypeId(u32);
Copy link
Member Author

Choose a reason for hiding this comment

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

This type used to be a wrapper around Symbol with a Debug derive that used the global interner, but the Symbol would actually be interned by a separate interner.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (476bbb073a2cb29fca275fdb4960f71270623a3c): comparison url.

Summary: This benchmark run did not return any significant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up.

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

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 8, 2021
@bjorn3
Copy link
Member Author

bjorn3 commented Aug 8, 2021

Up to 0.3% regressions all of which are for opt builds, which shouldn't have debuginfo generation and thus not run the changed code. Maybe it affects cgu partitioning or inlining?

@inquisitivecrystal inquisitivecrystal added T-libs Relevant to the library team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 24, 2021
@JohnCSimon
Copy link
Member

Ping from triage:
@bjorn3 - can you please address the merge conflicts?

Using symbol::Interner makes it very easy to mixup UniqueTypeId symbols
with the global interner. In fact the Debug implementation of
UniqueTypeId did exactly this.

Using a separate interner type also avoids prefilling the interner with
unused symbols and allow for optimizing the symbol interner for parallel
access without negatively affecting the single threaded module codegen.
@bjorn3 bjorn3 force-pushed the unique_type_id_interner branch from a35943d to 8c7840e Compare September 13, 2021 12:42
@bjorn3
Copy link
Member Author

bjorn3 commented Sep 13, 2021

Rebased

@wesleywiser
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 13, 2021

📌 Commit 8c7840e has been approved by wesleywiser

@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 Sep 13, 2021
@bors
Copy link
Contributor

bors commented Sep 14, 2021

⌛ Testing commit 8c7840e with merge dd52fb9058f3ddbb2e2f28460169860e7f387176...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-msvc-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[TIMING] Rustc { target: TargetSelection { triple: "x86_64-pc-windows-msvc", file: None }, compiler: Compiler { stage: 1, host: TargetSelection { triple: "x86_64-pc-windows-msvc", file: None } } } -- 0.938
Assembling stage2 compiler (x86_64-pc-windows-msvc)
[TIMING] Sysroot { compiler: Compiler { stage: 2, host: TargetSelection { triple: "x86_64-pc-windows-msvc", file: None } } } -- 0.000
[TIMING] Libdir { compiler: Compiler { stage: 2, host: TargetSelection { triple: "x86_64-pc-windows-msvc", file: None } }, target: TargetSelection { triple: "x86_64-pc-windows-msvc", file: None } } -- 0.000
thread 'main' panicked at 'failed to copy `D:\a\rust\rust\build\x86_64-pc-windows-msvc\stage1-rustc\x86_64-pc-windows-msvc\release\rustc-main.exe` to `D:\a\rust\rust\build\x86_64-pc-windows-msvc\stage2\bin\rustc.exe`: The process cannot access the file because it is being used by another process. (os error 32)', src\bootstrap\lib.rs:1335:17
Build completed unsuccessfully in 0:00:04

@bors
Copy link
Contributor

bors commented Sep 14, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 14, 2021
@ehuss
Copy link
Contributor

ehuss commented Sep 14, 2021

@bors retry

#88924

@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 Sep 14, 2021
@bors
Copy link
Contributor

bors commented Sep 14, 2021

⌛ Testing commit 8c7840e with merge 9e8b44cb5b43b95c220986e4fbab1fa8fc6c7930...

@rust-log-analyzer
Copy link
Collaborator

The job dist-i686-msvc failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling core v0.0.0 (D:\a\rust\rust\library\core)
   Compiling libc v0.2.99
   Compiling memchr v2.4.1
   Compiling std v0.0.0 (D:\a\rust\rust\library\std)
error: linking with `link.exe` failed: exit code: 1104
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x86\\link.exe" "/NOLOGO" "/LARGEADDRESSAWARE" "/SAFESEH" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.0.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.1.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.10.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.11.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.12.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.13.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.14.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.15.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.2.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.3.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.4.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.5.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.6.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.7.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.8.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.build_script_build.ffed8922-cgu.9.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.1ufx9vfr6oc6ja33.rcgu.o" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\deps" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libstd-81cb19e6a508a382.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libpanic_unwind-d68169d5fd63206c.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libstd_detect-f7aff418b211f3b4.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_demangle-bde83a8e075cbb6d.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libhashbrown-d018f29c6b54b3e3.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-57a11699c9cdcc43.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libunwind-8ea0c0e26bfbf063.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcfg_if-423bcb240d49abd0.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\liblibc-2e26fae3a666b111.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\liballoc-dd6f76dfeed99195.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_std_workspace_core-31972101b01c6747.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcore-4d870864fbc17473.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcompiler_builtins-771055d60d4c83bb.rlib" "kernel32.lib" "ws2_32.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "libcmt.lib" "/NXCOMPAT" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "/OUT:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2-std\\release\\build\\libc-8ef7e2152eb68624\\build_script_build-8ef7e2152eb68624.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage0\\lib\\rustlib\\etc\\libstd.natvis"
  = note: LINK : fatal error LNK1104: cannot open file 'D:\a\rust\rust\build\i686-pc-windows-msvc\stage2-std\release\build\libc-8ef7e2152eb68624\build_script_build-8ef7e2152eb68624.exe'
          

[RUSTC-TIMING] build_script_build test:false 0.315
error: could not compile `libc` due to previous error

@bors
Copy link
Contributor

bors commented Sep 14, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 14, 2021
@CryZe
Copy link
Contributor

CryZe commented Sep 15, 2021

The Windows Github Action Runners are broken atm: #88924

@ehuss
Copy link
Contributor

ehuss commented Sep 15, 2021

@bors retry

#88924

@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 Sep 15, 2021
@bors
Copy link
Contributor

bors commented Sep 15, 2021

⌛ Testing commit 8c7840e with merge 2c7bc5e...

@bors
Copy link
Contributor

bors commented Sep 15, 2021

☀️ Test successful - checks-actions
Approved by: wesleywiser
Pushing 2c7bc5e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 15, 2021
@bors bors merged commit 2c7bc5e into rust-lang:master Sep 15, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 15, 2021
@bjorn3 bjorn3 deleted the unique_type_id_interner branch September 15, 2021 16:14
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2c7bc5e): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 18, 2021
…ark-Simulacrum

Move the Lock into symbol::Interner

This makes it easier to make the symbol interner (near) lock free in case of concurrent accesses in the future.

With rust-lang#87867 landed this shouldn't affect performance anymore.
@JohnTitor
Copy link
Member

JohnTitor commented Oct 13, 2021

@bjorn3 This makes rust-semverver confused (e.g. on https://github.com/rust-lang/rust-semverver/blob/b49417044bd4e9833e218b5f370388d9fe191661/src/changes.rs#L1463-L1464). Since some parts (Interner itself, and Symbol's field and assoc fn) are private, it's hard to have our own Intener I guess, is there any workaround?

@bjorn3
Copy link
Member Author

bjorn3 commented Oct 13, 2021

Nornally I think having your own interner is the best solution. The previous setup made it too easy to mixup between different interners, which will result in incorrect results (for example symbol.as_atr() will use the global interner and not your own interner) and can potentially be a safety issue.

In this specific case I think only test is interned though, so you can use sym::test instead, which is also faster as it is already a symbol and doesn't need a hashmap lookup.

@JohnTitor
Copy link
Member

Got it, thanks for the pointer!

JohnTitor added a commit to JohnTitor/rust-semverver that referenced this pull request Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.