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-3919: Return error instead of panic in SelectCompiler #6163

Conversation

TimDiekmann
Copy link
Member

🌟 What is the purpose of this PR?

In some very special cases the SelectCompiler panics. To avoid crashing the graph if this happens, this is changed to errors instead.

🔍 What does this change?

  • Expose a SelectComilerError instead of panics
  • Drive-by: Allow limit in more locations
  • Drive-by: Make sure the compiler correctly errors when a cursor is passed

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 requested a review from CiaranMn January 15, 2025 11:58
@TimDiekmann TimDiekmann self-assigned this Jan 15, 2025
@github-actions github-actions bot added area/deps Relates to third-party dependencies (area) 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 Jan 15, 2025
@@ -294,7 +294,7 @@ pub async fn server(args: ServerArgs) -> Result<(), Report<GraphError>> {
let mut zanzibar_client = ZanzibarClient::new(spicedb_client);
zanzibar_client.seed().await.change_context(GraphError)?;

let temporal_client_fn = async |host: Option<String>, port: u16| {
let temporal_client_fn = |host: Option<String>, port: u16| async move {
Copy link
Member Author

Choose a reason for hiding this comment

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

Drive-by: async closures are unstable, we can use the stable way

@@ -661,7 +661,7 @@ impl<'q, 's, 'p: 'q> From<GetEntitiesRequest<'q, 's, 'p>> for GetEntitiesParams<
#[tracing::instrument(
level = "info",
skip_all,
fields(actor=%actor_id, %request)
fields(actor=%actor_id)
Copy link
Member Author

Choose a reason for hiding this comment

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

Drive-by: This would include the embedding in the log, which is quite large.

CiaranMn
CiaranMn previously approved these changes Jan 15, 2025
@TimDiekmann TimDiekmann added this pull request to the merge queue Jan 15, 2025
Merged via the queue into main with commit 4d81b44 Jan 15, 2025
165 checks passed
@TimDiekmann TimDiekmann deleted the t/h-3919-return-an-error-instead-of-panic-when-trying-to-user-a-limit branch January 15, 2025 12:55
Copy link
Contributor

Benchmark results

@rust/hash-graph-benches – Integrations

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$15.6 \mathrm{ms} \pm 192 \mathrm{μs}\left({\color{lightgreen}-31.749 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$16.2 \mathrm{ms} \pm 198 \mathrm{μs}\left({\color{gray}-3.077 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$16.9 \mathrm{ms} \pm 204 \mathrm{μs}\left({\color{gray}4.98 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$15.4 \mathrm{ms} \pm 160 \mathrm{μs}\left({\color{lightgreen}-9.557 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$15.8 \mathrm{ms} \pm 187 \mathrm{μs}\left({\color{lightgreen}-6.545 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$16.1 \mathrm{ms} \pm 190 \mathrm{μs}\left({\color{gray}2.26 \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 192 \mathrm{μs}\left({\color{gray}2.26 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$16.2 \mathrm{ms} \pm 185 \mathrm{μs}\left({\color{lightgreen}-29.042 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$16.3 \mathrm{ms} \pm 165 \mathrm{μs}\left({\color{gray}-3.018 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$65.8 \mathrm{ms} \pm 217 \mathrm{μs}\left({\color{gray}0.102 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$37.8 \mathrm{ms} \pm 185 \mathrm{μs}\left({\color{gray}-0.271 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$56.7 \mathrm{ms} \pm 380 \mathrm{μs}\left({\color{gray}1.08 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$42.0 \mathrm{ms} \pm 303 \mathrm{μs}\left({\color{gray}-2.310 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$47.7 \mathrm{ms} \pm 281 \mathrm{μs}\left({\color{gray}-1.836 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$52.4 \mathrm{ms} \pm 339 \mathrm{μs}\left({\color{gray}-0.049 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$99.0 \mathrm{ms} \pm 517 \mathrm{μs}\left({\color{gray}0.300 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$37.5 \mathrm{ms} \pm 211 \mathrm{μs}\left({\color{gray}0.606 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$89.8 \mathrm{ms} \pm 567 \mathrm{μs}\left({\color{gray}0.371 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$73.2 \mathrm{ms} \pm 591 \mathrm{μs}\left({\color{gray}0.657 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$81.4 \mathrm{ms} \pm 383 \mathrm{μs}\left({\color{gray}-0.392 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$85.7 \mathrm{ms} \pm 392 \mathrm{μs}\left({\color{gray}-0.052 \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 $$2.15 \mathrm{ms} \pm 8.87 \mathrm{μs}\left({\color{gray}0.258 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$268 \mathrm{ms} \pm 2.21 \mathrm{ms}\left({\color{gray}-0.603 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$27.5 \mathrm{ms} \pm 89.7 \mathrm{μs}\left({\color{gray}0.264 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$21.1 \mathrm{ms} \pm 134 \mathrm{μs}\left({\color{gray}0.252 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$54.1 \mathrm{ms} \pm 2.56 \mathrm{ms}\left({\color{red}6.31 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$177 \mathrm{ms} \pm 692 \mathrm{μs}\left({\color{red}8.33 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$2.02 \mathrm{ms} \pm 8.39 \mathrm{μs}\left({\color{gray}0.304 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.25 \mathrm{ms} \pm 9.63 \mathrm{μs}\left({\color{red}7.00 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$2.03 \mathrm{ms} \pm 8.07 \mathrm{μs}\left({\color{gray}-0.054 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$3.01 \mathrm{ms} \pm 18.3 \mathrm{μs}\left({\color{gray}2.02 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$13.4 \mathrm{ms} \pm 44.9 \mathrm{μs}\left({\color{gray}-0.174 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$4.24 \mathrm{ms} \pm 12.0 \mathrm{μs}\left({\color{gray}0.274 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$2.04 \mathrm{ms} \pm 8.66 \mathrm{μs}\left({\color{gray}0.199 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$2.02 \mathrm{ms} \pm 8.20 \mathrm{μs}\left({\color{gray}0.131 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$2.26 \mathrm{ms} \pm 10.2 \mathrm{μs}\left({\color{red}5.29 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$3.43 \mathrm{ms} \pm 15.4 \mathrm{μs}\left({\color{gray}0.725 \mathrm{\%}}\right) $$ Flame Graph

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