Repository navigation
goto-symex: record shared writes only once a thread is spawned - #9635
Draft
tautschnig wants to merge 1 commit into
Draft
tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
Symbolic execution records a shared-write event for every write to an object that is not thread-local, heap objects and globals included, also in programs that never spawn a thread. The events are only used by the memory model, which runs only if the equation has threads (postprocess_equation, has_threads), and by traces only then; in a single-threaded program they are steps that cost time and memory and are never read. A Lua program writes the fields of every new table, so that 28 % of its steps were such events (luacheck's stages/detect_empty_blocks.lua: 147,846 of 524,168). symex_target_equationt::shared_write now keeps the events recorded before the first spawn aside (their guard, object, atomic section, source and the number of steps before them), and spawn() inserts them where they would have been before it adds the spawn step, so that the equation of a program that spawns a thread is unchanged: the sorted --program-only output of each of the 68 tests of regression/cbmc-concurrency is the same as before (apart from the run times that one of them prints). Without a spawn they are dropped. (Simply not recording them before the first spawn would be unsound for the spawned threads, which read the values written before it: the new regression test cbmc-concurrency/shared-writes-before-spawn fails then.) The effect is mostly on steps and memory. A Lua front end built on CBMC (luacheck's stages/parse.lua, runs alternated on a quiet host): 1,228,346 to 915,985 steps, symbolic execution 85.4 to 84.1 s (mean of two runs), peak memory 3.17 to 3.06 GB. scripts/profile_cbmc.py --auto-large --runs 3: steps unchanged or fewer (array_ops 16,448 to 13,993, matrix 4,148 to 3,435, string_ops 1,950 to 1,737, unions 382 to 311, structs 312 to 207); pre-solver time -14.7 % to +4.8 % with develop run first and +0.3 % to +4.7 % with it second, on a host shared with other jobs, i.e. within the noise of the run order. Tests: unit test in unit/goto-symex/ssa_equation.cpp (the deferred events and their positions); regression/cbmc-concurrency/ shared-writes-before-spawn (values written before the spawn, on both branches and twice, read by the thread; a write after the spawn; and a single-threaded program whose --program-only output has no shared writes). single-thread.desc fails on develop. regression/cbmc (also with --paths lifo), cbmc-concurrency, cbmc-cpp, cbmc-cover, cbmc-shadow-memory and cbmc-primitives pass with --validate-goto-model --validate-ssa-equation; cbmc-library's mmap/test, mmap/test_02 and munmap/test fail with these options, as on develop. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
3 of 4 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9635 +/- ##
========================================
Coverage 81.34% 81.34%
========================================
Files 1727 1727
Lines 191715 191779 +64
Branches 73 73
========================================
+ Hits 155950 156009 +59
- Misses 35765 35770 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symbolic execution records a shared-write event for every write to an object that is not thread-local, heap objects and globals included, also in programs that never spawn a thread. The events are only used by the memory model, which runs only if the equation has threads (postprocess_equation, has_threads), and by traces only then; in a single-threaded program they are steps that cost time and memory and are never read. A Lua program writes the fields of every new table, so that 28 % of its steps were such events (luacheck's stages/detect_empty_blocks.lua: 147,846 of 524,168).
symex_target_equationt::shared_write now keeps the events recorded before the first spawn aside (their guard, object, atomic section, source and the number of steps before them), and spawn() inserts them where they would have been before it adds the spawn step, so that the equation of a program that spawns a thread is unchanged: the sorted --program-only output of each of the 68 tests of
regression/cbmc-concurrency is the same as before (apart from the run times that one of them prints). Without a spawn they are dropped. (Simply not recording them before the first spawn would be unsound for the spawned threads, which read the values written before it: the new regression test cbmc-concurrency/shared-writes-before-spawn fails then.)
The effect is mostly on steps and memory. A Lua front end built on CBMC (luacheck's stages/parse.lua, runs alternated on a quiet host): 1,228,346 to 915,985 steps, symbolic execution 85.4 to 84.1 s (mean of two runs), peak memory 3.17 to 3.06 GB. scripts/profile_cbmc.py --auto-large --runs 3: steps unchanged or fewer (array_ops 16,448 to 13,993, matrix 4,148 to 3,435, string_ops 1,950 to 1,737, unions 382 to 311, structs 312 to 207); pre-solver time -14.7 % to +4.8 % with develop run first and +0.3 % to +4.7 % with it second, on a host shared with other jobs, i.e. within the noise of the run order.
Tests: unit test in unit/goto-symex/ssa_equation.cpp (the deferred events and their positions); regression/cbmc-concurrency/ shared-writes-before-spawn (values written before the spawn, on both branches and twice, read by the thread; a write after the spawn; and a single-threaded program whose --program-only output has no shared writes). single-thread.desc fails on develop. regression/cbmc (also with --paths lifo), cbmc-concurrency, cbmc-cpp, cbmc-cover, cbmc-shadow-memory and cbmc-primitives pass with --validate-goto-model --validate-ssa-equation; cbmc-library's mmap/test, mmap/test_02 and munmap/test fail with these options, as on develop.