gh-239: Add metadata["phase"]#241
Open
maurycy wants to merge 7 commits into
Open
Conversation
Contributor
|
Should we include a test case validating that phase indicators are correctly passed to the hook's |
Contributor
Author
@sergey-miryanov Good catch. What do you think? |
| * ``unit``: Unit of values: ``byte``, ``integer`` or ``second`` | ||
| * ``phase`` (tuple or list of two non-empty strings): run phase and sample | ||
| type, set to one of ``("calibration", "loops")``, ``("calibration", | ||
| "warmup")``, ``("measurement", "warmup")`` or ``("measurement", "value")``. |
Contributor
There was a problem hiding this comment.
IIUC, the user will never see ("measurement", "warmup") in the output JSON. It would be good to note this. Or we could keep only the four states in the HookBase.teardown docs and note the difference.
| for value in (('measurement', 'value'), ['calibration', 'loops']): | ||
| with self.subTest(value=value): | ||
| run = pyperf.Run([1.0], metadata={'phase': value}, | ||
| collect_metadata=False) |
Contributor
There was a problem hiding this comment.
Should we test for collect_metadata=True here?
Member
|
I don't think that putting a phase in metadata makes sense: #239 (comment). |
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.
Hooks today receive
metadatabut cannot tell which_compute_valuesjust ran. The PR addsphaseto themetadata.("calibration", "warmup")calibrate_warmups(), including--recalibrate-warmups("calibration", "loops")calibrate_loops(), including--recalibrate-loops("measurement", "warmup")compute_warmups_values()warmup samples (skipped when--warmups 0)("measurement", "value")compute_warmups_values()value samplesRecalibration is implicit and hooks can use
metadata["recalibrate_warmups"]ormetadata["recalibrate_loops"].phaseis a tuple, but after a JSON round-trip it is a listAs a bonus,
benchmarks.runs.metadata[]is now explicit:{ "benchmarks": [ { "runs": [ { "metadata": { "calibrate_loops": 67108864, "date": "2026-05-27 23:54:30.678184", "duration": 0.7158581660478376, "mem_max_rss": 27230208, "phase": [ "calibration", "loops" ], "uptime": 634803.6837940216 }, "warmups": [[1, 2.92e-07], "... (elided)", [67108864, 2.65e-09]] }, { "metadata": { "date": "2026-05-27 23:54:31.261364", "duration": 0.536709374981001, "mem_max_rss": 27426816, "phase": [ "measurement", "value" ], "uptime": 634804.2667930126 }, "values": [ 2.5949900301497353E-9, 2.633662268304582E-9 ], "warmups": [ [ 67108864, 2.6324198845045776E-9 ] ] } ] } ], "metadata": { "boot_time": "2026-05-20 15:34:27", "...": "(removed for brevity)" }, "version": "1.0" }Feature requested by gc-monitor in #239.
Please see #239 (comment) for a possible future direction in the hook API.
cr @sergey-miryanov @vstinner
resolve #239