Skip to content

perf: keyword constants are hashed to a UUID once per fact #531

Closed

Description

@adityamukho

PatternMatcher::match_component (matcher.rs:174, :222) calls edn_to_entity_id(&EdnValue::Keyword(k.clone())), which clones the keyword and computes a UUID v5, for every fact it compares with a constant entity or ref. It is about 8% of the 3-clause join at 1M facts. Resolve each pattern's constants once before matching.

Found by the #394 performance envelope (examples/perf_envelope.rs, results in docs/BENCHMARKS.md on v3).

Activity

  1. added this to the v3.1.0 milestone on Oct 11, 2026
  2. adityamukho commented on Oct 15, 2026

    @adityamukho
    CollaboratorAuthor

    Likely superseded by the streaming engine (#473). The engine resolves keyword constants once, when it plans the query (src/query/engine/plan.rs, edn_to_entity_id in constant resolution), so the per-fact cost remains only in PatternMatcher::match_component in the old executor, which #551 removes. Plan: close as superseded once #551 lands.

    Before closing, verify that no remaining v3.0.0 query path still runs matcher.rs per fact (for example rule bodies, not/not-join, or anything left on the executor after #546–#551), and re-run the #394 envelope (examples/perf_envelope.rs) to confirm the cost is gone from the 3-clause join profile.

  3. modified the milestones: v3.next, v3.0.0 on Oct 26, 2026
  4. adityamukho commented on Oct 27, 2026

    @adityamukho
    CollaboratorAuthor

    Closing as completed/superseded after #773 merged into v3 (d0ad89c).

    The audit confirms the old matcher path is gone and pattern keyword constants resolve while planning across scans, joins, rule bodies, negation/disjunction, prepared queries and cursors. The bench-machine verification completed all 69 envelope cases at 100K/1M/10M without errors or caps, plus separate 1M profiles. The evidence and limitations are recorded in #773's report.

    The distinct per-row keyword/ref expression-equality conversion introduced by #744 is now tracked in #774. No claim that all keyword hashing disappeared or that the historical 8% cost applies to that expression path.

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

    performanceBenchmark performance regressions

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions