Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H-2961: Introduce a ClosedDataType schema type and store it in the database #4692

Conversation

TimDiekmann
Copy link
Member

@TimDiekmann TimDiekmann commented Jul 9, 2024

🌟 What is the purpose of this PR?

To allow inheritance, the closed data type needs to be created.

🔍 What does this change?

  • Add ClosedDataType
  • Extend database layout to store closed schemas
    • Add (empty) edges tables for allOf and oneOf
  • Create closed schema in
    • creation method
    • updating method
    • snapshot restoration

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

@github-actions github-actions bot added area/apps > hash* Affects HASH (a `hash-*` app) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/apps area/apps > hash-graph labels Jul 9, 2024
Base automatically changed from t/h-2975-make-all-data-type-constraints-strongly-typed to main July 9, 2024 12:35
@TimDiekmann TimDiekmann force-pushed the t/h-2961-introduce-a-closeddatatype-schema-type-and-store-it-in-the branch from 5036b81 to ca39a14 Compare July 9, 2024 17:17
CiaranMn
CiaranMn previously approved these changes Jul 11, 2024
@github-actions github-actions bot added area/apps > hash-api Affects the HASH API (app) type/eng > frontend Owned by the @frontend team area/tests New or updated tests area/tests > integration New or updated integration tests labels Jul 11, 2024
Copy link

codecov bot commented Jul 11, 2024

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 19.95%. Comparing base (427af2a) to head (b782147).
Report is 717 commits behind head on main.

Files with missing lines Patch % Lines
...s/src/activities/shared/dereference-entity-type.ts 0.00% 4 Missing ⚠️
...raph-is-initialized/migrate-ontology-types/util.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4692      +/-   ##
==========================================
- Coverage   20.08%   19.95%   -0.14%     
==========================================
  Files         458      459       +1     
  Lines       15762    15858      +96     
  Branches     2392     2426      +34     
==========================================
- Hits         3166     3164       -2     
- Misses      12555    12653      +98     
  Partials       41       41              
Flag Coverage Δ
apps.hash-ai-worker-ts 1.48% <0.00%> (-0.03%) ⬇️
apps.hash-api 0.00% <0.00%> (ø)
blockprotocol.type-system 47.41% <ø> (ø)
local.hash-backend-utils 4.25% <ø> (ø)
local.hash-isomorphic-utils 0.00% <ø> (ø)
local.hash-subgraph 24.87% <ø> (ø)

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.

Copy link
Contributor

Benchmark results

@rust/graph-benches – Integrations

representative_read_multiple_entities

Function Value Mean Flame graphs
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$1.96 \mathrm{s} \pm 7.14 \mathrm{ms}\left({\color{gray}0.430 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$1.02 \mathrm{s} \pm 6.98 \mathrm{ms}\left({\color{gray}-0.283 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$1.02 \mathrm{s} \pm 4.92 \mathrm{ms}\left({\color{gray}0.462 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$38.5 \mathrm{ms} \pm 168 \mathrm{μs}\left({\color{gray}0.332 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$396 \mathrm{ms} \pm 1.29 \mathrm{ms}\left({\color{gray}0.733 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$75.1 \mathrm{ms} \pm 495 \mathrm{μs}\left({\color{gray}0.893 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$2.85 \mathrm{s} \pm 6.36 \mathrm{ms}\left({\color{gray}0.419 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$977 \mathrm{ms} \pm 5.72 \mathrm{ms}\left({\color{gray}-1.541 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$998 \mathrm{ms} \pm 7.00 \mathrm{ms}\left({\color{gray}2.48 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$36.2 \mathrm{ms} \pm 228 \mathrm{μs}\left({\color{gray}0.107 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$370 \mathrm{ms} \pm 1.77 \mathrm{ms}\left({\color{gray}1.80 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$40.6 \mathrm{ms} \pm 257 \mathrm{μs}\left({\color{gray}0.211 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 100 entities $$2.03 \mathrm{ms} \pm 12.1 \mathrm{μs}\left({\color{gray}1.08 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$1.84 \mathrm{ms} \pm 8.06 \mathrm{μs}\left({\color{gray}0.661 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.84 \mathrm{ms} \pm 20.4 \mathrm{μs}\left({\color{gray}1.19 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.75 \mathrm{ms} \pm 12.6 \mathrm{μs}\left({\color{gray}-0.908 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$13.0 \mathrm{ms} \pm 159 \mathrm{μs}\left({\color{gray}0.355 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: d4e16033-c281-4cde-aa35-9085bf2e7579 $$1.42 \mathrm{ms} \pm 11.0 \mathrm{μs}\left({\color{gray}1.23 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 25 entities $$76.1 \mathrm{ms} \pm 310 \mathrm{μs}\left({\color{gray}0.019 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$24.2 \mathrm{ms} \pm 189 \mathrm{μs}\left({\color{gray}0.885 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$271 \mathrm{ms} \pm 2.34 \mathrm{ms}\left({\color{gray}-0.056 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$46.5 \mathrm{ms} \pm 2.55 \mathrm{ms}\left({\color{red}52.7 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$19.6 \mathrm{ms} \pm 82.8 \mathrm{μs}\left({\color{gray}-0.953 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 25 entities $$2.78 \mathrm{ms} \pm 68.1 \mathrm{μs}\left({\color{lightgreen}-10.575 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.87 \mathrm{ms} \pm 7.70 \mathrm{μs}\left({\color{gray}0.645 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$3.89 \mathrm{ms} \pm 15.9 \mathrm{μs}\left({\color{gray}-4.421 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$2.07 \mathrm{ms} \pm 9.08 \mathrm{μs}\left({\color{gray}-0.407 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.84 \mathrm{ms} \pm 7.08 \mathrm{μs}\left({\color{gray}-0.411 \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/playlist/v/1 $$16.1 \mathrm{ms} \pm 181 \mathrm{μs}\left({\color{gray}-0.066 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$15.3 \mathrm{ms} \pm 166 \mathrm{μs}\left({\color{gray}-2.410 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$15.2 \mathrm{ms} \pm 173 \mathrm{μs}\left({\color{gray}-3.405 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$16.6 \mathrm{ms} \pm 192 \mathrm{μs}\left({\color{red}5.05 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$17.2 \mathrm{ms} \pm 199 \mathrm{μs}\left({\color{lightgreen}-29.736 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$16.0 \mathrm{ms} \pm 186 \mathrm{μs}\left({\color{gray}-1.346 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$16.5 \mathrm{ms} \pm 169 \mathrm{μs}\left({\color{gray}3.87 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$15.5 \mathrm{ms} \pm 176 \mathrm{μs}\left({\color{gray}-4.520 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$16.3 \mathrm{ms} \pm 160 \mathrm{μs}\left({\color{gray}2.25 \mathrm{\%}}\right) $$ Flame Graph

@TimDiekmann TimDiekmann added this pull request to the merge queue Jul 12, 2024
Merged via the queue into main with commit e3c05fe Jul 12, 2024
100 of 102 checks passed
@TimDiekmann TimDiekmann deleted the t/h-2961-introduce-a-closeddatatype-schema-type-and-store-it-in-the branch July 12, 2024 10:32
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-api Affects the HASH API (app) area/apps > hash-graph area/apps area/libs Relates to first-party libraries/crates/packages (area) area/tests > integration New or updated integration tests area/tests New or updated tests type/eng > backend Owned by the @backend team type/eng > frontend Owned by the @frontend team
Development

Successfully merging this pull request may close these issues.

2 participants