Skip to content

performance: index CLI declaration collisions instead of scanning the full model registry #370

Description

@codeforester

Parent: #214

Problem

Every base_cli_option declaration scans the full associative model registry to detect name collisions and scans it again for each token. The registry contains multiple metadata entries per option, so model construction grows quadratically as generated CLIs add options.

This is declaration-time overhead before the application handler runs.

Evidence

Reviewed at commit d064f426681f0e340ff4990ba0c9830084a5fe12.

A focused same-process benchmark declaring one command with unique flag options measured:

Options Elapsed
100 0.37 s
200 0.94 s
400 3.01 s
800 10.64 s

Wall-clock values are environment-specific, but the roughly quadratic growth matches the nested full-registry scans in the implementation.

Impact

Large generated or plugin-composed CLIs pay multi-second startup costs, limiting extensibility even though lookup during parsing is map-based.

Acceptance criteria

  • Replace full-registry declaration scans with indexes keyed by option name, token, and relevant route.
  • Preserve ancestor/descendant collision semantics and declaration rollback guarantees.
  • Add scalable coverage that detects a regression to quadratic construction without a brittle machine-specific wall-clock threshold.
  • Record before/after benchmark results for representative model sizes.
  • Preserve Bash 4.2 support and run ./tests/validate.sh.

Review validation

The existing benchmark contract covers small reference applications and passes; it does not vary declaration count.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or product improvement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions