Skip to content

signature_adapter causes significant overhead in hot transition paths #548

@ojomio

Description

@ojomio

Profiling shows that signature_adapter (dispatcher.py:203) accounts for
~30–50% of callback execution time in steady-state transitions.

The overhead comes from repeated use of inspect.signature and argument
binding on every callback invocation.

Each transition re-binds callback arguments dynamically, dominating CPU time
in high-frequency state machines.

Evidence

Flamegraph shows signature_adapter → inspect.signature → bind
as a wide frame in callback execution.

Image

Suggested improvements

  • Cache bound callback adapters at state-machine construction time
  • Optionally allow users to disable signature binding entirely
  • Document performance impact of flexible callback signatures

Impact

This significantly limits throughput for systems with frequent transitions
and makes the library unsuitable for performance-critical workflows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions