Skip to content

test(genspec-tui): count every allocation when checking attribution - #110

Merged
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:fix/profiler-test-sampling
Aug 14, 2026
Merged

fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:fix/profiler-test-sampling

Conversation

@fredbi

@fredbi fredbi commented Aug 14, 2026

Copy link
Copy Markdown
Member

TestProfilerCapturesARun allocated a megabyte and asserted that the profiler attributed it. At the default rate the heap profiler samples one allocation per 512 KiB, so that megabyte is a Poisson draw with a mean of two, and the profile comes back empty about one run in seven — measured at 4 failures in 30 runs locally, independently of the toolchain.

Pin MemProfileRate to 1 for the test, as the fabricated-record tests alongside it already do, so the assertion is about attribution rather than about luck. The runtime honours rate 1 from the very next allocation, with no threshold carried over from the previous rate.

Nothing in the profiler changes: sampling is what the default rate means, and a phase whose sites were not sampled already says so on the card.

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

TestProfilerCapturesARun allocated a megabyte and asserted that the
profiler attributed it. At the default rate the heap profiler samples one
allocation per 512 KiB, so that megabyte is a Poisson draw with a mean of
two, and the profile comes back empty about one run in seven — measured at
4 failures in 30 runs locally, independently of the toolchain.

Pin MemProfileRate to 1 for the test, as the fabricated-record tests
alongside it already do, so the assertion is about attribution rather than
about luck. The runtime honours rate 1 from the very next allocation, with
no threshold carried over from the previous rate.

Nothing in the profiler changes: sampling is what the default rate means,
and a phase whose sites were not sampled already says so on the card.

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@fredbi
fredbi merged commit 116d6d2 into go-openapi:master Aug 14, 2026
29 checks passed
@fredbi
fredbi deleted the fix/profiler-test-sampling branch August 14, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant