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

incr-comp: hash and serialize span end line/column #76256

Merged
merged 3 commits into from
Nov 12, 2020

Conversation

tgnottingham
Copy link
Contributor

@tgnottingham tgnottingham commented Sep 2, 2020

Hash both the length and the end location (line/column) of a span. If we
hash only the length, for example, then two otherwise equal spans with
different end locations will have the same hash. This can cause a
problem during incremental compilation wherein a previous result for a
query that depends on the end location of a span will be incorrectly
reused when the end location of the span it depends on has changed. A
similar analysis applies if some query depends specifically on the
length of the span, but we only hash the end location. So hash both.

Fix #46744, fix #59954, fix #63161, fix #73640, fix #73967, fix #74890, fix #75900


See #74890 for a more in-depth analysis.

I haven't thought about what other problems this root cause could be responsible for. Please let me know if anything springs to mind. I believe the issue has existed since the inception of incremental compilation.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(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 Sep 2, 2020
@petrochenkov
Copy link
Contributor

cc @Aaron1011

@tgnottingham
Copy link
Contributor Author

It's a little unsettling at first that the hash should contain both the length and end line/column, because we can derive one from the other. It seems redundant. But that's only true when we have a source map from which to derive that info. A span in isolation is incomplete without both the length and the end location. That's my intuition, anyway.

But this raises the question of whether both should be serialized. Since we do have a source map when we create the in-memory spans, we don't actually need both pieces of information. Except that having both allows us to check that the information derived from the source map is consistent with what we read from disk. I'm fairly certain it's a bug if not. We probably shouldn't be reusing a span that is inconsistent with what we derive from the source map. So I've serialized both the end location and length in this PR, but I'm interested to hear what others think about the issue.

@Mark-Simulacrum
Copy link
Member

@bors try @rust-timer queue

Let's get some sense of how much of a performance hit it is to hash both -- if it's not, then I'm inclined to say we should :)

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Sep 2, 2020

⌛ Trying commit d5b6701ccc8217f75d78da34279264f687fc3cdd with merge a58d6a897ef3f0383e1fcc53cb87c6a2c8c64145...

@tgnottingham
Copy link
Contributor Author

@Mark-Simulacrum, I force pushed an update to the commit message. :) Does the perf run need to be requeued?

@Mark-Simulacrum
Copy link
Member

Sort of. @rust-timer build a58d6a897ef3f0383e1fcc53cb87c6a2c8c64145

The try build completed, but bors currently loses track and doesn't print the "Try build finished" message if you force push.

@rust-timer
Copy link
Collaborator

Queued a58d6a897ef3f0383e1fcc53cb87c6a2c8c64145 with parent 95815c9, future comparison URL.

@jyn514 jyn514 added A-incr-comp Area: Incremental compilation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 2, 2020
@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (a58d6a897ef3f0383e1fcc53cb87c6a2c8c64145): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never

@tgnottingham
Copy link
Contributor Author

Okay, looks like there are some optimization opportunities here, which is great, because that's an area I'd like to work on. :) Looking into some small, local optimizations to start, just to see if we can get this PR performance-neutral.

@crlf0710
Copy link
Member

@tgnottingham Ping from triage, what's the status of this?

@tgnottingham
Copy link
Contributor Author

@crlf0710 I have a couple of performance improvements in the works. I can probably get them out within the week.

@tgnottingham
Copy link
Contributor Author

tgnottingham commented Sep 21, 2020

I made some changes that should help with the performance hit of the additional line/column lookup, and some minor changes to hashing. The last commit, which added a span_data_to_lines_and_cols function, was the most impactful based on my local tests. It's a modest improvement.

I'm making some larger changes on the hashing side, but they're significant enough that they should go into a separate PR. Hopefully that will come later this week.

@tgnottingham
Copy link
Contributor Author

Hope to have the hash performance improvements out tomorrow or the next day.

@tgnottingham
Copy link
Contributor Author

By the way, the hashing performance improvements are up for review in #77476.

@bors
Copy link
Contributor

bors commented Oct 9, 2020

☔ The latest upstream changes (presumably #77687) made this pull request unmergeable. Please resolve the merge conflicts.

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@nikomatsakis nikomatsakis added the S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. label Oct 16, 2020
@nikomatsakis
Copy link
Contributor

I've marked this S-blocked, from reading the PR thread it's my impression that this PR is blocked on some performance improvements. @tgnottingham is that correct?

@tgnottingham
Copy link
Contributor Author

@nikomatsakis, yes.

@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 Nov 7, 2020
@bors
Copy link
Contributor

bors commented Nov 8, 2020

⌛ Testing commit b71e627 with merge 846543277ca38eb23967c561ec9e1762a5cd2f41...

@bors
Copy link
Contributor

bors commented Nov 8, 2020

💔 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 Nov 8, 2020
@kennytm
Copy link
Member

kennytm commented Nov 8, 2020

@bors r-

the new test failed on arm-none-eabi-gcc due to linker flag, looks legit

https://github.com/rust-lang-ci/rust/runs/1368962233

failures:

---- [run-make] run-make/incr-prev-body-beyond-eof stdout ----

error: make failed
status: exit code: 2
command: "make"
stdout:
------------------------------------------
mkdir /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/src
mkdir /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/incr
cp a.rs /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/src/main.rs
LD_LIBRARY_PATH="/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/lib" '/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc' --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof -L /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof  -Clinker='arm-none-eabi-gcc' -C incremental=/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/incr /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/src/main.rs
Makefile:11: recipe for target 'all' failed

------------------------------------------
stderr:
------------------------------------------
error: linking with `arm-none-eabi-gcc` failed: exit code: 1
  |
  = note: "arm-none-eabi-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.24tiyo9f8xdudm29.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.2vuk8g9ve0w04u8b.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.3e2qsm1x7ht4xi2a.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.432o4h71aelwht4j.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.5aumkhj7rs1kp4mu.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.8urjmv6unxzieb8.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.j5nriyc7t40nfd8.rcgu.o" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.4s37gsrti678ik8u.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-cd8d1606f661f6b0.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-448643d99e633b5d.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-c7c3d631a525883a.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-d7659a11bb201e01.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-3582800a023674d1.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-56ae8ed396eb3f30.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-b13a322082c79e4f.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-1d4694108f8cb543.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-79eaa6e630880f50.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-0df1a4ec96f80cf7.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-bba9b0f0f4d77257.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-f848f9c987265235.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-0d5ea4f2d39b8e27.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-c22053fa5fc00a3b.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-c52e5d6301e1bd59.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-2675a9a46b5cec89.rlib" "-Wl,--end-group" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-6e3d052afeb9f711.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
  = note: arm-none-eabi-gcc: error: unrecognized command line option '-m64'
          

error: aborting due to previous error

make: *** [all] Error 1

@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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2020
@tgnottingham
Copy link
Contributor Author

@jonas-schievink, we're getting multiple linker errors from a new run-make test I added. I saw that you were responsible for this line in another run-make file: # ignore-32bit wrong/no cross compiler and sometimes we pass wrong gcc args (-m64), which looks related to one of the errors we're seeing (unrecognized command line option '-m64').

Do you happen to know what I need to change in my run-make test to make it pass CI? I didn't think I was doing anything novel.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 12, 2020

📌 Commit dac57e6 has been approved by nikomatsakis

@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 Nov 12, 2020
@bors
Copy link
Contributor

bors commented Nov 12, 2020

⌛ Testing commit dac57e6 with merge 9722952...

@bors
Copy link
Contributor

bors commented Nov 12, 2020

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing 9722952 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 12, 2020
@bors bors merged commit 9722952 into rust-lang:master Nov 12, 2020
@rustbot rustbot added this to the 1.49.0 milestone Nov 12, 2020
@tgnottingham tgnottingham deleted the issue-74890 branch January 20, 2021 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation 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