Skip to content

Add hierarchical discriminator multiplicity support#257

Open
kugan-nv wants to merge 1 commit intogoogle:masterfrom
kugan-nv:hd1
Open

Add hierarchical discriminator multiplicity support#257
kugan-nv wants to merge 1 commit intogoogle:masterfrom
kugan-nv:hd1

Conversation

@kugan-nv
Copy link
Contributor

@kugan-nv kugan-nv commented Nov 14, 2025

Added support for mutiplicity and copy_id for gcc gcov. This should matches the GCC
implementation. I am posting patches to GCC to match this.

This patch also adds support for two-pass aggregation when using hierarchical
discriminator encoding (gcov_version=3). The two-pass approach correctly
handles duplicate samples from code duplication (loop unrolling, etc.).

  • GetBaseDiscriminator() - Extract bits 0-7
  • GetMultiplicity() - Extract bits 8-14 (duplication factor)
  • GetCopyID() - Extract bits 15-25 (unused but reserved)

With the patch we now:

  1. Extract multiplicity and copy_id from discriminator
  2. Multiply sample count by multiplicity
  3. Add samples using copy_id.

Copy link
Contributor

@erozenfeld erozenfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one question

source_info.h Outdated
}

// Return the full 64-bit offset for 32-bit hierarchical discriminators.
static constexpr uint64_t GenerateFullOffset(uint64_t Offset) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not called from anywhere , is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this

@kugan-nv
Copy link
Contributor Author

Thanks for the review @erozenfeld.

I have also added support for aggregating samples with same with same [line + base discriminator] as a second pass as GCC doesn't aggregate. This is only done for create_gcov (for gcc) and supported with a flag. This is also enabled only for gcov version 3.

GCC patches are now comitted.

@kugan-nv kugan-nv force-pushed the hd1 branch 2 times, most recently from 74a75eb to 03a7e16 Compare January 16, 2026 10:49
Added support for mutiplicity and copy_id for gcc gcov. This should matches the GCC
implementation. I am posting patches to GCC to match this.

This patch also adds support for two-pass aggregation when using hierarchical
discriminator encoding (gcov_version=3). The two-pass approach correctly
handles duplicate samples from code duplication (loop unrolling, etc.).

  * GetBaseDiscriminator() - Extract bits 0-7
  * GetMultiplicity() - Extract bits 8-14 (duplication factor)
  * GetCopyID() - Extract bits 15-25 (unused but reserved)

With the patch we now:
1. Extract multiplicity and copy_id from discriminator
2. Multiply sample count by multiplicity
4. Add samples  using copy_id.

This was already supported for LLVM.
@kugan-nv
Copy link
Contributor Author

kugan-nv commented Feb 4, 2026

@erozenfeld: Ping ?

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.

2 participants