pub fn pattern_key(name: &str) -> StringExpand description
Compute the token-normalized skeleton for a name string.
Consumed by crate::ctprof_compare::GroupBy::Comm
(thread-name grouping),
crate::ctprof_compare::GroupBy::Pcomm (process-name
grouping), and
crate::ctprof_compare::collect_smaps_rollup (per-pcomm
smaps aggregation) — each callsite passes a different field
(t.comm, t.pcomm, t.pcomm respectively) and applies its
own callsite-level policy on top of the skeleton this function
returns.
Splits the input on a separator class ([.\-_/:@+\[\]\s]+),
classifies each non-separator token by classify_token, and
rejoins with the original separator runs preserved verbatim.
The first matching rule wins per token:
- Pure digits →
{N}(e.g.42→{N}). - Hex-like (all chars
[0-9a-f], length ≥ 2, contains at least one digit) →{H}(e.g.abc123def→{H}). - Alpha prefix + trailing digits (
^[A-Za-z]+\d+$, alpha prefix length ≥ 1) →prefix{N}(e.g.worker7→worker{N},u8→u{N}). - Leading digits + alpha suffix (
^\d+[A-Za-z]+$) →{N}suffix(e.g.1H→{N}H,100Hz→{N}Hz). - Otherwise: keep literal.
Two names that produce the same skeleton group together at
the bucket layer. The singleton-revert policy (“if only one
thread / process matches a skeleton, revert to literal”) is a
callsite policy enforced by
crate::ctprof_compare::build_groups — pattern_key itself
always returns the skeleton, leaving callsites free to override
(and indeed crate::ctprof_compare::collect_smaps_rollup
does NOT singleton-revert; see its doc for why).
Examples:
whirly-gig-15→whirly-gig-{N}.kworker/0:0-wq_reclaim→kworker/{N}:{N}-wq_reclaim.kworker/u8:7→kworker/u{N}:{N}(single-letter alpha prefixuqualifies under rule 3).session-a1234→session-{H}(hex-like).BPF_CUBIC→BPF_CUBIC(pure alpha, no digits).bloop-tangler→bloop-tangler(pure alpha).