Skip to content

Conversation

TimDiekmann
Copy link
Member

@TimDiekmann TimDiekmann commented Oct 15, 2025

🌟 What is the purpose of this PR?

This PR refactors the ontology type version system to support semantic versioning with pre-release/draft versions. Previously, OntologyTypeVersion was a simple u32 wrapper representing only published versions. Now it supports draft versions with lane-based isolation, enabling parallel development workflows while maintaining proper version ordering semantics.

The new URL format supports both published versions (v/2) and draft versions (v/2-draft.lane.5), following semantic versioning conventions where published versions have higher precedence than pre-release versions with the same major version.

🔗 Related links

  • Linear issue: BE-162 (Implement pre-release parsing for OntologyTypeVersion)
  • Follow-up: BE-161 (Allow IDs for pre-release types to be stored in Postgres)

🔍 What does this change?

Core Type System Changes

  • Refactored OntologyTypeVersion structure (libs/@blockprotocol/type-system/rust/src/ontology/id/mod.rs)
    • Changed from simple u32 wrapper to struct with major: u32 and pre_release: Option<PreRelease>
    • Created PreRelease enum to support extensible pre-release types (currently only Draft variant)
    • Draft format: major-draft.lane.revision (e.g., 2-draft.abcd1234.5)
    • Lanes support dots for hierarchical naming (e.g., v1.alpha.3)
  • Implemented semantic versioning ordering (libs/@blockprotocol/type-system/rust/src/ontology/id/mod.rs)
    • Published versions have higher precedence than drafts with same major version (v/2 > v/2-draft.x.y)
    • Draft versions ordered by lane (following SemVer rules) then revision (numeric)
    • Major version takes precedence across all comparisons
    • SemVer-compliant lane comparison: numeric identifiers compared numerically, alphanumeric compared lexicographically, numeric < alphanumeric
  • Enhanced error types with structured validation (libs/@blockprotocol/type-system/rust/src/ontology/id/error.rs)
    • Added ParseOntologyTypeVersionError for version-specific errors with three variants:
      • MissingVersion - Empty version string
      • ParseVersion(String) - Invalid major version number
      • InvalidPreRelease(String, ParseDraftInfoError) - Draft format validation failures
    • Added ParseDraftInfoError for draft format validation with four variants:
      • IncorrectFormatting - Missing dot separator or empty lane
      • InvalidLane(String) - SemVer-invalid lane identifier
      • MissingRevision - Empty revision after dot
      • InvalidRevision(String, String) - Non-numeric or out-of-range revision
    • Changed ParseVersionedUrlError::InvalidVersion to use structured error types instead of strings
    • Error messages now provide detailed context about what's wrong and where

TypeScript/JavaScript Changes

Database and API Updates

  • Updated all call sites (34 files across libs/@local/graph/)
    • Changed OntologyTypeVersion::new() calls to struct initialization
    • Updated .inner() calls to .major field access
    • Modified ToSql/FromSql implementations to handle drafts (with TODO for full support)
    • Added errors for draft versions in Postgres (tracked in BE-161)

Testing Improvements

Comprehensive Rust Test Suite

Refactored existing tests to use from_str() and proper error handling:

  • Changed from OntologyTypeVersion::new() to parsing from strings
  • Updated function signatures to Result<(), Box<dyn Error>> for better error propagation
  • Enhanced error validation to test actual error message content, not just error types

Added 11 new comprehensive test functions covering all edge cases:

  1. ontology_version_parsing - Tests parsing both published (1, 42) and draft (2-draft.abcd1234.5) version strings, verifies structure and roundtrip
  2. ontology_version_roundtrip - Ensures parse → serialize → parse consistency for multiple version formats
  3. ontology_version_ordering_same_major - Tests SemVer ordering rules for same major version (published > draft, revision ordering)
  4. ontology_version_ordering_different_major - Tests major version precedence across published and draft versions
  5. ontology_version_ordering_different_lanes - Tests lane-based ordering (lexicographic comparison)
  6. ontology_version_ordering_semver_prerelease_rules - Comprehensive SemVer validation:
    • Rule 1: Numeric identifiers compared numerically (2 < 10)
    • Rule 2: Alphanumeric compared lexicographically (alpha < beta)
    • Rule 3: Numeric < alphanumeric (999 < 123abc)
    • Rule 4: Revision number comparison within same lane
  7. ontology_version_equality - Tests equality comparisons for published and draft versions
  8. draft_url_parsing - Tests full URL parsing with draft versions and roundtrip
  9. invalid_prerelease_identifiers_rejected - Tests rejection of:
    • Special characters in lane (abc,def)
    • Unicode characters in lane (🚀)
    • Validates specific error types and messages
  10. missing_lane_rejected - Tests edge case: 1-draft.123 (only revision, no lane separator)
    • Validates ParseDraftInfoError::IncorrectFormatting
  11. missing_revision_rejected - Tests edge case: 1-draft.lane. (lane present but empty revision)
    • Validates ParseDraftInfoError::MissingRevision with exact input tracking
  12. invalid_revision_rejected - Tests rejection of:
    • Non-numeric revision (lane.abc) → InvalidRevision with message validation
    • Negative revision (lane.-5) → InvalidRevision with exact value tracking
    • Overflow cases (implicit in u32 parsing)
    • All cases validate error structure and message content
  13. multiple_dots_in_lane_accepted - Tests hierarchical lanes (lane.with.dots.5, v1.alpha.3.10)
  14. draft_in_lane_accepted - Tests lane names containing "draft" (my-draft.2)
  15. build_is_rejected - Tests rejection of SemVer build metadata:
    • In draft versions (1-draft.lane.1+build.123)
    • In published versions (1+build.123)
    • In ambiguous formats (1+build-draft.123)

Key testing improvements:

  • All error tests now validate the exact error variant, input tracking, and error message content
  • Tests use pattern matching to ensure structured errors contain expected data
  • Edge cases comprehensively covered: missing components, invalid formats, boundary conditions
  • SemVer compliance thoroughly validated across all comparison rules

TypeScript Tests

Added TypeScript tests (libs/@blockprotocol/type-system/typescript/test/url.test.ts)

  • Draft URL validation tests
  • Version comparison tests
  • Helper function tests
  • Error case validation
  • Snapshot tests updated for new error format

Integration Coverage

  • All existing integration tests pass with updated version handling
  • 34 files updated across graph API, store, and benchmark code

⚠️ Known issues

  • Draft versions cannot be stored in Postgres yet: The ToSql implementation for OntologyTypeVersion includes an error (via todo!()) when attempting to serialize draft versions. This is intentional - draft support in the database layer is tracked separately in BE-161.
  • Error type incompatibility: The error structure changed from simple strings to nested structured errors. This may affect error handling code that pattern matches on the old format.

🐾 Next steps

  • BE-161: Implement Postgres storage for draft versions (requires schema changes and migration strategy)
  • Consider error-stack migration: Multiple TODOs added indicating we should migrate to error-stack for better error handling (tracked in BE-160 subtask)

🛡 What tests cover this?

Rust Tests (in libs/@blockprotocol/type-system/rust/src/ontology/id/mod.rs)

Core functionality tests:

  • ontology_version_parsing - Parsing published and draft versions
  • ontology_version_roundtrip - Serialize/deserialize consistency
  • ontology_version_ordering_same_major - SemVer ordering (same major)
  • ontology_version_ordering_different_major - Major version precedence
  • ontology_version_ordering_different_lanes - Lane-based ordering
  • ontology_version_ordering_semver_prerelease_rules - Complete SemVer compliance validation
  • ontology_version_equality - Equality comparisons
  • draft_url_parsing - Full URL parsing with draft versions

Error validation tests:

  • invalid_prerelease_identifiers_rejected - Special characters and Unicode rejection
  • missing_lane_rejected - Edge case: only revision without lane (1-draft.123)
  • missing_revision_rejected - Edge case: lane without revision (1-draft.lane.)
  • invalid_revision_rejected - Non-numeric (abc), negative (-5), and overflow cases

Edge case tests:

  • multiple_dots_in_lane_accepted - Hierarchical lane names (lane.with.dots)
  • draft_in_lane_accepted - Lane names containing "draft"
  • build_is_rejected - SemVer build metadata rejection

Updated existing tests:

  • base_url_test - Updated for new error types
  • versioned_url_test - Updated for structured errors
  • record_id_conversions - Updated for new structure

TypeScript Tests (in libs/@blockprotocol/type-system/typescript/test/url.test.ts)

  • Draft URL validation tests
  • Version comparison tests covering all SemVer ordering scenarios
  • Helper function tests (isDraftVersion, extractMajorVersion, etc.)
  • Error message validation for invalid draft formats
  • Snapshot tests updated for new error format

Integration Coverage

  • All existing integration tests pass with updated version handling
  • 34 files updated across graph API, store, and benchmark code

❓ How to test this?

Test Published Versions (No Behavior Change)

  1. Checkout the branch
  2. Run Rust tests: cargo nextest run --package type-system
  3. Run TypeScript tests: turbo run test --filter '@blockprotocol/type-system'
  4. Verify existing functionality unchanged

Test Draft Version Parsing

# Test Rust parsing
cargo test --package type-system ontology_version_parsing

# Test TypeScript validation
turbo run test --filter '@blockprotocol/type-system' -- url.test.ts

Test Version Ordering

  1. Run ordering tests:
  2. Verify SemVer semantics:
    • Published > Draft (same major): v/2 > v/2-draft.x.y
    • Major version precedence: v/3 > v/2 > v/1
    • Draft ordering: v/2-draft.a.1 < v/2-draft.b.1 < v/2-draft.b.2

Test Error Handling and Edge Cases

# Run all error validation tests
cargo test --package type-system rejected

# Test specific edge cases
cargo test --package type-system missing_lane_rejected
cargo test --package type-system missing_revision_rejected
cargo test --package type-system invalid_revision_rejected

Verify error messages provide detailed context:

  • Missing lane: 1-draft.123IncorrectFormatting
  • Missing revision: 1-draft.lane.MissingRevision
  • Invalid revision: 1-draft.lane.abcInvalidRevision("abc", "invalid digit...")
  • Negative revision: 2-draft.lane.-5InvalidRevision("-5", "invalid digit...")

Test Database Limitations (Expected Failure)

Attempting to serialize draft version to Postgres should panic with TODO message:

let draft = OntologyTypeVersion::from_str("2-draft.lane.5")?;
// This will panic with: "not yet implemented: https://linear.app/hash/issue/BE-161/..."
draft.to_sql(...)?;

📹 Demo

No visual demo needed - this is infrastructure work for the type system. The changes are visible in:

  1. Rust code - New types and parsing logic
  2. Test output - Comprehensive test coverage showing all scenarios
  3. Error messages - Improved structured error reporting with detailed context

Example of new URL format support:

Published:  https://example.com/person/v/2
Draft:      https://example.com/person/v/2-draft.abcd1234.5
            ├─ major: 2
            ├─ pre_release.lane: "abcd1234"
            └─ pre_release.revision: 5

Ordering:
  v/1 < v/2-draft.lane.5 < v/2 < v/3

SemVer Lane Comparison:
  v/1-draft.2.1 < v/1-draft.10.1       (numeric: 2 < 10)
  v/1-draft.999.1 < v/1-draft.abc.1    (numeric < alphanumeric)
  v/1-draft.alpha.1 < v/1-draft.beta.1 (lexicographic)

Hierarchical Lanes:
  v/1-draft.lane.with.dots.5
  v/2-draft.v1.alpha.3.10

@github-actions github-actions bot added area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/tests New or updated tests labels Oct 15, 2025
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@TimDiekmann TimDiekmann self-assigned this Oct 15, 2025
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

❌ Patch coverage is 35.84906% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.12%. Comparing base (bbbbc76) to head (51d72cc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...kprotocol/type-system/typescript/src/native/url.ts 72.41% 3 Missing and 5 partials ⚠️
...uthorization/src/policies/cedar/expression_tree.rs 0.00% 6 Missing ⚠️
libs/@local/graph/store/src/filter/mod.rs 53.84% 6 Missing ⚠️
...ocal/graph/store/src/subgraph/identifier/vertex.rs 0.00% 6 Missing ⚠️
...i/src/rest/utoipa_typedef/subgraph/vertices/mod.rs 0.00% 4 Missing ⚠️
...rc/rest/utoipa_typedef/subgraph/vertices/vertex.rs 0.00% 4 Missing ⚠️
...s-store/src/snapshot/ontology/data_type/channel.rs 0.00% 4 Missing ⚠️
...store/src/snapshot/ontology/entity_type/channel.rs 0.00% 4 Missing ⚠️
libs/@local/graph/store/src/filter/parameter.rs 20.00% 4 Missing ⚠️
libs/@local/graph/store/src/subgraph/record.rs 0.00% 3 Missing ⚠️
... and 10 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7872      +/-   ##
==========================================
- Coverage   55.13%   55.12%   -0.02%     
==========================================
  Files        1103     1103              
  Lines       98529    98664     +135     
  Branches     4575     4589      +14     
==========================================
+ Hits        54325    54387      +62     
- Misses      43585    43653      +68     
- Partials      619      624       +5     
Flag Coverage Δ
apps.hash-ai-worker-ts 1.32% <ø> (ø)
apps.hash-api 0.00% <ø> (ø)
blockprotocol.type-system 40.84% <72.41%> (+4.98%) ⬆️
local.hash-backend-utils 4.06% <ø> (ø)
local.hash-graph-sdk 10.88% <ø> (ø)
local.hash-isomorphic-utils 0.00% <ø> (ø)
rust.hash-graph-api 2.93% <22.22%> (+0.08%) ⬆️
rust.hash-graph-authorization 62.50% <0.00%> (-0.09%) ⬇️
rust.hash-graph-postgres-store 19.66% <33.33%> (+<0.01%) ⬆️
rust.hash-graph-store 31.00% <25.00%> (-0.66%) ⬇️
rust.hash-graph-types 0.00% <ø> (ø)
rust.hash-graph-validation 83.29% <ø> (ø)
rust.hashql-compiletest 53.03% <ø> (ø)
rust.hashql-eval 70.23% <ø> (+2.15%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

…d enhance documentation for pre-release versioning
Copy link
Contributor

graphite-app bot commented Oct 15, 2025

Graphite Automations

"Request Rust reviewers once CI passes" took an action on this PR • (10/15/25)

1 reviewer was added to this PR based on Tim Diekmann's automation.

"Request backend reviewers once CI passes" took an action on this PR • (10/15/25)

1 reviewer was added to this PR based on Tim Diekmann's automation.

@vercel vercel bot temporarily deployed to Preview – hashdotdesign October 16, 2025 11:51 Inactive
@TimDiekmann TimDiekmann force-pushed the t/be-162-implement-pre-release-parsing-for-ontologytypeversion branch from 685fdfb to 680f50c Compare October 16, 2025 12:11
indietyp
indietyp previously approved these changes Oct 16, 2025
…action and add test for draft in lane identifier
@vercel vercel bot temporarily deployed to Preview – hashdotdesign October 16, 2025 12:20 Inactive
@github-actions github-actions bot dismissed indietyp’s stale review October 16, 2025 12:20

Your organization requires reapproval when changes are made, so Graphite has dismissed approvals. See the output of git range-diff at https://github.com/hashintel/hash/actions/runs/18561030442

@TimDiekmann TimDiekmann requested a review from indietyp October 16, 2025 12:21
@vercel vercel bot temporarily deployed to Preview – hashdotdesign October 16, 2025 12:29 Inactive
@vercel vercel bot temporarily deployed to Preview – hashdotdesign October 16, 2025 12:31 Inactive
@vercel vercel bot temporarily deployed to Preview – hashdotdesign October 16, 2025 12:41 Inactive
@vercel vercel bot temporarily deployed to Preview – hashdotdesign October 16, 2025 12:49 Inactive
Copy link
Member

@indietyp indietyp left a comment

Choose a reason for hiding this comment

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

thank you 🎉

@TimDiekmann TimDiekmann added this pull request to the merge queue Oct 16, 2025
Merged via the queue into main with commit bf6dfb1 Oct 16, 2025
114 of 115 checks passed
@TimDiekmann TimDiekmann deleted the t/be-162-implement-pre-release-parsing-for-ontologytypeversion branch October 16, 2025 14:27
Copy link
Contributor

Benchmark results

@rust/hash-graph-benches – Integrations

policy_resolution_extra_large

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 10002 $$97.1 \mathrm{ms} \pm 578 \mathrm{μs}\left({\color{gray}-1.036 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$5.44 \mathrm{ms} \pm 27.8 \mathrm{μs}\left({\color{gray}-2.864 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 5001 $$77.1 \mathrm{ms} \pm 534 \mathrm{μs}\left({\color{gray}-2.247 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 27604 $$292 \mathrm{ms} \pm 1.30 \mathrm{ms}\left({\color{gray}1.48 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$20.5 \mathrm{ms} \pm 185 \mathrm{μs}\left({\color{gray}-4.369 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 13450 $$229 \mathrm{ms} \pm 900 \mathrm{μs}\left({\color{gray}0.430 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 11308 $$456 \mathrm{ms} \pm 2.24 \mathrm{ms}\left({\color{red}161 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$6.41 \mathrm{ms} \pm 36.6 \mathrm{μs}\left({\color{gray}-1.430 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 5628 $$67.9 \mathrm{ms} \pm 3.93 \mathrm{ms}\left({\color{lightgreen}-24.085 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_large

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2002 $$28.8 \mathrm{ms} \pm 164 \mathrm{μs}\left({\color{gray}0.156 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.46 \mathrm{ms} \pm 14.2 \mathrm{μs}\left({\color{gray}0.413 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$13.0 \mathrm{ms} \pm 71.9 \mathrm{μs}\left({\color{gray}-0.784 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$38.4 \mathrm{ms} \pm 315 \mathrm{μs}\left({\color{gray}-0.300 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$13.9 \mathrm{ms} \pm 58.4 \mathrm{μs}\left({\color{gray}2.46 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$24.4 \mathrm{ms} \pm 149 \mathrm{μs}\left({\color{gray}0.687 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$28.6 \mathrm{ms} \pm 140 \mathrm{μs}\left({\color{lightgreen}-40.208 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.75 \mathrm{ms} \pm 16.5 \mathrm{μs}\left({\color{gray}0.428 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$11.9 \mathrm{ms} \pm 79.2 \mathrm{μs}\left({\color{lightgreen}-39.836 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.67 \mathrm{ms} \pm 19.7 \mathrm{μs}\left({\color{lightgreen}-6.199 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.04 \mathrm{ms} \pm 10.7 \mathrm{μs}\left({\color{gray}0.500 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.15 \mathrm{ms} \pm 13.8 \mathrm{μs}\left({\color{lightgreen}-8.005 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.32 \mathrm{ms} \pm 24.5 \mathrm{μs}\left({\color{gray}-1.238 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.59 \mathrm{ms} \pm 16.8 \mathrm{μs}\left({\color{gray}-1.237 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$4.20 \mathrm{ms} \pm 22.5 \mathrm{μs}\left({\color{gray}-1.091 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.35 \mathrm{ms} \pm 32.0 \mathrm{μs}\left({\color{lightgreen}-5.678 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.27 \mathrm{ms} \pm 14.8 \mathrm{μs}\left({\color{lightgreen}-6.695 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$3.87 \mathrm{ms} \pm 19.0 \mathrm{μs}\left({\color{lightgreen}-7.516 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.58 \mathrm{ms} \pm 12.9 \mathrm{μs}\left({\color{red}9.60 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.56 \mathrm{ms} \pm 12.0 \mathrm{μs}\left({\color{red}10.9 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.64 \mathrm{ms} \pm 12.3 \mathrm{μs}\left({\color{red}8.68 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.84 \mathrm{ms} \pm 10.9 \mathrm{μs}\left({\color{red}7.58 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.72 \mathrm{ms} \pm 11.2 \mathrm{μs}\left({\color{red}10.3 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.93 \mathrm{ms} \pm 13.1 \mathrm{μs}\left({\color{red}8.04 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$3.01 \mathrm{ms} \pm 17.2 \mathrm{μs}\left({\color{red}8.48 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.67 \mathrm{ms} \pm 14.4 \mathrm{μs}\left({\color{red}9.85 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$2.87 \mathrm{ms} \pm 20.4 \mathrm{μs}\left({\color{red}11.4 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.38 \mathrm{ms} \pm 22.1 \mathrm{μs}\left({\color{red}9.15 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.90 \mathrm{ms} \pm 15.1 \mathrm{μs}\left({\color{red}8.51 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$3.14 \mathrm{ms} \pm 17.7 \mathrm{μs}\left({\color{red}8.85 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.27 \mathrm{ms} \pm 19.0 \mathrm{μs}\left({\color{red}8.29 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.85 \mathrm{ms} \pm 13.1 \mathrm{μs}\left({\color{red}8.83 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.20 \mathrm{ms} \pm 20.4 \mathrm{μs}\left({\color{red}11.6 \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 $$30.2 \mathrm{ms} \pm 276 \mathrm{μs}\left({\color{gray}-1.702 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$30.7 \mathrm{ms} \pm 274 \mathrm{μs}\left({\color{gray}1.04 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$30.0 \mathrm{ms} \pm 299 \mathrm{μs}\left({\color{gray}-3.417 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$30.9 \mathrm{ms} \pm 290 \mathrm{μs}\left({\color{gray}0.625 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$30.4 \mathrm{ms} \pm 272 \mathrm{μs}\left({\color{gray}-0.496 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$31.7 \mathrm{ms} \pm 289 \mathrm{μs}\left({\color{gray}1.58 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$31.1 \mathrm{ms} \pm 255 \mathrm{μs}\left({\color{gray}2.67 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$30.5 \mathrm{ms} \pm 313 \mathrm{μs}\left({\color{gray}1.31 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$30.9 \mathrm{ms} \pm 259 \mathrm{μs}\left({\color{gray}0.234 \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.22 \mathrm{ms} \pm 31.9 \mathrm{μs}\left({\color{gray}0.273 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$58.4 \mathrm{ms} \pm 404 \mathrm{μs}\left({\color{gray}3.25 \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 471 \mathrm{μs}\left({\color{gray}0.481 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$61.8 \mathrm{ms} \pm 238 \mathrm{μs}\left({\color{gray}0.320 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$70.8 \mathrm{ms} \pm 372 \mathrm{μs}\left({\color{gray}-0.796 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$79.4 \mathrm{ms} \pm 290 \mathrm{μs}\left({\color{gray}-0.339 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$87.3 \mathrm{ms} \pm 318 \mathrm{μs}\left({\color{gray}0.313 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$51.6 \mathrm{ms} \pm 356 \mathrm{μs}\left({\color{gray}1.53 \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 $$78.5 \mathrm{ms} \pm 333 \mathrm{μs}\left({\color{gray}-1.793 \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 $$55.9 \mathrm{ms} \pm 283 \mathrm{μs}\left({\color{gray}1.76 \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 $$65.3 \mathrm{ms} \pm 263 \mathrm{μs}\left({\color{gray}-0.259 \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 $$66.5 \mathrm{ms} \pm 272 \mathrm{μs}\left({\color{gray}-0.225 \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 $$66.6 \mathrm{ms} \pm 277 \mathrm{μs}\left({\color{gray}-1.817 \mathrm{\%}}\right) $$

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 1 entities $$48.8 \mathrm{ms} \pm 201 \mathrm{μs}\left({\color{gray}-1.984 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$58.7 \mathrm{ms} \pm 452 \mathrm{μs}\left({\color{gray}-3.185 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$54.0 \mathrm{ms} \pm 292 \mathrm{μs}\left({\color{gray}-0.003 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$52.8 \mathrm{ms} \pm 415 \mathrm{μs}\left({\color{gray}0.574 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$59.1 \mathrm{ms} \pm 368 \mathrm{μs}\left({\color{gray}0.318 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 1 entities $$49.8 \mathrm{ms} \pm 239 \mathrm{μs}\left({\color{gray}1.66 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$59.0 \mathrm{ms} \pm 436 \mathrm{μs}\left({\color{gray}0.621 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$54.1 \mathrm{ms} \pm 194 \mathrm{μs}\left({\color{gray}-0.013 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$52.1 \mathrm{ms} \pm 221 \mathrm{μs}\left({\color{gray}-0.437 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$74.5 \mathrm{ms} \pm 373 \mathrm{μs}\left({\color{gray}1.30 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$15.1 \mathrm{ms} \pm 53.7 \mathrm{μs}\left({\color{gray}4.51 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$14.5 \mathrm{ms} \pm 59.1 \mathrm{μs}\left({\color{gray}0.106 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$14.8 \mathrm{ms} \pm 86.9 \mathrm{μs}\left({\color{gray}2.06 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$15.1 \mathrm{ms} \pm 88.9 \mathrm{μs}\left({\color{gray}0.288 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$23.1 \mathrm{ms} \pm 159 \mathrm{μs}\left({\color{gray}1.88 \mathrm{\%}}\right) $$ Flame Graph

scenarios

Function Value Mean Flame graphs
full_test query-limited $$134 \mathrm{ms} \pm 537 \mathrm{μs}\left({\color{gray}-3.170 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$133 \mathrm{ms} \pm 464 \mathrm{μs}\left({\color{gray}-1.374 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$42.8 \mathrm{ms} \pm 227 \mathrm{μs}\left({\color{lightgreen}-59.432 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$576 \mathrm{ms} \pm 1.12 \mathrm{ms}\left({\color{lightgreen}-5.179 \mathrm{\%}}\right) $$ Flame Graph

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

Labels

area/deps Relates to third-party dependencies (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

Development

Successfully merging this pull request may close these issues.

2 participants