diff --git a/README.md b/README.md index 363f4aa..ffed653 100644 --- a/README.md +++ b/README.md @@ -257,9 +257,11 @@ cases allow a 2% dead-heat margin so a genuine tie can't flake — but a real loss writes a shame report, fails the suite, and exits non-zero. The words suite grows to 1M and 10M lines; the lines suite carries the monsters: 100M lines raced against coreutils, and 1B lines timed solo -— there is no reference for that one; we are the reference now. When -the run ends, the average speedup of fastwc against each oracle is -printed. +— there is no reference for that one; we are the reference now. The +lines suite also races `-L` at 1M and 10M lines, and ends with a +128-file list (12.8M lines) so the worker pool is under the contract +too, not just in some table in this file. When the run ends, the +average speedup of fastwc against each oracle is printed. ## Development diff --git a/benchmarks/files/lines/bench.sh b/benchmarks/files/lines/bench.sh index 3561154..2c211bc 100755 --- a/benchmarks/files/lines/bench.sh +++ b/benchmarks/files/lines/bench.sh @@ -30,6 +30,12 @@ for oracle in $ORACLES; do exit 1 fi + printf '\n%s\n' '--- longest line ---' + if ! run_cases lines -L 1000000 10000000; then + exit 1 + fi + + printf '\nall %s lines benchmarks passed — fastwc was never slower than %s wc\n' \ "$BENCH_NAME" "$BENCH_NAME" done @@ -45,3 +51,11 @@ fi printf '%s\n' '--- monster: 1B lines, solo ---' run_solo_case 1000000000 -l + +# A file list is where the worker pool lives, and it needs files big +# enough that both sides are counting rather than starting. 128 files of +# about 1.1 MB, 140 MB in total. +printf '%s\n' '--- file list: 128 files, 12.8M lines, vs coreutils ---' +if ! run_multi_case lines 128 12800000 -lwc; then + exit 1 +fi diff --git a/benchmarks/std.sh b/benchmarks/std.sh index 8a1d016..974da98 100755 --- a/benchmarks/std.sh +++ b/benchmarks/std.sh @@ -403,6 +403,48 @@ run_cases() { return $rc } +# run_multi_case — race a list of files. +# A list is where the worker pool lives: one file per worker, rows printed +# in argument order. Correctness is the whole output, not one column, +# because a pool that reorders or drops a row would still total up. +run_multi_case() { + local mode="$1" nfiles="$2" lines="$3" flag="$4" + local label="$mode (${nfiles} files, ${lines} lines)" + local src dir name i d wc_out fast_out wc_us fast_us + local -a files=() + + src=$(createtxt "$lines") || return 1 + dir="$DATA_DIR/multi-${nfiles}-${lines}" + if [[ ! -f "$dir/.ready" ]]; then + rm -rf "$dir" + mkdir -p "$dir" + split -n "$nfiles" -d -a 3 "$src" "$dir/part-" || return 1 + : > "$dir/.ready" + fi + for name in "$dir"/part-*; do + files+=("$name") + done + + # The oracles pad their columns differently, so the check is the row + # count (nothing dropped or reordered) and the total row's numbers. + wc_out=$("${WC_CMD[@]}" "$flag" "${files[@]}" 2>/dev/null | + awk 'END { print NR ":" $1, $2, $3 }') + fast_out=$("$FASTWC" "$flag" "${files[@]}" 2>/dev/null | + awk 'END { print NR ":" $1, $2, $3 }') + + wc_us='' + fast_us='' + for ((i = 0; i < BENCH_REPS; i++)); do + d=$(timeit "${WC_CMD[@]}" "$flag" "${files[@]}") + [[ -z "$wc_us" || "$d" -lt "$wc_us" ]] && wc_us="$d" + + d=$(timeit "$FASTWC" "$flag" "${files[@]}") + [[ -z "$fast_us" || "$d" -lt "$fast_us" ]] && fast_us="$d" + done + + finish_race "$label" "$wc_out" "$fast_out" "$wc_us" "$fast_us" +} + # run_stdin_cases <-w|-l|...> — run run_stdin_case # for every size, stopping at the first failure. run_stdin_cases() { diff --git a/docs/PERFORMANCE.md b/docs/PERFORMANCE.md index 8333cd6..6f876e8 100644 --- a/docs/PERFORMANCE.md +++ b/docs/PERFORMANCE.md @@ -287,6 +287,11 @@ make bench # build release + run every suite ./benchmarks/test-all.sh # words, lines (monsters included), stdin ``` +The lines suite races `-L` as well as `-l`, and ends by counting 128 +files of about 1.1 MB each, which is the worker pool's case: both sides +finish in well over a second's worth of work, so the row is a race and +not a startup measurement. + `test-all.sh` compiles its two helper tools on the spot (`tools/genfile` for the test data, `tools/timeit` for microsecond timing) — no separate setup. The suites live in