Skip to content

BE-622: Move semantic search embedding generation into the graph#8920

Open
TimDiekmann wants to merge 2 commits into
mainfrom
t/be-622-move-semantic-search-embedding-generation-into-graph
Open

BE-622: Move semantic search embedding generation into the graph#8920
TimDiekmann wants to merge 2 commits into
mainfrom
t/be-622-move-semantic-search-embedding-generation-into-graph

Conversation

@TimDiekmann

Copy link
Copy Markdown
Member

Purpose

Move semantic-search embedding generation out of the Node SDK (which did a Temporal roundtrip to the ai worker) into the graph. The /entities/search and /entity-types/search endpoints now accept a semanticString and resolve it to an embedding by calling OpenAI directly, configured via HASH_GRAPH_OPENAI_API_KEY.

Builds on the dedicated search endpoints from BE-471/BE-621 (#8910, merged); targets main.

Linear: BE-622

What does this change?

  • New hash-graph-embeddings crate — provider-agnostic EmbeddingGenerator trait + OpenAiEmbeddingClient (own thin reqwest + reqwest-retry client, no async-openai). Model text-embedding-3-large / 3072 dims, pinned to match the TS indexer.
  • GraphHASH_GRAPH_OPENAI_API_KEY wired in like the Temporal client; search endpoints accept embedding xor semanticString; provider failures are classified (auth / rate-limit / outage) and mapped to 429/503/500 instead of a blanket 500; a caller-supplied embedding is validated against Embedding::DIM; startup logs whether semantic search is enabled.
  • Node SDKsearchEntities/searchEntityTypes forward semanticString directly and no longer take a temporalClient; dead calculateEmbedding removed (CreateEmbeddings* types kept for the worker's indexing path).
  • Docs / infra — OpenAPI regenerated; the mise run sync:turborepo task documented in AGENTS.md; HASH_GRAPH_OPENAI_API_KEY wired into the compose graph service.

Pre-merge checklist

  • New Rust crate is publish = false; no other publishable-package changes.
  • Docs updated (AGENTS.md); no Petrinaut changes.
  • Turbo graph gains @rust/hash-graph-embeddings.

How to test

Set HASH_GRAPH_OPENAI_API_KEY, start the graph, and POST /entities/search with { "semanticString": "...", "maximumSemanticDistance": 0.7 }. Without a key configured, semantic-string search returns a clean "unavailable" error and the startup log warns; the precomputed-embedding path needs no key.

Notes / follow-ups

  • Reviewed with the pr-review-toolkit agents (two rounds); findings addressed.
  • Deferred: HTTP-mock unit tests for the OpenAI client; honoring Retry-After (intentionally fail-fast for the interactive path); splitting EmbeddingError::Request build-vs-send.

@TimDiekmann TimDiekmann requested a review from a team as a code owner June 30, 2026 10:37
Copilot AI review requested due to automatic review settings June 30, 2026 10:37
@vercel

vercel Bot commented Jun 30, 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, Comment Jun 30, 2026 12:26pm
hashdotdesign-tokens Ready Ready Preview, Comment Jun 30, 2026 12:26pm
petrinaut Ready Ready Preview, Comment Jun 30, 2026 12:26pm

@cursor

cursor Bot commented Jun 30, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Search requests now depend on optional OpenAI credentials and an external API on the interactive path; misconfiguration or provider outages affect semantic-string search, though precomputed embeddings and fail-fast behavior limit blast radius.

Overview
Moves semantic-search embedding generation into the graph so callers no longer need a Temporal roundtrip through the AI worker when using semanticString.

Adds hash-graph-embeddings with an EmbeddingGenerator trait and OpenAiEmbeddingClient (text-embedding-3-large, 3072 dims, retries/timeouts). The graph reads HASH_GRAPH_OPENAI_API_KEY (empty/unset disables semantic-string search with a startup warning); compose passes OPENAI_API_KEY through as that env var.

/entities/search and /entity-types/search now take either a precomputed embedding or semanticString (not both). Shared resolve_search_embedding validates caller-supplied vector dimensions, calls OpenAI when configured, and maps provider failures to clearer HTTP statuses (e.g. rate limits, unavailable). OpenAPI is updated accordingly.

The TypeScript graph SDK drops calculateEmbedding and no longer requires temporalClient on searchEntities / searchEntityTypes; it forwards semanticString to the API. Embedding::len / is_empty support dimension checks. Docs note mise run sync:turborepo for new Rust crate wiring; dependency diagrams and lockfile reflect the new crate and reqwest-retry.

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

@github-actions github-actions Bot added area/deps Relates to third-party dependencies (area) area/apps > hash* Affects HASH (a `hash-*` app) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/apps area/apps > hash-graph type/legal Owned by the @legal team labels Jun 30, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d7f20d7. Configure here.

Comment thread apps/hash-graph/src/subcommand/server.rs
@TimDiekmann TimDiekmann force-pushed the t/be-622-move-semantic-search-embedding-generation-into-graph branch from d7f20d7 to dcb0ee2 Compare June 30, 2026 10:40
@github-advanced-security

Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

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

Moves semantic-search embedding generation from the TypeScript/Temporal path into the Rust graph service so /entities/search and /entity-types/search can accept a semanticString and resolve it to an embedding server-side (OpenAI), gated by HASH_GRAPH_OPENAI_API_KEY.

Changes:

  • Adds a new Rust workspace crate hash-graph-embeddings with a provider-agnostic EmbeddingGenerator trait and an OpenAI-backed client implementation.
  • Updates graph REST search request handling to accept embedding xor semanticString, resolve/validate embeddings, and classify provider failures into more specific status codes.
  • Removes the Node SDK’s Temporal-based calculateEmbedding path and forwards semanticString directly; wires the API key into docker-compose and updates agent docs.

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
yarn.lock Adds the new @rust/hash-graph-embeddings workspace package to Yarn dependencies.
libs/@local/graph/types/src/embedding.rs Adds len() / is_empty() helpers used for embedding validation.
libs/@local/graph/sdk/typescript/src/entity.ts Removes Temporal dependency and forwards semanticString directly to graph API search.
libs/@local/graph/sdk/typescript/src/entity-type.ts Removes Temporal dependency and forwards semanticString directly to graph API search.
libs/@local/graph/sdk/typescript/src/embeddings.ts Removes the Temporal-based calculateEmbedding implementation (keeps types).
libs/@local/graph/embeddings/src/openai.rs Implements OpenAI embeddings client with retries, timeout, and response validation.
libs/@local/graph/embeddings/src/lib.rs Introduces EmbeddingGenerator trait and re-exports public client types.
libs/@local/graph/embeddings/src/error.rs Defines typed embedding-generation error taxonomy.
libs/@local/graph/embeddings/package.json Adds Turborepo wiring + scripts for the new Rust crate package.
libs/@local/graph/embeddings/LICENSE.md Adds crate-level license text.
libs/@local/graph/embeddings/docs/dependency-diagram.mmd Adds dependency diagram for the new crate.
libs/@local/graph/embeddings/Cargo.toml Adds the new crate to the Rust workspace with required deps.
libs/@local/graph/api/src/rest/mod.rs Adds embedding resolution helper + embeds embedding client into REST dependencies.
libs/@local/graph/api/src/rest/entity.rs Wires embedding client into entity search handler and resolves params asynchronously.
libs/@local/graph/api/src/rest/entity_type.rs Wires embedding client into entity-type search handler and resolves params asynchronously.
libs/@local/graph/api/src/rest/entity_query_request.rs Updates entity search request schema to embedding/semanticString XOR and resolves embedding server-side.
libs/@local/graph/api/package.json Adds dependency on @rust/hash-graph-embeddings.
libs/@local/graph/api/openapi/openapi.json Regenerates OpenAPI to reflect optional embedding and new semanticString.
libs/@local/graph/api/Cargo.toml Adds Rust dependency on hash-graph-embeddings.
infra/compose/compose.yml Wires HASH_GRAPH_OPENAI_API_KEY into the graph compose service.
Cargo.toml Registers the new crate in the Rust workspace + adds reqwest-retry.
Cargo.lock Locks new Rust dependencies (e.g. reqwest-retry, retry-policies).
apps/hash-graph/src/subcommand/server.rs Adds HASH_GRAPH_OPENAI_API_KEY config and initializes embedding client at startup.
apps/hash-graph/package.json Adds dependency on @rust/hash-graph-embeddings.
apps/hash-graph/Cargo.toml Adds Rust dependency on hash-graph-embeddings.
AGENTS.md Documents mise run sync:turborepo for Rust crate wiring changes.
.clippy.toml Adds OpenAI to doc-valid-idents.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/@local/graph/embeddings/src/lib.rs
Comment thread libs/@local/graph/api/src/rest/mod.rs
Copilot AI review requested due to automatic review settings June 30, 2026 10:42
@TimDiekmann TimDiekmann force-pushed the t/be-622-move-semantic-search-embedding-generation-into-graph branch from dcb0ee2 to a8b9f33 Compare June 30, 2026 10:43
@codspeed-hq

codspeed-hq Bot commented Jun 30, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 80 untouched benchmarks


Comparing t/be-622-move-semantic-search-embedding-generation-into-graph (3b5c957) with main (7f74e1c)

Open in CodSpeed

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 25 out of 27 changed files in this pull request and generated 5 comments.

Comment thread libs/@local/graph/api/src/rest/mod.rs Outdated
Comment thread infra/compose/compose.yml
Comment thread libs/@local/graph/api/src/rest/entity_query_request.rs
Comment thread libs/@local/graph/api/src/rest/entity_type.rs
Comment thread libs/@local/graph/embeddings/src/lib.rs
Copilot AI review requested due to automatic review settings June 30, 2026 10:47
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.56%. Comparing base (b8971f3) to head (3b5c957).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
libs/@local/graph/api/src/rest/mod.rs 0.00% 40 Missing ⚠️
libs/@local/graph/api/src/rest/entity_type.rs 0.00% 13 Missing ⚠️
.../@local/graph/api/src/rest/entity_query_request.rs 0.00% 10 Missing ⚠️
libs/@local/graph/api/src/rest/entity.rs 0.00% 6 Missing ⚠️
libs/@local/graph/types/src/embedding.rs 0.00% 6 Missing ⚠️
...ibs/@local/graph/sdk/typescript/src/entity-type.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8920      +/-   ##
==========================================
- Coverage   59.57%   59.56%   -0.02%     
==========================================
  Files        1366     1365       -1     
  Lines      132760   132837      +77     
  Branches     6045     6042       -3     
==========================================
+ Hits        79094    79121      +27     
- Misses      52732    52782      +50     
  Partials      934      934              
Flag Coverage Δ
apps.hash-ai-worker-ts 1.39% <ø> (ø)
apps.hash-api 6.39% <ø> (ø)
blockprotocol.type-system 40.84% <ø> (ø)
local.claude-hooks 0.00% <ø> (ø)
local.harpc-client 51.49% <ø> (ø)
local.hash-backend-utils 2.81% <ø> (ø)
local.hash-graph-sdk 10.02% <0.00%> (+0.02%) ⬆️
local.hash-isomorphic-utils 0.18% <ø> (ø)
rust.antsi 0.00% <ø> (ø)
rust.error-stack 90.87% <ø> (ø)
rust.harpc-codec 84.70% <ø> (ø)
rust.harpc-net 96.21% <ø> (+0.01%) ⬆️
rust.harpc-tower 67.03% <ø> (ø)
rust.harpc-types 0.00% <ø> (ø)
rust.harpc-wire-protocol 92.23% <ø> (ø)
rust.hash-codec 72.76% <ø> (ø)
rust.hash-graph-api 2.47% <0.00%> (-0.03%) ⬇️
rust.hash-graph-authorization 62.59% <ø> (+0.18%) ⬆️
rust.hash-graph-postgres-store 29.38% <ø> (ø)
rust.hash-graph-store 38.21% <ø> (ø)
rust.hash-graph-temporal-versioning 47.95% <ø> (ø)
rust.hash-graph-types 0.00% <0.00%> (ø)
rust.hash-graph-validation 83.43% <ø> (ø)
rust.hashql-ast 87.23% <ø> (ø)
rust.hashql-compiletest 28.24% <ø> (ø)
rust.hashql-core 79.60% <ø> (ø)
rust.hashql-diagnostics 72.31% <ø> (ø)
rust.hashql-eval 75.23% <ø> (ø)
rust.hashql-hir 89.06% <ø> (ø)
rust.hashql-mir 88.45% <ø> (ø)
rust.hashql-syntax-jexpr 94.04% <ø> (ø)

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.

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 25 out of 27 changed files in this pull request and generated 2 comments.

Comment thread libs/@local/graph/embeddings/src/lib.rs
Comment thread libs/@local/graph/api/src/rest/mod.rs
Add a hash-graph-embeddings crate exposing a provider-agnostic EmbeddingGenerator trait and an OpenAI-backed client (reqwest + reqwest-retry). The graph now resolves a search request's semanticString to an embedding itself, configured via HASH_GRAPH_OPENAI_API_KEY and wired in like the Temporal client, removing the Temporal roundtrip from the Node SDK search path.

The /entities/search and /entity-types/search endpoints accept embedding xor semanticString; the Node SDK searchEntities/searchEntityTypes forward semanticString directly and no longer take a temporalClient. Provider failures are classified (auth/rate-limit/outage) and mapped to appropriate HTTP statuses rather than a blanket 500, a caller-supplied embedding is validated against Embedding::DIM, and startup logs whether semantic search is enabled.

Regenerate the OpenAPI spec, document the sync:turborepo task in AGENTS.md, and wire HASH_GRAPH_OPENAI_API_KEY into the compose graph service.

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 38 out of 40 changed files in this pull request and generated 2 comments.

Comment thread libs/@local/graph/embeddings/src/openai.rs Outdated
Comment thread libs/@local/graph/embeddings/src/lib.rs
@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.3 \mathrm{ms} \pm 189 \mathrm{μs}\left({\color{lightgreen}-5.095 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.56 \mathrm{ms} \pm 26.4 \mathrm{μs}\left({\color{gray}-3.775 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1002 $$12.8 \mathrm{ms} \pm 94.8 \mathrm{μs}\left({\color{lightgreen}-10.281 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$44.4 \mathrm{ms} \pm 411 \mathrm{μs}\left({\color{gray}-1.960 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$15.6 \mathrm{ms} \pm 169 \mathrm{μs}\left({\color{gray}4.31 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1527 $$24.9 \mathrm{ms} \pm 229 \mathrm{μs}\left({\color{gray}1.06 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$28.3 \mathrm{ms} \pm 238 \mathrm{μs}\left({\color{lightgreen}-5.638 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.86 \mathrm{ms} \pm 27.2 \mathrm{μs}\left({\color{gray}-3.503 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$14.1 \mathrm{ms} \pm 126 \mathrm{μs}\left({\color{lightgreen}-8.374 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.84 \mathrm{ms} \pm 24.2 \mathrm{μs}\left({\color{gray}-1.299 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.04 \mathrm{ms} \pm 24.4 \mathrm{μs}\left({\color{gray}-1.014 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 52 $$3.44 \mathrm{ms} \pm 23.7 \mathrm{μs}\left({\color{gray}0.984 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.21 \mathrm{ms} \pm 38.0 \mathrm{μs}\left({\color{lightgreen}-5.574 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.54 \mathrm{ms} \pm 20.8 \mathrm{μs}\left({\color{gray}-3.780 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 108 $$4.16 \mathrm{ms} \pm 29.6 \mathrm{μs}\left({\color{gray}-3.313 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.48 \mathrm{ms} \pm 32.4 \mathrm{μs}\left({\color{gray}-0.555 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.50 \mathrm{ms} \pm 21.6 \mathrm{μs}\left({\color{gray}-0.127 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$4.12 \mathrm{ms} \pm 28.1 \mathrm{μs}\left({\color{gray}-1.057 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.64 \mathrm{ms} \pm 18.9 \mathrm{μs}\left({\color{gray}0.000 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.50 \mathrm{ms} \pm 11.8 \mathrm{μs}\left({\color{gray}-1.506 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 2 $$2.56 \mathrm{ms} \pm 12.9 \mathrm{μs}\left({\color{gray}-1.631 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.86 \mathrm{ms} \pm 17.8 \mathrm{μs}\left({\color{gray}-1.145 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.67 \mathrm{ms} \pm 19.0 \mathrm{μs}\left({\color{gray}1.26 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.82 \mathrm{ms} \pm 15.2 \mathrm{μs}\left({\color{gray}-0.945 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$3.04 \mathrm{ms} \pm 24.2 \mathrm{μs}\left({\color{gray}-3.516 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.75 \mathrm{ms} \pm 16.0 \mathrm{μs}\left({\color{gray}-1.907 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 26 $$3.00 \mathrm{ms} \pm 16.4 \mathrm{μs}\left({\color{gray}-2.182 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.46 \mathrm{ms} \pm 20.4 \mathrm{μs}\left({\color{gray}-1.591 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.01 \mathrm{ms} \pm 21.0 \mathrm{μs}\left({\color{gray}-0.224 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 27 $$3.29 \mathrm{ms} \pm 21.4 \mathrm{μs}\left({\color{gray}-1.502 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.45 \mathrm{ms} \pm 25.8 \mathrm{μs}\left({\color{gray}-2.107 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.95 \mathrm{ms} \pm 17.6 \mathrm{μs}\left({\color{gray}-2.462 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.30 \mathrm{ms} \pm 18.9 \mathrm{μs}\left({\color{gray}-4.356 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$42.4 \mathrm{ms} \pm 258 \mathrm{μs}\left({\color{gray}-0.849 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$32.8 \mathrm{ms} \pm 242 \mathrm{μs}\left({\color{gray}-3.169 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$35.8 \mathrm{ms} \pm 203 \mathrm{μs}\left({\color{gray}-1.313 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$31.7 \mathrm{ms} \pm 201 \mathrm{μs}\left({\color{gray}-0.622 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$42.2 \mathrm{ms} \pm 257 \mathrm{μs}\left({\color{gray}-3.929 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$49.2 \mathrm{ms} \pm 240 \mathrm{μs}\left({\color{gray}-3.865 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$40.1 \mathrm{ms} \pm 257 \mathrm{μs}\left({\color{lightgreen}-6.644 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$92.8 \mathrm{ms} \pm 660 \mathrm{μs}\left({\color{gray}-4.193 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$33.2 \mathrm{ms} \pm 191 \mathrm{μs}\left({\color{lightgreen}-5.814 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$277 \mathrm{ms} \pm 1.05 \mathrm{ms}\left({\color{lightgreen}-12.318 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$10.5 \mathrm{ms} \pm 65.2 \mathrm{μs}\left({\color{lightgreen}-9.882 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$10.9 \mathrm{ms} \pm 81.1 \mathrm{μs}\left({\color{lightgreen}-9.194 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$10.7 \mathrm{ms} \pm 68.2 \mathrm{μs}\left({\color{lightgreen}-9.066 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$10.5 \mathrm{ms} \pm 69.2 \mathrm{μs}\left({\color{lightgreen}-8.727 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$10.7 \mathrm{ms} \pm 77.7 \mathrm{μs}\left({\color{lightgreen}-9.491 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$10.6 \mathrm{ms} \pm 62.7 \mathrm{μs}\left({\color{lightgreen}-7.125 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$10.7 \mathrm{ms} \pm 76.9 \mathrm{μs}\left({\color{lightgreen}-6.374 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$10.7 \mathrm{ms} \pm 72.7 \mathrm{μs}\left({\color{lightgreen}-6.893 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$10.8 \mathrm{ms} \pm 69.4 \mathrm{μs}\left({\color{lightgreen}-9.374 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$10.6 \mathrm{ms} \pm 63.3 \mathrm{μs}\left({\color{lightgreen}-10.332 \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.4 \mathrm{ms} \pm 121 \mathrm{μs}\left({\color{gray}-2.510 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$11.2 \mathrm{ms} \pm 73.8 \mathrm{μs}\left({\color{gray}-4.946 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$11.0 \mathrm{ms} \pm 63.7 \mathrm{μs}\left({\color{gray}-3.481 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$11.1 \mathrm{ms} \pm 64.0 \mathrm{μs}\left({\color{gray}-4.966 \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 72.0 \mathrm{μs}\left({\color{gray}1.33 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$11.5 \mathrm{ms} \pm 89.0 \mathrm{μs}\left({\color{gray}0.022 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$11.1 \mathrm{ms} \pm 69.0 \mathrm{μs}\left({\color{lightgreen}-5.181 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$11.5 \mathrm{ms} \pm 91.7 \mathrm{μs}\left({\color{gray}-3.128 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$11.5 \mathrm{ms} \pm 65.5 \mathrm{μs}\left({\color{gray}-1.512 \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 $$9.02 \mathrm{ms} \pm 59.6 \mathrm{μs}\left({\color{gray}-1.089 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$62.6 \mathrm{ms} \pm 478 \mathrm{μs}\left({\color{gray}-0.713 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$110 \mathrm{ms} \pm 491 \mathrm{μs}\left({\color{lightgreen}-6.229 \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.4 \mathrm{ms} \pm 500 \mathrm{μs}\left({\color{gray}-2.521 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$76.0 \mathrm{ms} \pm 524 \mathrm{μs}\left({\color{gray}-3.276 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$82.8 \mathrm{ms} \pm 505 \mathrm{μs}\left({\color{lightgreen}-9.083 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$89.2 \mathrm{ms} \pm 609 \mathrm{μs}\left({\color{lightgreen}-7.473 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$43.9 \mathrm{ms} \pm 228 \mathrm{μs}\left({\color{lightgreen}-6.862 \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.9 \mathrm{ms} \pm 474 \mathrm{μs}\left({\color{gray}-3.607 \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.5 \mathrm{ms} \pm 358 \mathrm{μs}\left({\color{lightgreen}-5.670 \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 $$59.9 \mathrm{ms} \pm 346 \mathrm{μs}\left({\color{lightgreen}-6.127 \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 $$63.0 \mathrm{ms} \pm 479 \mathrm{μs}\left({\color{gray}-4.365 \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.7 \mathrm{ms} \pm 440 \mathrm{μs}\left({\color{gray}-3.869 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$118 \mathrm{ms} \pm 730 \mathrm{μs}\left({\color{lightgreen}-7.066 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$128 \mathrm{ms} \pm 534 \mathrm{μs}\left({\color{lightgreen}-6.057 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$18.4 \mathrm{ms} \pm 140 \mathrm{μs}\left({\color{lightgreen}-22.388 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$549 \mathrm{ms} \pm 1.32 \mathrm{ms}\left({\color{gray}-0.686 \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/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team type/legal Owned by the @legal team

Development

Successfully merging this pull request may close these issues.

3 participants