Description
While trying to prepare the codebase I am working on for frequent miri
usage I found a few related test cases that seem to be messing with the runtime of cargo miri test
.
After a quick chat with @oli-obk it was found that when disabling stacked borrows analysis via -Zmiri-disabled-stacked-borrows
the required time to analyse the tests via miri dropped significantly back to what would be expected from a miri
run that is normally approximately slower compared to native execution by a magnitude of 5.
The approximated "benchmarks" are the following:
With stacked borrows analysis enabled:
Iterations | required time |
---|---|
1 | 0.0s |
10 | 0.5s |
100 | 5s |
1000 | 7m50s |
10_000 | N/A |
Note that for exhausting the data structure under test a minimum of 8193 iterations are needed to explain the 10k iterations in this test.
With stacked borrows analysis disabled:
Iterations | required time |
---|---|
1 | 0.0s |
10 | 0.3s |
100 | 2.5s |
1000 | 37s |
10_000 | 4m55s |
The tested algorithm is approximately linear to the iterations with the test but with a very low factor. The actual type of operation mainly performed in this test is bit-fiddling since we are mainly working on a bitvector data structure and on a bit level of detail.
It seems to me that the stacked borrows analysis somehow explodes given this type of code.
The original code of the test in question can be found here:
https://github.com/paritytech/ink/blob/redo-init-and-flush/core/src/storage2/alloc/tests.rs#L63
Test the code via:
cargo miri test -- -- many_alloc_and_free_works
Or test the code with disabled stacked borrows using:
cargo miri test -- -Zmiri-disable-stacked-borrows -- many_alloc_and_free_works
The used miri
version yielded by cargo miri --version
is the following:
miri 0.1.0 (5c823a1 2020-04-15)
I will try to minimize the test case and make another post if I succeed.