Enable dtest -r for -s calc - #387
Conversation
Calc expands each deal into strain boards; record those solve times and sum them so the existing report path works for DD-table runs. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
🟡 Changes recommended
Zero-deal calc paths can leave reused timing output stale.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Extends dtest -r reporting to calc mode by collecting per-strain solve timings and aggregating them per deal.
Changes:
- Adds optional timing output to CalcAllTablesX APIs.
- Integrates calc timings into reports.
- Updates help text and adds aggregation and loop tests.
File summaries
| File | Reviewed changes | Findings |
|---|---|---|
library/tests/testcommon.cpp |
Enables calc timing reports. | — |
library/tests/report_board_timings.hpp |
Declares timing aggregation helpers. | — |
library/tests/report_board_timings.cpp |
Implements per-deal timing aggregation. | — |
library/tests/report_board_timings_test.cpp |
Tests aggregation and saturation behavior. | — |
library/tests/loop.hpp |
Extends the loop API for timing output. | — |
library/tests/loop.cpp |
Collects and aggregates calc timings across batches. | — |
library/tests/loop_failure_test.cpp |
Tests cross-batch timing collection. | — |
library/tests/args.cpp |
Updates report help text. | — |
library/src/calc_tables.hpp |
Declares timing-aware APIs. | Moderate, 2 votes: zero-deal paths do not clear or resize strain_times_us. |
library/src/calc_tables.cpp |
Collects optional per-strain timings. | Moderate, 1 vote: the main zero-deal path can leave stale output. Moderate, 1 vote: the PBN zero-deal path likewise leaves stale output. |
Review details
Suppressed comments (2)
library/src/calc_tables.cpp:799
- The PBN helper has the same stale-output edge case: its zero-deal success return bypasses the forwarding call, so a caller-provided
strain_times_usis not cleared despite the optional-output contract. Clear it before returning fornumDeals == 0.
return calc_all_tables_x(
numDeals, binary.data(), mode, trumpFilter, results, par, maxThreads,
strain_times_us);
library/src/calc_tables.cpp:711
- The new timing-output contract says a non-null
strain_times_usis resized tonumDeals * included_strains, but thenumDeals == 0success path returns before this assignment and leaves a reused vector unchanged. Clear the optional output on the zero-deal path so callers cannot observe stale timings.
if (strain_times_us != nullptr)
*strain_times_us = std::move(local_strain_times);
- Files reviewed: 10/10 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
A successful numDeals == 0 path must empty an optional strain_times_us vector so callers cannot observe timings from a previous batch. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Add a direct <utility> include in calc_tables.cpp for std::move.
Review details
Suppressed comments (1)
library/src/calc_tables.cpp:12
- This translation unit now calls
std::movebelow, but it does not include<utility>directly and therefore relies on transitive standard-library includes. That is not portable across toolchains; add the direct header so the new code has a guaranteed declaration.
#include <chrono>
- Files reviewed: 11/11 changed files
- Comments generated: 0 new
- Review effort level: Lite
Avoid relying on transitive standard-library headers for the optional strain-timing path. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed the follow-up Copilot note: |
zzcgumn
left a comment
There was a problem hiding this comment.
I like the idea that we can report fine-grained performance data and feed it to any statistical analysis toolkit we want to use.
Summary
dtest -r/--reportso-s calcprints the same per-deal timing table as solve.calc_all_tables_x, then sum them to per-deal times in the harness.Test plan
bazelisk test //library/tests:report_board_timings_test //library/tests:loop_failure_test //library/tests/system:calc_all_tables_x_testbazelisk build //library/tests:dtest && ./bazel-bin/library/tests/dtest -f hands/list10.txt -s calc -n 1 -rshows a non-empty per-board timing report-s solve -rstill reports as beforeMade with Cursor