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-3380, H-3381: Improve error handling and data type ID inference #5284

Merged

Conversation

TimDiekmann
Copy link
Member

🌟 What is the purpose of this PR?

We want to infer the data type if the schema is requesting exactly one possible data type and it's not abstract. Also, the errors reported from validation should include more information on what property/data type has failed to validate.

🔍 What does this change?

  • Lift constraints on data type inference:
    • All potential data type IDs must be non-abstract
    • Exactly one data type ID needs to be allowed for a property
      This should cover almost every scenario we currently encounter
  • Improve error layout and attachments on validation errors
  • A few more locations make sure that the ReportSink-bomb is defused.

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

Copy link
Contributor

Benchmark results

@rust/graph-benches – Integrations

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$55.7 \mathrm{ms} \pm 346 \mathrm{μs}\left({\color{gray}-2.916 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$50.9 \mathrm{ms} \pm 222 \mathrm{μs}\left({\color{lightgreen}-5.302 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$44.9 \mathrm{ms} \pm 186 \mathrm{μs}\left({\color{gray}-3.325 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$67.0 \mathrm{ms} \pm 437 \mathrm{μs}\left({\color{gray}0.384 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$59.7 \mathrm{ms} \pm 376 \mathrm{μs}\left({\color{gray}-2.654 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$40.8 \mathrm{ms} \pm 265 \mathrm{μs}\left({\color{gray}-4.273 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$94.1 \mathrm{ms} \pm 633 \mathrm{μs}\left({\color{gray}-0.075 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$91.9 \mathrm{ms} \pm 501 \mathrm{μs}\left({\color{gray}1.36 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$79.7 \mathrm{ms} \pm 407 \mathrm{μs}\left({\color{gray}0.713 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$107 \mathrm{ms} \pm 643 \mathrm{μs}\left({\color{gray}0.049 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$99.2 \mathrm{ms} \pm 485 \mathrm{μs}\left({\color{gray}0.377 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$42.0 \mathrm{ms} \pm 240 \mathrm{μs}\left({\color{gray}-2.380 \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/person/v/1 $$16.2 \mathrm{ms} \pm 179 \mathrm{μs}\left({\color{lightgreen}-31.521 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$16.7 \mathrm{ms} \pm 188 \mathrm{μs}\left({\color{gray}-1.140 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$15.7 \mathrm{ms} \pm 171 \mathrm{μs}\left({\color{lightgreen}-36.911 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$16.0 \mathrm{ms} \pm 182 \mathrm{μs}\left({\color{lightgreen}-9.301 \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 239 \mathrm{μs}\left({\color{gray}-4.152 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$17.1 \mathrm{ms} \pm 156 \mathrm{μs}\left({\color{red}21.0 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$16.4 \mathrm{ms} \pm 192 \mathrm{μs}\left({\color{lightgreen}-34.553 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$16.7 \mathrm{ms} \pm 202 \mathrm{μs}\left({\color{gray}-2.701 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$15.5 \mathrm{ms} \pm 211 \mathrm{μs}\left({\color{lightgreen}-13.226 \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.40 \mathrm{ms} \pm 3.33 \mathrm{μs}\left({\color{gray}-2.021 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$2.08 \mathrm{ms} \pm 8.15 \mathrm{μs}\left({\color{gray}4.92 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$2.54 \mathrm{ms} \pm 9.86 \mathrm{μs}\left({\color{gray}-4.259 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.90 \mathrm{ms} \pm 10.7 \mathrm{μs}\left({\color{gray}-0.034 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$3.78 \mathrm{ms} \pm 14.0 \mathrm{μs}\left({\color{gray}-4.578 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.89 \mathrm{ms} \pm 11.9 \mathrm{μs}\left({\color{gray}1.34 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$52.9 \mathrm{ms} \pm 187 \mathrm{μs}\left({\color{gray}1.30 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$74.2 \mathrm{ms} \pm 410 \mathrm{μs}\left({\color{gray}1.52 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$24.8 \mathrm{ms} \pm 152 \mathrm{μs}\left({\color{gray}-0.269 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$278 \mathrm{ms} \pm 2.12 \mathrm{ms}\left({\color{lightgreen}-81.478 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$19.7 \mathrm{ms} \pm 89.2 \mathrm{μs}\left({\color{gray}-0.753 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 10000 entities $$9.07 \mathrm{ms} \pm 80.2 \mathrm{μs}\left({\color{lightgreen}-28.068 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$1.88 \mathrm{ms} \pm 6.94 \mathrm{μs}\left({\color{gray}0.842 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.03 \mathrm{ms} \pm 7.31 \mathrm{μs}\left({\color{gray}-0.058 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.75 \mathrm{ms} \pm 10.2 \mathrm{μs}\left({\color{lightgreen}-19.391 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.87 \mathrm{ms} \pm 7.90 \mathrm{μs}\left({\color{gray}1.43 \mathrm{\%}}\right) $$ Flame Graph

@TimDiekmann TimDiekmann added this pull request to the merge queue Sep 30, 2024
Merged via the queue into main with commit 49a3f9c Sep 30, 2024
157 of 158 checks passed
@TimDiekmann TimDiekmann deleted the t/h-3380-improve-reported-properties-when-validation-errors branch September 30, 2024 15:57
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/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