Stream: t-compiler/rust-analyzer

Topic: Scalability, but at what COST?


matklad (Jan 28 2021 at 15:04, on Zulip):

Here's a fun one:

17:58:15|~/projects/rust-analyzer|master✓
λ t env RUN_SLOW_TESTS=1 cargo t -p rust-analyzer --release --test rust-analyzer -q

running 12 tests
............
test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

real 60.08s
user 511.80s
sys  2.23s
rss  1198176k
18:01:33|~/projects/rust-analyzer|master✓
λ t env RUN_SLOW_TESTS=1 cargo t -p rust-analyzer --release --test rust-analyzer -q -- --test-threads 1

running 12 tests
............
test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

real 23.55s
user 26.55s
sys  1.66s
rss  430548k

That is, running tests in multiple threads is 3x longer than using one thread in terms of wall-clock time, and wtf-times costlier in terms of CPU time

matklad (Jan 28 2021 at 15:05, on Zulip):

cc @Edwin Cheng this is what I stumbled into when trying to quickly switch from progress to status

matklad (Jan 28 2021 at 15:06, on Zulip):

Are there any ideas of what might be the issue here? These are separate tests, so there should be zero shared memory...

Jeremy Kolb (Jan 28 2021 at 15:16, on Zulip):

Fascinating. It's a lot less memory too. Is it only with slow tests?

Edwin Cheng (Jan 28 2021 at 15:20, on Zulip):

My theory is our task pool is "multiplying" the number of threads in used. Could you try to run only one test ?

Edwin Cheng (Jan 28 2021 at 15:22, on Zulip):

I mean something like: env RUN_SLOW_TESTS=1 cargo t -p rust-analyzer --release --test rust-analyzer -q -- test_runnables_project --test-threads 1

matklad (Jan 28 2021 at 15:25, on Zulip):

there's no difference for a single test

Edwin Cheng (Jan 28 2021 at 15:30, on Zulip):

I can imagine cargo test have a thread pool which size of n cpu, but our task pool is also the size of n cpu. So the number of actual thread will be used is n*n. And I can imagine the context switch cost is quite large ?

matklad (Jan 28 2021 at 15:33, on Zulip):

ok, it seems this is countme

matklad (Jan 28 2021 at 15:35, on Zulip):

right, "enable by default" logic backfires in tests...

Last update: Jul 26 2021 at 13:00UTC