Skip to content

fix: restore function names for migrated async guards #116

@rocketman-code

Description

@rocketman-code

Current Behavior

When a Guard detects thread migration on drop, the migrated record is attributed to "<migrated>" instead of the actual function name. This is because the 16-byte Guard optimization (PR #112) removed the function name from the Guard struct to minimize timing overhead.

For async code with multiple migrating functions, all migrated invocations collapse into a single "<migrated>" bucket with no way to distinguish which function each record belongs to.

Expected Behavior

Migrated guards should report the actual function name so that per-function timing data is preserved even when tasks migrate across threads.

Possible Approaches

  • Look up the function name from the enter thread's TLS stack using the cookie (stack depth) stored in the Guard
  • Embed a function name index (interned string table) and store an index in the Guard instead of the full string
  • Use a compact function ID assigned at registration time

The constraint is keeping Guard small (currently 16 bytes) to minimize timing distortion from stack allocation.

Related

Scope

  • piano-runtime/src/collector.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low prioritybugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions