Skip to content

Importing gitgalaxy.galaxyscope takes ~3 s, 2.5 s of it compiling every language's regexes up front #3914

Closed

Description

@squid-protocol

Measured

python -X importtime -c "import gitgalaxy.galaxyscope" on Linux reports 3.2 s in total:

Module Cumulative import time Self time
gitgalaxy.standards.language_standards 2.50 s
languages.dart 0.26 s
_shared_patterns 0.23 s
languages.powershell 0.20 s
gitgalaxy.core.detector (own time) 0.20 s

Why it matters

Every process that scans pays it:

  • every galaxyscope run, including a one-file scan whose extraction takes 0.06 s;
  • under the spawn start method (Windows, macOS), every extraction worker as well.

The test suite runs about 150 scans, so the suite pays this cost O(scans) times. The companion fix removes the per-worker share for small scans, but not the per-process one.

Directions

  • Compile each language's rules lazily, on the first file of that language: a COBOL estate never needs dart's patterns.
  • Or keep the definitions as source strings until a StructuralExtractor is built for that language.

Either way, measure with -X importtime before and after, and keep the golden masters byte-identical.

Activity

  1. added
    core-engine
    on Sep 27, 2026
  2. added 3 commits that reference this issue on Sep 27, 2026
  3. squid-protocol commented on Sep 27, 2026

    @squid-protocol
    OwnerAuthor

    Where this landed.

    The change took three PRs:

    End state, measured with phase_ab against main before #3923, as whole-command time:

    scan change
    40 C files −30.4%
    3,280-file crucible corpus +0.0%

    The deterministic outputs and the golden masters are identical. Details and caveats are on #3929.


    Generated by Claude Code

  4. added 2 commits that reference this issue on Sep 27, 2026
  5. squid-protocol commented on Sep 27, 2026

    @squid-protocol
    OwnerAuthor

    Closing as done. #3923, #3931 and #3939 are all merged.

    The full numbers are in the comment above and on #3929.


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-engineperformance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions