Skip to content

perf: benchmark type-annotation stripping before optimizing is_return_field_child #452

Description

@dean0x

Context

Deferred from PR #446 (fix/agent-reported-batch) code review:

  • Review dir: .devflow/docs/reviews/fix-agent-reported-batch/2026-07-13_1130
  • Review date: 2026-07-15
  • Consolidates: ISSUE-13, ISSUE-18
  • Reason: Premature-optimization perf note; bounded + within <50ms/1000-line target; reviewer flags MEASURE-BEFORE-OPTIMIZING

Issue

Upward parent-walk overhead in is_return_field_child

  • File: crates/rskim-core/src/transform/pseudo.rs:556
  • Problem: is_return_field_child walks node.parent() (O(subtree-depth) in tree-sitter C bindings) once per strippable Python/TS type node
  • Current state: Bounded by MAX_AST_DEPTH/MAX_AST_NODES and comfortably within the <50ms/1000-line target; no demonstrated performance impact

Solution

MEASURE FIRST (this is not a blocker):

  1. Create a type-annotation-heavy TS/Python benchmark fixture (e.g., 100+ param/return type annotations)
  2. Profile skim <fixture> --mode=pseudo with flame graph or perf
  3. Measure: overhead of is_return_field_child parent-walk vs total transform time
  4. If measured overhead > 5% of transform time: Optimize by threading TreeCursor field_name() into the collect_noise_ranges recursion to check field_name == "return_type" in O(1)
  5. If measured overhead < 5%: Close as WONTFIX — the parent-walk is negligible and the simpler logic is safer

Implementation Notes

  • Do NOT optimize without measurement — follow "measure before optimizing" discipline
  • Regression target: must stay under <50ms/1000-line SLA
  • Benchmarking task may belong in rskim-bench or as a standalone script

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtTechnical debt backlog item

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions