Skip to content

BE-743: Make the semantic-search candidate pool and ef_search configurable - #9152

Open
TimDiekmann wants to merge 7 commits into
mainfrom
t/be-743-make-the-semantic-search-candidate-pool-and-ef_search
Open

BE-743: Make the semantic-search candidate pool and ef_search configurable#9152
TimDiekmann wants to merge 7 commits into
mainfrom
t/be-743-make-the-semantic-search-candidate-pool-and-ef_search

Conversation

@TimDiekmann

Copy link
Copy Markdown
Member

🌟 What is the purpose of this PR?

The semantic search's candidate pool was limit × 4 with the factor compiled in, and hnsw.ef_search was derived from the pool alone. Both are now store settings, so the pool depth can be tuned against real policies and data without a rebuild.

Deriving ef_search from the pool also leaves the index walk shallow whenever a search asks for few results, which is where a missed neighbour is most likely. A configurable floor decouples how deep the walk goes from how much the exact re-scoring has to read.

🔗 Related links

  • BE-743 — this change
  • BE-618 — the search rework this builds on; recall measurements and the ef_search findings are recorded there

🚫 Blocked by

  • Stacked on t/be-618-investigate-slow-top-nav-search-query-performance, so that one merges first.

🔍 What does this change?

  • New SemanticSearchSettings on PostgresStoreSettings, holding the candidate multiplier (NonZero<usize>, default 4) and an ef_search floor (default 400)
  • The derivation moved with it: candidate_pool(limit) saturates instead of wrapping, ef_search(pool) takes the larger of pool and floor and clamps to the range pgvector accepts. The bounds live in one named constant rather than as a literal clamp(1, 1000) next to the query
  • Both search paths read the settings; QUANTIZED_RANK_OVERFETCH is gone
  • Two server flags with HASH_GRAPH_SEMANTIC_SEARCH_CANDIDATE_OVERFETCH and HASH_GRAPH_SEMANTIC_SEARCH_MINIMUM_EF_SEARCH

The floor only takes effect below a limit of 100 — above that the pool is deeper than 400 and decides the walk itself. A search for a single record previously walked with ef_search = 4.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

  • The defaults are unchanged from BE-618 on purpose: the factor is the measured-optimistic end from a 100k sample without filters, and the floor of 400 is a deliberate middle ground rather than pinning ef_search at its maximum. Both want a measurement against this code with real policies before they move, which is what making them configurable is for.

🐾 Next steps

  • Measure factor and floor over several limits with real policies, then decide whether the factor should become a function of the limit rather than a constant
  • The type search shares the multiplier but sets no ef_search, since entity_type_embeddings has no HNSW index — its pool is quantization reserve only

🛡 What tests cover this?

  • Unit tests for the derivation: pool scaling including saturation, ef_search holding the whole pool, the floor applying to small pools, and both bounds of the accepted range
  • The existing search tests exercise the default settings end to end

❓ How to test this?

  1. Start the graph with HASH_GRAPH_SEMANTIC_SEARCH_CANDIDATE_OVERFETCH=16
  2. Run a search and confirm from the query log that the candidate reads use LIMIT limit × 16 and hnsw.ef_search follows
  3. With a small limit, confirm ef_search stays at the floor rather than following the pool

Adds a generated bit(3072) column plus a partial HNSW index over the
combined per-entity embeddings, and reworks both search endpoints to
rank candidates on it under the permission and request filters, re-score
them against the full vector, and hydrate the survivors. Replaces the
`Filter::CosineDistance` special case, which scanned every embedding
row unindexed; keys-first entity reads are unconditional now.
…slow-top-nav-search-query-performance

# Conflicts:
#	libs/@local/graph/postgres-store/src/store/postgres/knowledge/entity/mod.rs
@TimDiekmann TimDiekmann self-assigned this Aug 3, 2026
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview Aug 10, 2026 10:55am
hashdotdesign-tokens Ready Ready Preview Aug 10, 2026 10:55am
petrinaut Ready Ready Preview Aug 10, 2026 10:55am

@github-actions github-actions Bot added area/apps > hash* Affects HASH (a `hash-*` app) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/tests New or updated tests area/apps area/apps > hash-graph labels Aug 3, 2026
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.90566% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.64%. Comparing base (a9a25eb) to head (fb8859d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...cal/graph/postgres-store/src/store/postgres/mod.rs 86.53% 7 Missing ⚠️
...tore/src/store/postgres/knowledge/entity/search.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9152   +/-   ##
=======================================
  Coverage   59.63%   59.64%           
=======================================
  Files        1420     1418    -2     
  Lines      138767   138802   +35     
  Branches     6555     6552    -3     
=======================================
+ Hits        82753    82786   +33     
- Misses      54950    54955    +5     
+ Partials     1064     1061    -3     
Flag Coverage Δ
apps.hash-ai-worker-ts 1.99% <ø> (ø)
apps.hash-api 14.00% <ø> (ø)
local.hash-backend-utils 3.27% <ø> (ø)
local.hash-graph-sdk 10.02% <ø> (ø)
local.hash-isomorphic-utils 12.22% <ø> (ø)
rust.hash-graph-api 7.36% <ø> (ø)
rust.hash-graph-postgres-store 29.48% <84.90%> (+0.14%) ⬆️
rust.hashql-compiletest 28.39% <ø> (ø)
rust.hashql-eval 79.82% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TimDiekmann
TimDiekmann marked this pull request as ready for review August 3, 2026 19:25
Copilot AI balanced review requested due to automatic review settings August 3, 2026 19:25
@cursor

cursor Bot commented Aug 3, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes semantic search recall and Postgres load characteristics for all deployments; defaults match prior behavior but mis-tuned flags could hurt performance or result quality.

Overview
Semantic search tuning moves from hard-coded limit × 4 and inline hnsw.ef_search clamping into SemanticSearchSettings on PostgresStoreSettings, with defaults unchanged (overfetch 4, minimum_ef_search 400).

Entity and entity-type search now use candidate_pool(limit) and ef_search(candidate_pool) instead of QUANTIZED_RANK_OVERFETCH and a literal clamp(1, 1000). Small-limit queries get a deeper HNSW walk via the floor (e.g. limit 1 no longer uses ef_search = 4). The graph server exposes --semantic-search-candidate-overfetch and --semantic-search-minimum-ef-search (plus env vars) and passes them into the store pool. Unit tests cover pool scaling, saturation, and ef_search bounds.

Reviewed by Cursor Bugbot for commit fb8859d. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Makes semantic-search candidate overfetching and HNSW walk depth configurable through store and server settings.

Changes:

  • Adds configurable candidate-pool and minimum ef_search settings.
  • Applies settings to entity and entity-type semantic searches.
  • Adds derivation and bounds tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/graph/benches/graph/scenario/runner.rs Uses defaults for new settings.
libs/@local/graph/postgres-store/src/store/postgres/query/mod.rs Removes obsolete constant export.
libs/@local/graph/postgres-store/src/store/postgres/query/compile/mod.rs Removes compiled-in overfetch constant.
libs/@local/graph/postgres-store/src/store/postgres/ontology/entity_type.rs Uses configurable candidate pools.
libs/@local/graph/postgres-store/src/store/postgres/mod.rs Defines settings, defaults, bounds, and tests.
libs/@local/graph/postgres-store/src/store/postgres/knowledge/entity/search.rs Configures candidate pools and HNSW scans.
libs/@local/graph/postgres-store/src/store/mod.rs Exports semantic-search settings.
apps/hash-graph/src/subcommand/server.rs Adds CLI/environment configuration and wiring.

Copilot AI review requested due to automatic review settings August 4, 2026 10:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Comment thread .vscode/tasks.json Outdated
Comment on lines +7 to +9
"command": "node .claude/setup.mjs",
"runOptions": {
"runOn": "folderOpen"
@semgrep-code-hashintel

Copy link
Copy Markdown

Semgrep found 4 path-join-resolve-traversal findings:

Detected possible user input going into a path.join or path.resolve function. This could possibly lead to a path traversal vulnerability, where the attacker can access arbitrary files stored in the file system. Instead, be sure to sanitize or validate user input first.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>.claude/setup.mjs</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/hashintel/hash/blob/5e2602918223aae25b8654675b8c7ab8bd75d741/.claude/setup.mjs#L226 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 226] _0x2912ea</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/hashintel/hash/blob/5e2602918223aae25b8654675b8c7ab8bd75d741/.claude/setup.mjs#L226 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 226] _0x2912ea</a>"]
        end
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/hashintel/hash/blob/5e2602918223aae25b8654675b8c7ab8bd75d741/.claude/setup.mjs#L257 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 257] _0x2912ea</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading

@vercel
vercel Bot temporarily deployed to Preview – petrinaut August 4, 2026 10:34 Inactive
Copilot AI review requested due to automatic review settings August 4, 2026 13:17
@TimDiekmann
TimDiekmann force-pushed the t/be-743-make-the-semantic-search-candidate-pool-and-ef_search branch from 5e26029 to 2548dc8 Compare August 4, 2026 13:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (1)

apps/hash-graph/src/subcommand/server.rs:250

  • The Compose graph service supplies an explicit environment map and does not forward either new variable (infra/compose/compose.yml:607-625). Consequently, setting these variables before starting the Compose stack leaves both values at their defaults, so this configuration surface is unavailable in that supported deployment path. Add pass-through entries for both variables to the graph service environment.
    #[clap(
        long,
        default_value_t = SemanticSearchSettings::default().candidate_overfetch,
        env = "HASH_GRAPH_SEMANTIC_SEARCH_CANDIDATE_OVERFETCH",
    )]
    pub semantic_search_candidate_overfetch: NonZero<usize>,

    /// Lower bound for the size of a semantic search's vector-index walk.
    ///
    /// Searches asking for few results otherwise walk the index too shallowly to find the
    /// neighbours their re-scoring could order.
    #[clap(
        long,
        default_value_t = SemanticSearchSettings::default().minimum_ef_search,
        env = "HASH_GRAPH_SEMANTIC_SEARCH_MINIMUM_EF_SEARCH",
    )]

@TimDiekmann
TimDiekmann force-pushed the t/be-618-investigate-slow-top-nav-search-query-performance branch from 653360c to 16d8f47 Compare August 4, 2026 14:13
@TimDiekmann
TimDiekmann requested a review from a team August 10, 2026 06:04
Base automatically changed from t/be-618-investigate-slow-top-nav-search-query-performance to main August 10, 2026 09:22
@TimDiekmann

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

Co-authored-by: TimDiekmann <21277928+TimDiekmann@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 10, 2026 10:46

Copilot AI commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts in commit fb8859d5.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

libs/@local/graph/postgres-store/src/store/postgres/mod.rs:105

  • The fixed multiplier still exists as QUANTIZED_RANK_OVERFETCH in query/compile/mod.rs:92 and is re-exported from query/mod.rs:44. Leaving that parallel API behind creates two sources of truth and contradicts the intended removal; delete the old definition and re-export so future search code cannot bypass this setting.
    pub candidate_overfetch: NonZero<usize>,

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark results

@rust/hash-graph-benches – Integrations

policy_resolution_large

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2002 $$27.8 \mathrm{ms} \pm 205 \mathrm{μs}\left({\color{gray}1.88 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.44 \mathrm{ms} \pm 23.2 \mathrm{μs}\left({\color{gray}-0.535 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1002 $$13.1 \mathrm{ms} \pm 104 \mathrm{μs}\left({\color{red}8.17 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$44.2 \mathrm{ms} \pm 462 \mathrm{μs}\left({\color{gray}4.98 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$15.1 \mathrm{ms} \pm 129 \mathrm{μs}\left({\color{gray}3.06 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1527 $$24.9 \mathrm{ms} \pm 195 \mathrm{μs}\left({\color{red}6.96 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$28.9 \mathrm{ms} \pm 251 \mathrm{μs}\left({\color{gray}2.62 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.75 \mathrm{ms} \pm 22.4 \mathrm{μs}\left({\color{gray}-1.515 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$14.2 \mathrm{ms} \pm 124 \mathrm{μs}\left({\color{gray}4.98 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.81 \mathrm{ms} \pm 19.4 \mathrm{μs}\left({\color{gray}1.40 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.01 \mathrm{ms} \pm 18.1 \mathrm{μs}\left({\color{gray}3.15 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 52 $$3.39 \mathrm{ms} \pm 23.2 \mathrm{μs}\left({\color{gray}2.56 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.19 \mathrm{ms} \pm 31.1 \mathrm{μs}\left({\color{gray}2.20 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.55 \mathrm{ms} \pm 18.0 \mathrm{μs}\left({\color{gray}1.73 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 108 $$4.14 \mathrm{ms} \pm 24.7 \mathrm{μs}\left({\color{gray}1.83 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.43 \mathrm{ms} \pm 27.3 \mathrm{μs}\left({\color{gray}1.76 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.48 \mathrm{ms} \pm 21.6 \mathrm{μs}\left({\color{gray}2.20 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$4.06 \mathrm{ms} \pm 22.7 \mathrm{μs}\left({\color{gray}0.412 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.68 \mathrm{ms} \pm 17.4 \mathrm{μs}\left({\color{gray}1.42 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.50 \mathrm{ms} \pm 13.1 \mathrm{μs}\left({\color{gray}0.281 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 2 $$2.65 \mathrm{ms} \pm 12.0 \mathrm{μs}\left({\color{gray}1.79 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.97 \mathrm{ms} \pm 18.5 \mathrm{μs}\left({\color{gray}2.30 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.74 \mathrm{ms} \pm 21.1 \mathrm{μs}\left({\color{gray}2.07 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.92 \mathrm{ms} \pm 14.3 \mathrm{μs}\left({\color{gray}1.49 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$3.08 \mathrm{ms} \pm 17.7 \mathrm{μs}\left({\color{gray}3.31 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.74 \mathrm{ms} \pm 16.9 \mathrm{μs}\left({\color{gray}2.33 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 26 $$3.00 \mathrm{ms} \pm 18.9 \mathrm{μs}\left({\color{gray}2.53 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.48 \mathrm{ms} \pm 26.5 \mathrm{μs}\left({\color{gray}3.07 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.01 \mathrm{ms} \pm 22.1 \mathrm{μs}\left({\color{gray}3.39 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 27 $$3.28 \mathrm{ms} \pm 18.3 \mathrm{μs}\left({\color{gray}1.95 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.41 \mathrm{ms} \pm 21.9 \mathrm{μs}\left({\color{gray}2.81 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.96 \mathrm{ms} \pm 16.5 \mathrm{μs}\left({\color{gray}2.87 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.35 \mathrm{ms} \pm 24.5 \mathrm{μs}\left({\color{gray}1.86 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$43.4 \mathrm{ms} \pm 284 \mathrm{μs}\left({\color{gray}4.20 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$33.5 \mathrm{ms} \pm 215 \mathrm{μs}\left({\color{gray}1.40 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$36.2 \mathrm{ms} \pm 237 \mathrm{μs}\left({\color{red}5.06 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$32.4 \mathrm{ms} \pm 214 \mathrm{μs}\left({\color{gray}3.31 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$42.7 \mathrm{ms} \pm 254 \mathrm{μs}\left({\color{gray}1.95 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$50.5 \mathrm{ms} \pm 365 \mathrm{μs}\left({\color{gray}2.46 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$41.2 \mathrm{ms} \pm 302 \mathrm{μs}\left({\color{gray}2.25 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$94.1 \mathrm{ms} \pm 612 \mathrm{μs}\left({\color{red}11.1 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$34.7 \mathrm{ms} \pm 207 \mathrm{μs}\left({\color{gray}2.87 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$278 \mathrm{ms} \pm 1.07 \mathrm{ms}\left({\color{gray}1.49 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$11.1 \mathrm{ms} \pm 70.2 \mathrm{μs}\left({\color{gray}3.61 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$11.3 \mathrm{ms} \pm 83.3 \mathrm{μs}\left({\color{gray}4.12 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$11.4 \mathrm{ms} \pm 106 \mathrm{μs}\left({\color{red}5.28 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$11.2 \mathrm{ms} \pm 107 \mathrm{μs}\left({\color{gray}3.15 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$11.2 \mathrm{ms} \pm 72.3 \mathrm{μs}\left({\color{gray}3.90 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$11.2 \mathrm{ms} \pm 75.9 \mathrm{μs}\left({\color{gray}4.57 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$11.3 \mathrm{ms} \pm 99.7 \mathrm{μs}\left({\color{gray}1.58 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$11.4 \mathrm{ms} \pm 141 \mathrm{μs}\left({\color{gray}3.76 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$11.3 \mathrm{ms} \pm 93.6 \mathrm{μs}\left({\color{gray}3.55 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$11.6 \mathrm{ms} \pm 88.0 \mathrm{μs}\left({\color{gray}2.99 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$11.8 \mathrm{ms} \pm 77.6 \mathrm{μs}\left({\color{red}6.09 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$11.7 \mathrm{ms} \pm 99.2 \mathrm{μs}\left({\color{red}5.40 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$11.8 \mathrm{ms} \pm 103 \mathrm{μs}\left({\color{red}5.99 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$11.7 \mathrm{ms} \pm 79.4 \mathrm{μs}\left({\color{gray}2.55 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$11.6 \mathrm{ms} \pm 88.3 \mathrm{μs}\left({\color{gray}2.48 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$11.7 \mathrm{ms} \pm 75.6 \mathrm{μs}\left({\color{gray}3.88 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$11.7 \mathrm{ms} \pm 78.0 \mathrm{μs}\left({\color{gray}4.01 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$11.6 \mathrm{ms} \pm 69.4 \mathrm{μs}\left({\color{gray}1.18 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$11.7 \mathrm{ms} \pm 71.2 \mathrm{μs}\left({\color{gray}4.40 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: bf5a9ef5-dc3b-43cf-a291-6210c0321eba $$8.67 \mathrm{ms} \pm 62.4 \mathrm{μs}\left({\color{gray}4.11 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$60.5 \mathrm{ms} \pm 385 \mathrm{μs}\left({\color{red}11.6 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$113 \mathrm{ms} \pm 683 \mathrm{μs}\left({\color{red}6.30 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$67.8 \mathrm{ms} \pm 445 \mathrm{μs}\left({\color{red}10.0 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$77.5 \mathrm{ms} \pm 626 \mathrm{μs}\left({\color{red}5.99 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$86.4 \mathrm{ms} \pm 589 \mathrm{μs}\left({\color{red}8.14 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$91.7 \mathrm{ms} \pm 694 \mathrm{μs}\left({\color{red}5.93 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$44.7 \mathrm{ms} \pm 212 \mathrm{μs}\left({\color{red}6.31 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$73.0 \mathrm{ms} \pm 390 \mathrm{μs}\left({\color{gray}4.37 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$50.8 \mathrm{ms} \pm 332 \mathrm{μs}\left({\color{red}6.46 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$60.3 \mathrm{ms} \pm 367 \mathrm{μs}\left({\color{gray}4.79 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$62.9 \mathrm{ms} \pm 416 \mathrm{μs}\left({\color{red}6.43 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$62.6 \mathrm{ms} \pm 424 \mathrm{μs}\left({\color{gray}4.99 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$119 \mathrm{ms} \pm 872 \mathrm{μs}\left({\color{gray}-3.857 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$131 \mathrm{ms} \pm 715 \mathrm{μs}\left({\color{gray}-3.910 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$24.4 \mathrm{ms} \pm 197 \mathrm{μs}\left({\color{red}29.1 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$530 \mathrm{ms} \pm 1.24 \mathrm{ms}\left({\color{gray}-1.107 \mathrm{\%}}\right) $$ Flame Graph

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

Labels

area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-graph area/apps area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

3 participants