Skip to content

Skip zero-padding for companion entries in per-frame vector #105

@rocketman-code

Description

@rocketman-code

Problem

In format_table_with_frames, the padding loop at lines 411-417 pads all entries (including companion-merged functions) with zeros so late-appearing functions have values for earlier frames:

let total_frames = frame_data.frames.len();
for e in &mut entries {
    while e.per_frame_self_ns.len() < total_frames {
        e.per_frame_self_ns.push(0);
    }
}

This is functionally harmless because the is_companion guard at line 441 prevents the padded vector from being used in percentile calculation. However, the zero-fill skip at lines 377-385 already excludes companion functions, so this padding loop is inconsistent -- it allocates zeros that are never read.

Suggested fix

Add the same companion guard to the padding loop:

for e in &mut entries {
    if !e.is_companion {
        while e.per_frame_self_ns.len() < total_frames {
            e.per_frame_self_ns.push(0);
        }
    }
}

Context

Discovered during code review of PR #104.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priorityperfPerformance improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions