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-3331: Validate all data type constraints #5165

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

TimDiekmann
Copy link
Member

🌟 What is the purpose of this PR?

Currently, we only validate the constraints on the same data type but not the parents.

🔍 What does this change?

  • Add the validation for the allOf field in data types

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

@TimDiekmann TimDiekmann self-assigned this Sep 17, 2024
@github-actions github-actions bot added area/apps > hash* Affects HASH (a `hash-*` app) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/tests New or updated tests labels Sep 17, 2024
Copy link
Contributor

Benchmark results

@rust/graph-benches – Integrations

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$47.0 \mathrm{ms} \pm 2.51 \mathrm{ms}\left({\color{red}49.3 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$276 \mathrm{ms} \pm 2.44 \mathrm{ms}\left({\color{lightgreen}-82.087 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$19.9 \mathrm{ms} \pm 116 \mathrm{μs}\left({\color{gray}-0.884 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$74.9 \mathrm{ms} \pm 520 \mathrm{μs}\left({\color{gray}1.84 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$25.1 \mathrm{ms} \pm 298 \mathrm{μs}\left({\color{gray}1.90 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$2.07 \mathrm{ms} \pm 16.7 \mathrm{μs}\left({\color{gray}3.01 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$4.17 \mathrm{ms} \pm 23.4 \mathrm{μs}\left({\color{gray}3.58 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.87 \mathrm{ms} \pm 7.80 \mathrm{μs}\left({\color{gray}-0.040 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$2.80 \mathrm{ms} \pm 86.3 \mathrm{μs}\left({\color{gray}4.41 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.91 \mathrm{ms} \pm 7.62 \mathrm{μs}\left({\color{gray}0.525 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 10 entities $$1.87 \mathrm{ms} \pm 8.98 \mathrm{μs}\left({\color{gray}-0.223 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.03 \mathrm{ms} \pm 12.0 \mathrm{μs}\left({\color{gray}-0.214 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.80 \mathrm{ms} \pm 14.7 \mathrm{μs}\left({\color{lightgreen}-21.746 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.86 \mathrm{ms} \pm 9.07 \mathrm{μs}\left({\color{gray}-0.246 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$13.2 \mathrm{ms} \pm 135 \mathrm{μs}\left({\color{gray}0.797 \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.41 \mathrm{ms} \pm 7.02 \mathrm{μs}\left({\color{gray}0.894 \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/book/v/1 $$15.9 \mathrm{ms} \pm 151 \mathrm{μs}\left({\color{gray}0.966 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$17.3 \mathrm{ms} \pm 244 \mathrm{μs}\left({\color{gray}1.55 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$16.6 \mathrm{ms} \pm 191 \mathrm{μs}\left({\color{gray}1.53 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$16.0 \mathrm{ms} \pm 193 \mathrm{μs}\left({\color{gray}-0.724 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$16.6 \mathrm{ms} \pm 248 \mathrm{μs}\left({\color{gray}4.19 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$16.0 \mathrm{ms} \pm 204 \mathrm{μs}\left({\color{gray}1.76 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$15.2 \mathrm{ms} \pm 162 \mathrm{μs}\left({\color{lightgreen}-5.107 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$15.6 \mathrm{ms} \pm 198 \mathrm{μs}\left({\color{lightgreen}-39.427 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$16.9 \mathrm{ms} \pm 234 \mathrm{μs}\left({\color{red}9.93 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$102 \mathrm{ms} \pm 700 \mathrm{μs}\left({\color{gray}0.191 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$80.5 \mathrm{ms} \pm 271 \mathrm{μs}\left({\color{gray}0.313 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$42.3 \mathrm{ms} \pm 292 \mathrm{μs}\left({\color{gray}0.099 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$90.8 \mathrm{ms} \pm 549 \mathrm{μs}\left({\color{gray}-0.704 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$94.6 \mathrm{ms} \pm 513 \mathrm{μs}\left({\color{gray}-0.639 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$109 \mathrm{ms} \pm 437 \mathrm{μs}\left({\color{gray}1.21 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$59.4 \mathrm{ms} \pm 316 \mathrm{μs}\left({\color{gray}-0.098 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$44.0 \mathrm{ms} \pm 276 \mathrm{μs}\left({\color{gray}1.06 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$39.7 \mathrm{ms} \pm 323 \mathrm{μs}\left({\color{gray}0.291 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$51.0 \mathrm{ms} \pm 371 \mathrm{μs}\left({\color{gray}1.13 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$54.8 \mathrm{ms} \pm 324 \mathrm{μs}\left({\color{gray}-0.016 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$67.4 \mathrm{ms} \pm 351 \mathrm{μs}\left({\color{gray}-0.534 \mathrm{\%}}\right) $$ Flame Graph

@TimDiekmann TimDiekmann marked this pull request as ready for review September 17, 2024 17:52
Copy link
Member

@CiaranMn CiaranMn left a comment

Choose a reason for hiding this comment

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

Looks good, one non-blocking question

@@ -60,8 +60,7 @@ X-Authenticated-User-Actor-Id: {{account_id}}
"$id": "http://localhost:3000/@alice/types/data-type/meter/v/1",
"title": "Meter",
"type": "number",
"description": "A unit of length",
"minimum": 0
Copy link
Member

Choose a reason for hiding this comment

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

Out of interest, why did these need to be removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

They should be inherited from the parent anyway. I don't use the constraint in this file, however, I think it's better practice to not repeat every constraint on child data types if not needed.

@TimDiekmann TimDiekmann added this pull request to the merge queue Sep 18, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 18, 2024
@TimDiekmann TimDiekmann added this pull request to the merge queue Sep 18, 2024
Merged via the queue into main with commit b28fe42 Sep 18, 2024
90 checks passed
@TimDiekmann TimDiekmann deleted the t/h-3331-validate-all-data-type-constraints branch September 18, 2024 10:21
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/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