Skip to content

BE-607: HashQL: Refactor ModuleRegistry into builder/immutable split with allocator-generic stdlib construction#8887

Open
indietyp wants to merge 12 commits into
bm/be-538-hashql-permission-system-integrationfrom
bm/be-607-hashql-remove-smallvec-from-the-standardlibrary-for-module
Open

BE-607: HashQL: Refactor ModuleRegistry into builder/immutable split with allocator-generic stdlib construction#8887
indietyp wants to merge 12 commits into
bm/be-538-hashql-permission-system-integrationfrom
bm/be-607-hashql-remove-smallvec-from-the-standardlibrary-for-module

Conversation

@indietyp

Copy link
Copy Markdown
Member

🌟 What is the purpose of this PR?

Replaces the StandardLibrary type (12.9KB on the stack due to nested SmallVec) with a flat ModuleCache backed by MaybeUninit slots and a FiniteBitSet, and restructures ModuleRegistry construction around a builder pattern (PartialModuleRegistry). Reduces stdlib construction cost by ~20% in instructions and ~60% in L1D cache misses.

🔍 What does this change?

Module cache and construction:

  • Replaced nested SmallVec<(TypeId, ModuleDef)> in StandardLibrary with a flat ModuleCache using Box<[MaybeUninit<ModuleDef>]> and FiniteBitSet<CacheId, u64> for initialization tracking
  • Split StandardLibrary into StandardLibrary (coordinator), StandardLibraryContext (passed to define methods), and ModuleCache (shared across modules)
  • Added CacheId enum with one variant per stdlib module in preorder traversal order, replacing runtime TypeId linear scan with compile-time indices
  • ModuleDef tracks emitted_len for exact output capacity when building item slices
  • Direct match in build() instead of [Option<ItemKind>; 2].flatten() for item emission
  • Reordered build() to construct children before the output slice, allowing bump allocator reclamation of intermediate allocations
  • Item slices allocated directly on the heap (bypassing InternSet) since module item slices are provably unique by ModuleId ownership

Registry restructuring:

  • Introduced PartialModuleRegistry as a mutable builder that collects modules during construction
  • ModuleRegistry is now immutable after construction, backed by a contiguous IdSlice instead of InternMap
  • Removed RwLock from the root namespace (mutable access during construction, shared reference after)
  • Added ModuleRegistry::builder() test helper and PartialModuleRegistry::insert_root_module() for tests that inject custom modules

Symbol and type cleanup:

  • Replaced all heap.intern_symbol("...") calls in stdlib modules with pre-interned sym:: constants
  • Replaced all raw string .opaque("::...") calls with sym::path:: nested constants
  • Interned::empty() for zero-generic decl! expansions and special form types
  • ModuleDef parameterized by allocator S for bump-scope 2.x support

Benchmark results (Apple Silicon, bump-scope 2.x):

Counter Before After Delta
Instructions 440.0K 351.2K -20.2%
L1D cache misses 1,213 487 -59.9%
Branch mispredictions 420 347 -17.4%
Walltime 23.49 us 19.57 us -16.7%

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

🐾 Next steps

Potential further optimizations identified but not implemented:

  • Cache primitive TypeIds (number, boolean, etc.) on TypeBuilder to avoid repeated intern round-trips
  • Hoist repeated monomorphic TypeDefs in modules like math and special_form
  • Pre-size hash maps for the finite stdlib construction
  • Batch generic declaration construction in the decl! macro

🛡 What tests cover this?

  • Existing hashql-core test suite (880 unit + 326 integration + 20 doc tests) all pass
  • The module::namespace and module::resolver tests exercise custom module construction through the new PartialModuleRegistry builder API

❓ How to test this?

  1. cargo test --package hashql-core
  2. Verify all 1226 tests pass

@vercel

vercel Bot commented Jun 19, 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 19, 2026 3:32pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Jun 19, 2026 3:32pm
petrinaut Skipped Skipped Jun 19, 2026 3:32pm

@cursor

cursor Bot commented Jun 19, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Large refactor of module resolution and stdlib registration—core compiler infrastructure—with new unsafe initialization paths and changed storage layout for all modules and items.

Overview
Module registry moves from incremental interning (InternMap, InternSet, RwLock on the root map) to PartialModuleRegistryfinish() → immutable ModuleRegistry backed by a heap IdSlice. Modules store &'heap [Item] instead of interned slices; search_by_name uses a DenseBitSet instead of a hash set; root lookup no longer takes a lock.

Standard library construction drops the large nested SmallVec / runtime TypeId cache in favor of a flat ModuleCache (MaybeUninit slots + CacheId + FiniteBitSet) and StandardLibraryContext. Each stdlib module gets a fixed CACHE_ID; define is allocator-generic and uses ModuleDef::emitted_len for exact item buffers. ModuleRegistry::new / new_in still load the stdlib via the partial builder.

API cleanup: Item::absolute_path removed in favor of absolute_path_rev (expander path formatting updated). Tests use ModuleRegistry::builder() and insert_root_module. Stdl modules switch from heap.intern_symbol / string opaques to sym:: and sym::path::; decl! uses Interned::empty() when there are no generics.

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

indietyp commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

@vercel vercel Bot temporarily deployed to Preview – petrinaut June 19, 2026 15:17 Inactive

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

Refactors HashQL’s module system and stdlib construction to reduce construction cost and memory pressure by introducing an allocator-generic stdlib module cache and a builder/immutable split for ModuleRegistry.

Changes:

  • Reworked stdlib construction around ModuleCache + CacheId (preorder indexing) and a StandardLibraryContext, replacing the prior nested SmallVec/TypeId lookup approach.
  • Introduced PartialModuleRegistry as a mutable builder and made ModuleRegistry immutable post-construction (contiguous IdSlice backing; root namespace no longer behind an RwLock).
  • Updated stdlib modules + symbol definitions to use pre-interned sym:: constants / sym::path::… constants, and adjusted resolver/namespace logic to match the new registry backing.

Reviewed changes

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

Show a summary per file
File Description
libs/@local/hashql/core/src/symbol/sym.rs Adds new sym:: and sym::path::… constants used by the refactored stdlib modules.
libs/@local/hashql/core/src/module/std_lib/mod.rs Introduces CacheId, ModuleCache, allocator-generic ModuleDef, and the new stdlib build pipeline.
libs/@local/hashql/core/src/module/std_lib/kernel/type.rs Ports kernel type module to StandardLibraryContext + ModuleCache and assigns a CacheId.
libs/@local/hashql/core/src/module/std_lib/kernel/special_form.rs Ports kernel special_form module to new context/cache and uses Interned::empty() for 0-generics.
libs/@local/hashql/core/src/module/std_lib/kernel/mod.rs Ports kernel module scaffold to new context/cache + CacheId.
libs/@local/hashql/core/src/module/std_lib/graph/types/principal/mod.rs Ports principal stdlib module to new context/cache + CacheId.
libs/@local/hashql/core/src/module/std_lib/graph/types/principal/actor_group/web.rs Updates module to request dependencies via ModuleCache and allocator-generic ModuleDef.
libs/@local/hashql/core/src/module/std_lib/graph/types/principal/actor_group/mod.rs Updates module to request dependencies via ModuleCache and allocator-generic ModuleDef.
libs/@local/hashql/core/src/module/std_lib/graph/types/ontology/mod.rs Ports ontology stdlib module to new context/cache + CacheId.
libs/@local/hashql/core/src/module/std_lib/graph/types/ontology/entity_type.rs Adds EntityType/EntityTypeMetadata stdlib types using sym:: constants and cache-based deps.
libs/@local/hashql/core/src/module/std_lib/graph/types/mod.rs Ports graph types module scaffold to new context/cache + CacheId.
libs/@local/hashql/core/src/module/std_lib/graph/types/knowledge/mod.rs Ports knowledge module scaffold to new context/cache + CacheId.
libs/@local/hashql/core/src/module/std_lib/graph/types/knowledge/entity.rs Ports the large Entity type module to new context/cache and symbol constants.
libs/@local/hashql/core/src/module/std_lib/graph/tmp.rs Ports tmp module to new context/cache and removes empty-generic interning.
libs/@local/hashql/core/src/module/std_lib/graph/temporal.rs Ports temporal module to new context/cache and allocator-generic ModuleDef.
libs/@local/hashql/core/src/module/std_lib/graph/tail.rs Ports tail module to new context/cache and cache-based dependency requests.
libs/@local/hashql/core/src/module/std_lib/graph/mod.rs Ports graph root module; defines Graph<T> type using sym::path::graph::Graph and internal marker symbol.
libs/@local/hashql/core/src/module/std_lib/graph/head.rs Ports head module to new context/cache + cache-based dependency requests.
libs/@local/hashql/core/src/module/std_lib/graph/entity.rs Ports graph entity module to new context/cache + cache-based dependency requests.
libs/@local/hashql/core/src/module/std_lib/graph/body.rs Ports body module to new context/cache + cache-based dependency requests.
libs/@local/hashql/core/src/module/std_lib/core/uuid.rs Ports uuid stdlib module to new context/cache + CacheId.
libs/@local/hashql/core/src/module/std_lib/core/url.rs Ports url stdlib module to new context/cache + CacheId.
libs/@local/hashql/core/src/module/std_lib/core/result.rs Ports result stdlib module to new context/cache + CacheId, uses sym::path::….
libs/@local/hashql/core/src/module/std_lib/core/option.rs Ports option stdlib module to new context/cache + CacheId.
libs/@local/hashql/core/src/module/std_lib/core/mod.rs Updates core module scaffold and makes func allocator-generic for new ModuleDef.
libs/@local/hashql/core/src/module/std_lib/core/math.rs Ports math intrinsic declarations to new context/cache + CacheId.
libs/@local/hashql/core/src/module/std_lib/core/json.rs Adds JsonPath/JsonPathSegment types using symbol constants + CacheId.
libs/@local/hashql/core/src/module/std_lib/core/cmp.rs Ports cmp intrinsics to new context/cache + CacheId.
libs/@local/hashql/core/src/module/std_lib/core/bool.rs Ports bool intrinsics to new context/cache + CacheId.
libs/@local/hashql/core/src/module/std_lib/core/bits.rs Ports bits intrinsics to new context/cache + CacheId.
libs/@local/hashql/core/src/module/resolver.rs Updates resolver to the new ModuleRegistry backing (IdSlice + slice iterators) and adapts tests to builder API.
libs/@local/hashql/core/src/module/namespace.rs Updates namespace import logic for immutable root and adapts tests to builder API and heap slice allocation.
libs/@local/hashql/core/src/module/mod.rs Introduces PartialModuleRegistry, makes ModuleRegistry immutable, swaps traversal visited-set to DenseBitSet, and adds test helpers.
libs/@local/hashql/core/src/module/item.rs Updates Item helpers to index into IdSlice-backed modules and adds #[must_use] annotations.
libs/@local/hashql/core/src/lib.rs Enables maybe_uninit_fill feature needed by the new MaybeUninit-based construction.

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

Comment thread libs/@local/hashql/core/src/module/mod.rs Outdated
Comment thread libs/@local/hashql/core/src/module/mod.rs
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.82946% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.46%. Comparing base (12fa94b) to head (e5e144c).

Files with missing lines Patch % Lines
libs/@local/hashql/core/src/module/mod.rs 84.33% 13 Missing ⚠️
libs/@local/hashql/core/src/module/item.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                                 Coverage Diff                                 @@
##           bm/be-538-hashql-permission-system-integration    #8887       +/-   ##
===================================================================================
+ Coverage                                           23.54%   63.46%   +39.92%     
===================================================================================
  Files                                                 551      899      +348     
  Lines                                               27759    78094    +50335     
  Branches                                             3066     4628     +1562     
===================================================================================
+ Hits                                                 6535    49565    +43030     
- Misses                                              21130    27962     +6832     
- Partials                                               94      567      +473     
Flag Coverage Δ
apps.hash-ai-worker-ts 1.39% <ø> (ø)
apps.hash-api 0.00% <ø> (ø)
local.hash-backend-utils 2.81% <ø> (ø)
local.hash-graph-sdk 9.63% <ø> (ø)
local.hash-isomorphic-utils 0.00% <ø> (ø)
rust.hash-graph-api 7.63% <ø> (ø)
rust.hash-graph-validation ?
rust.hashql-ast 89.64% <100.00%> (?)
rust.hashql-compiletest 28.40% <ø> (ø)
rust.hashql-core 79.29% <97.80%> (?)
rust.hashql-eval 82.08% <ø> (ø)
rust.hashql-hir 89.09% <ø> (?)
rust.hashql-mir 88.05% <ø> (?)
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 review requested due to automatic review settings June 19, 2026 15:24
@indietyp indietyp force-pushed the bm/be-607-hashql-remove-smallvec-from-the-standardlibrary-for-module branch from 272a5c3 to e5e144c Compare June 19, 2026 15:24
@indietyp indietyp force-pushed the bm/be-538-hashql-permission-system-integration branch from 9a2df18 to 12fa94b Compare June 19, 2026 15:24
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 19, 2026 15:24 Inactive
@codspeed-hq

codspeed-hq Bot commented Jun 19, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 12.23%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
❌ 4 regressed benchmarks
✅ 74 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
bit_matrix/dense/iter_row[64] 140.8 ns 170 ns -17.16%
pattern_match_constant 150.8 ns 180 ns -16.2%
unique[100] 25 µs 29.5 µs -15.18%
bit_matrix/dense/iter_row[200] 185.8 ns 215 ns -13.57%
runtime 58.9 ns 29.7 ns +98.13%
constant 58.9 ns 29.7 ns +98.13%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing bm/be-607-hashql-remove-smallvec-from-the-standardlibrary-for-module (e5e144c) with main (fbfcb98)1

Open in CodSpeed

Footnotes

  1. No successful run was found on bm/be-538-hashql-permission-system-integration (12fa94b) during the generation of this report, so main (fbfcb98) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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 36 out of 36 changed files in this pull request and generated 1 comment.

Comment thread libs/@local/hashql/core/src/module/mod.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.9 \mathrm{ms} \pm 205 \mathrm{μs}\left({\color{gray}0.974 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.48 \mathrm{ms} \pm 23.8 \mathrm{μs}\left({\color{gray}0.226 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$13.5 \mathrm{ms} \pm 129 \mathrm{μs}\left({\color{red}6.67 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$44.6 \mathrm{ms} \pm 442 \mathrm{μs}\left({\color{gray}1.44 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$15.0 \mathrm{ms} \pm 153 \mathrm{μs}\left({\color{gray}3.55 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$25.0 \mathrm{ms} \pm 204 \mathrm{μs}\left({\color{gray}3.26 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$28.5 \mathrm{ms} \pm 201 \mathrm{μs}\left({\color{gray}-0.647 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.86 \mathrm{ms} \pm 30.3 \mathrm{μs}\left({\color{gray}2.53 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$15.0 \mathrm{ms} \pm 114 \mathrm{μs}\left({\color{red}9.82 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.85 \mathrm{ms} \pm 24.1 \mathrm{μs}\left({\color{gray}-1.825 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.08 \mathrm{ms} \pm 20.0 \mathrm{μs}\left({\color{gray}-0.437 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.42 \mathrm{ms} \pm 22.3 \mathrm{μs}\left({\color{gray}-1.226 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.34 \mathrm{ms} \pm 45.3 \mathrm{μs}\left({\color{gray}1.30 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.60 \mathrm{ms} \pm 21.7 \mathrm{μs}\left({\color{gray}-0.054 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$4.23 \mathrm{ms} \pm 31.7 \mathrm{μs}\left({\color{gray}1.34 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.52 \mathrm{ms} \pm 32.7 \mathrm{μs}\left({\color{gray}0.994 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.52 \mathrm{ms} \pm 21.6 \mathrm{μs}\left({\color{gray}-0.352 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$4.15 \mathrm{ms} \pm 26.1 \mathrm{μs}\left({\color{gray}0.097 \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 16.4 \mathrm{μs}\left({\color{gray}0.434 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.58 \mathrm{ms} \pm 16.5 \mathrm{μs}\left({\color{gray}1.93 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.63 \mathrm{ms} \pm 18.9 \mathrm{μs}\left({\color{gray}0.976 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.90 \mathrm{ms} \pm 17.1 \mathrm{μs}\left({\color{gray}0.669 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.71 \mathrm{ms} \pm 15.1 \mathrm{μs}\left({\color{gray}1.36 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.88 \mathrm{ms} \pm 17.8 \mathrm{μs}\left({\color{gray}-0.556 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$3.07 \mathrm{ms} \pm 21.3 \mathrm{μs}\left({\color{gray}-0.491 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.80 \mathrm{ms} \pm 23.7 \mathrm{μs}\left({\color{gray}0.844 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$3.06 \mathrm{ms} \pm 20.5 \mathrm{μs}\left({\color{gray}0.721 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.51 \mathrm{ms} \pm 24.0 \mathrm{μs}\left({\color{gray}1.90 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.01 \mathrm{ms} \pm 17.4 \mathrm{μs}\left({\color{gray}0.964 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$3.35 \mathrm{ms} \pm 23.0 \mathrm{μs}\left({\color{gray}0.529 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.40 \mathrm{ms} \pm 22.9 \mathrm{μs}\left({\color{gray}0.832 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.99 \mathrm{ms} \pm 17.0 \mathrm{μs}\left({\color{gray}-0.387 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.42 \mathrm{ms} \pm 23.7 \mathrm{μs}\left({\color{gray}1.15 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$57.2 \mathrm{ms} \pm 431 \mathrm{μs}\left({\color{gray}0.942 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$47.7 \mathrm{ms} \pm 236 \mathrm{μs}\left({\color{gray}1.38 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$51.8 \mathrm{ms} \pm 324 \mathrm{μs}\left({\color{gray}-0.538 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$45.5 \mathrm{ms} \pm 258 \mathrm{μs}\left({\color{gray}0.377 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$64.7 \mathrm{ms} \pm 479 \mathrm{μs}\left({\color{gray}-0.721 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$64.0 \mathrm{ms} \pm 406 \mathrm{μs}\left({\color{gray}0.557 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$57.1 \mathrm{ms} \pm 264 \mathrm{μs}\left({\color{gray}0.521 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$106 \mathrm{ms} \pm 546 \mathrm{μs}\left({\color{gray}1.07 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$62.8 \mathrm{ms} \pm 4.33 \mathrm{ms}\left({\color{red}32.8 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$303 \mathrm{ms} \pm 1.07 \mathrm{ms}\left({\color{gray}2.14 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$20.1 \mathrm{ms} \pm 164 \mathrm{μs}\left({\color{gray}1.43 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$20.1 \mathrm{ms} \pm 109 \mathrm{μs}\left({\color{gray}-2.214 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$21.1 \mathrm{ms} \pm 137 \mathrm{μs}\left({\color{gray}2.40 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$19.8 \mathrm{ms} \pm 107 \mathrm{μs}\left({\color{gray}0.335 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$25.4 \mathrm{ms} \pm 204 \mathrm{μs}\left({\color{gray}-1.762 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$19.6 \mathrm{ms} \pm 123 \mathrm{μs}\left({\color{gray}-0.935 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$19.9 \mathrm{ms} \pm 152 \mathrm{μs}\left({\color{gray}-0.498 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$19.9 \mathrm{ms} \pm 115 \mathrm{μs}\left({\color{gray}-1.214 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$21.1 \mathrm{ms} \pm 128 \mathrm{μs}\left({\color{gray}0.314 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$28.4 \mathrm{ms} \pm 301 \mathrm{μs}\left({\color{gray}3.71 \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 $$36.3 \mathrm{ms} \pm 349 \mathrm{μs}\left({\color{gray}-0.243 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$35.6 \mathrm{ms} \pm 265 \mathrm{μs}\left({\color{gray}-0.275 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$35.7 \mathrm{ms} \pm 351 \mathrm{μs}\left({\color{gray}3.57 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$36.2 \mathrm{ms} \pm 328 \mathrm{μs}\left({\color{gray}3.33 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$36.1 \mathrm{ms} \pm 309 \mathrm{μs}\left({\color{gray}-1.003 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$36.4 \mathrm{ms} \pm 362 \mathrm{μs}\left({\color{gray}-0.543 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$35.4 \mathrm{ms} \pm 304 \mathrm{μs}\left({\color{gray}-2.281 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$36.6 \mathrm{ms} \pm 313 \mathrm{μs}\left({\color{gray}-0.598 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$35.2 \mathrm{ms} \pm 384 \mathrm{μs}\left({\color{gray}0.077 \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.81 \mathrm{ms} \pm 51.7 \mathrm{μs}\left({\color{gray}-0.688 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$95.3 \mathrm{ms} \pm 641 \mathrm{μs}\left({\color{gray}0.003 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$153 \mathrm{ms} \pm 613 \mathrm{μs}\left({\color{gray}2.57 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$102 \mathrm{ms} \pm 559 \mathrm{μs}\left({\color{gray}-0.497 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$114 \mathrm{ms} \pm 823 \mathrm{μs}\left({\color{gray}-0.356 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$122 \mathrm{ms} \pm 562 \mathrm{μs}\left({\color{gray}2.21 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$133 \mathrm{ms} \pm 601 \mathrm{μs}\left({\color{gray}3.48 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$108 \mathrm{ms} \pm 694 \mathrm{μs}\left({\color{gray}3.27 \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 $$137 \mathrm{ms} \pm 929 \mathrm{μs}\left({\color{gray}1.27 \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 $$115 \mathrm{ms} \pm 725 \mathrm{μs}\left({\color{gray}3.19 \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 $$125 \mathrm{ms} \pm 821 \mathrm{μs}\left({\color{gray}2.45 \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 $$124 \mathrm{ms} \pm 769 \mathrm{μs}\left({\color{gray}-0.942 \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 $$123 \mathrm{ms} \pm 710 \mathrm{μs}\left({\color{gray}-0.122 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$186 \mathrm{ms} \pm 1.11 \mathrm{ms}\left({\color{gray}-1.140 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$151 \mathrm{ms} \pm 655 \mathrm{μs}\left({\color{gray}-1.524 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$41.9 \mathrm{ms} \pm 280 \mathrm{μs}\left({\color{gray}-0.990 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$561 \mathrm{ms} \pm 1.29 \mathrm{ms}\left({\color{gray}0.518 \mathrm{\%}}\right) $$ Flame Graph

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

Labels

area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

2 participants