Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36121. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
jeanpablojp
left a comment
There was a problem hiding this comment.
Concept ACK
I had a look at the logs. Looks like on macOS the pool was already saturated. Summing the process times and dividing by --par gives 613s there, against 200s for the slowest single target, so there was no tail to cut. On Windows and MSan it's the other way round, and that is where the win comes from.
Almost all of the macOS side comes from one target. utxo_total_supply builds a ChainTestingSetup inside the target body, so a datadir per input, and three shards of 680 take around 240s each against 200s for all 2040 in one process. Same on Windows.
Is it worth gating this on something, or does the win on the other jobs already outweigh it?
| help='How many targets to merge or execute in parallel.', | ||
| ) | ||
| parser.add_argument( | ||
| '--corpus-shards', |
There was a problem hiding this comment.
nit: --help ends up with two defaults, the one in the help string and a (default: None) that ArgumentDefaultsHelpFormatter appends.
There was a problem hiding this comment.
Yeah, saw that too. Not sure how to fix. I guess it is fine to leave as-is.
| if using_libfuzzer: | ||
| if empty_min_time and empty_dir: | ||
| args += [f"-max_total_time={empty_min_time}"] | ||
| with tempfile.TemporaryDirectory(dir=corpus.parent, prefix='.fuzz-shards-') as shard_root: |
There was a problem hiding this comment.
This gets created before we know whether there will be any sharding, so with a read-only parent the run dies in mkdtemp, and --corpus-shards 1 doesn't avoid it. It also survives a SIGTERM, left next to the corpus.
And since the with wraps the collection loop too, the removal only happens after the last job, with everything else idle. 31s on macOS.
There was a problem hiding this comment.
read-only parent should be rare, but I think I fixed this in the latest push by having a temp dir for each job.
SIGTERM will probably still leave them around.
The creation/removal is now interleaved, but I don't expect this to improve the runtime, unless there is over-subscription, but then there could be even more storage thrashing...
| corpus_files = sorted(path for path in corpus_path.iterdir() if path.is_file()) | ||
| empty_dir = not corpus_files | ||
|
|
||
| if corpus_shards > 1 and len(corpus_files) > 1: |
There was a problem hiding this comment.
This hits every target that has a corpus, none has fewer than three inputs. cmpctblock sometimes does the same kind of per-input work through ResetChainmanAndMempool.
The hard links are one per corpus input, so that part doesn't shrink with more workers. On macOS that takes 155s before the first job gets collected.
There was a problem hiding this comment.
Hmm, I guess this is a combination of some OSs not having a tmpfs at all and the GHA VMs having a slow storage. :(
| logging.info(e.stdout) | ||
| if e.stderr: | ||
| logging.info(e.stderr) | ||
| logging.info(f"⚠️ Failure generated from target with exit code {e.returncode}: {result.args}") |
There was a problem hiding this comment.
nit: this path is already gone by the time anyone reads the log, it's inside the shard dir. The file name survives, the path doesn't.
And with the sys.exit(1) in here, the dir disappears under the shards that are still running, so on the standalone builds they die on the read_file Assert instead of on the input that actually broke.
There was a problem hiding this comment.
Hmm, the file disappearing should be fine, because the basename of the file (sha1 hash) should be important/sufficient.
The read_file assertions aren't great. I guess this is fixed by having per-job tmp dirs for the shards.
| if using_libfuzzer: | ||
| done_stat = [l for l in output.splitlines() if "DONE" in l] | ||
| assert len(done_stat) == 1 | ||
| stats.append((target, done_stat[0])) |
There was a problem hiding this comment.
Summary goes from 237 lines to 3754 on your asan run, and cov: becomes per process. coins_view_db reports sixteen values between 12033 and 13709 where master reports 14509, and since it's a union there's no way to put it back together. So you can't compare coverage across a change any more. Could the shards be folded back into one line per target?
There was a problem hiding this comment.
I don't think it is possible to recover the coverage from the shards. I can only see compiling with coverage instrumentation and then using that. This could possibly also help with bitcoin-core/qa-assets#166
To better utilize the given --par option, split each corpus into shards by default. The diff can be reviewed via --ignore-all-space
d000002 to
fa2d43f
Compare
Hmm, if the slowest single target happened to be scheduled toward the end, there would be a tail to cut, no?
Hmm, I guess this means the bottleneck is storage IO and not CPU, so this pull request won't help and may even make it worse due to storage thrashing. In theory, all of the fuzzing should be in a tmpfs (default on modern Linux), but neither macOS nor Windows have that option :(
in theory, the macOS config (and possibly Windows) could disable it, but if this gets too complicated, I may close this pull. |
|
Ok, so tmpfs helped a bit on macos, but still not enough. On Linux, it didn't really make a difference, it seems. |
You're right.
macOS on master runs anywhere from 632 to 976s and this head is 767s, so it is inside what master does on its own. I guess two runs can't really separate that. |
|
Closing for now. Not sure if this is worth it. IIRC I created this after @willcl-ark contemplated how the MSan fuzz CI could be speed up. It would be a bit faster with this pull, but I am not sure if the code review and complexity is worth it |
Currently, the fuzz runner accepts a
--paroption to schedule fuzz runs in parallel. This is fine. However, when only a single target is selected,--parwill not speed up the run. Moreover, when multiple targets are selected, the run-time of the longest target dominates.Fix both issues by splitting the corpus to into
--parequal-sized shards by default. The sharding can be disabled, if needed.Can be tested e.g. by running a single target: