Skip to content

Ninja generation and the scheduler do quadratic lookups #187

Closed

Description

@Aswin-V

What

Two quadratic paths in ebuild:

  1. NinjaBackend._write_ninja (ebuild/build/ninja_backend.py) matched each executable depends entry by scanning every target, and rebuilt the cflags string for every source.
  2. run_graph (ebuild/core/scheduler.py) ordered freed nodes with order.index, a linear scan per node.

Measured (author's numbers, macOS, Python 3.14)

  • ninja large (600 targets, 24k sources): 379.7 ms -> 195.0 ms
  • scheduler fan-out n=4000, jobs=4: 98.5 ms -> 53.0 ms

Proposed approach

Build the static-library lookup once per manifest (a count, not a set, so output stays byte-identical when two static libraries share a name), build the cflags line once per target, and use a position map in run_graph. Add tests for internal static-library linking, per-source cflags, and parallel dispatch order. Generated build.ninja and compile_commands.json must stay byte-identical to master.

Status

Fix proposed in #186 (same author). Performance, not correctness.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions