Skip to content

CommonJS model: shape-gate cost (the verdict is applied after the model, and quiet() is not memoized) #37

Open

Description

@inth3shadows

Found in the round-1 review of branch fix/commonjs-model-gaps (stacked on PR #29).

  1. The shape gate (with expandEvals, which builds up to 3 more programs) is computed up front, but its verdict is applied only after the whole value model has run. So every file the gate turns away still pays for the full model. That covers loops, try, UMD wrappers, comma statements and require('x')(...), which is most real-world and bundled CommonJS. The order exists so a file the model already turns away keeps its more specific reason. Run the gate first, and keep the specific reason only where it is cheap.
  2. quiet() is not memoized, so N call sites of the same helper re-walk its body (and the bodies of the functions it calls) N times. A Map<FunctionLikeDeclaration, boolean> for one gate run makes it linear.

Related: Express indexing CPU is already about +38% on PR #29.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions