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-3500: harpc: Remove the ErrorEncoder and ErrorDecoder traits #5428

Merged
merged 5 commits into from
Oct 21, 2024

Conversation

indietyp
Copy link
Member

🌟 What is the purpose of this PR?

This removes the ErrorEncoder and ErrorDecoder from harpc, they are only used on the lower level, indicating lower level errors, such as when a service couldn't be found.

Response level errors are still retained, as they are encoded via the Encoder and Decoder traits.

Note: we might want to explore in the future, if we can't lower procedure level errors into network errors as well. This would enable us to have error codes, tho we would need to separate again between errors that can be encoded and decoded and "plain" errors that are returned on the network level. I think that the split this PR introduces is quite the improvement over the last approach.

Note 2: This PR introduces a way that enables us to change the encoding and decoding transparently - I could imagine implementing the first note, simply by requesting an erased_serde::Serialize for the details and then returning {"message": ..., "details": ...}, but that's something for the future if we ever decide we need it or it's beneficial.

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:

  • affected the execution graph, and the turbo.json's have been updated to reflect this

@github-actions github-actions bot added 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 labels Oct 20, 2024
@vilkinsons vilkinsons changed the title harpc: remove the ErrorEncoder and ErrorDecoder H-3500: harpc: Remove the ErrorEncoder and ErrorDecoder Oct 20, 2024
Copy link
Contributor

Benchmark results

@rust/graph-benches – Integrations

representative_read_entity_type

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

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$2.00 \mathrm{ms} \pm 8.39 \mathrm{μs}\left({\color{gray}-1.860 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$4.05 \mathrm{ms} \pm 17.4 \mathrm{μs}\left({\color{gray}0.509 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.85 \mathrm{ms} \pm 11.4 \mathrm{μs}\left({\color{gray}-0.298 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.87 \mathrm{ms} \pm 12.6 \mathrm{μs}\left({\color{gray}-0.982 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$2.48 \mathrm{ms} \pm 16.6 \mathrm{μs}\left({\color{gray}-1.646 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 10 entities $$1.83 \mathrm{ms} \pm 6.93 \mathrm{μs}\left({\color{gray}-0.880 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$3.03 \mathrm{ms} \pm 39.3 \mathrm{μs}\left({\color{gray}2.75 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.86 \mathrm{ms} \pm 5.71 \mathrm{μs}\left({\color{gray}-0.312 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$12.2 \mathrm{ms} \pm 123 \mathrm{μs}\left({\color{red}38.2 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.01 \mathrm{ms} \pm 6.94 \mathrm{μs}\left({\color{gray}0.355 \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 $$66.1 \mathrm{ms} \pm 410 \mathrm{μs}\left({\color{gray}-0.271 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$52.4 \mathrm{ms} \pm 264 \mathrm{μs}\left({\color{gray}-0.210 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$37.8 \mathrm{ms} \pm 290 \mathrm{μs}\left({\color{gray}-1.556 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$48.7 \mathrm{ms} \pm 342 \mathrm{μs}\left({\color{gray}0.496 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$42.1 \mathrm{ms} \pm 353 \mathrm{μs}\left({\color{gray}0.016 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$57.1 \mathrm{ms} \pm 395 \mathrm{μs}\left({\color{gray}0.512 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$106 \mathrm{ms} \pm 922 \mathrm{μs}\left({\color{gray}0.721 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$91.8 \mathrm{ms} \pm 350 \mathrm{μs}\left({\color{gray}-0.103 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$40.1 \mathrm{ms} \pm 286 \mathrm{μs}\left({\color{gray}-1.553 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$87.8 \mathrm{ms} \pm 610 \mathrm{μs}\left({\color{gray}0.602 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$77.1 \mathrm{ms} \pm 469 \mathrm{μs}\left({\color{gray}-0.390 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$96.6 \mathrm{ms} \pm 488 \mathrm{μs}\left({\color{gray}0.891 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$53.1 \mathrm{ms} \pm 156 \mathrm{μs}\left({\color{red}14.1 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$276 \mathrm{ms} \pm 1.53 \mathrm{ms}\left({\color{gray}2.36 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$19.8 \mathrm{ms} \pm 141 \mathrm{μs}\left({\color{gray}-0.260 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$24.7 \mathrm{ms} \pm 89.9 \mathrm{μs}\left({\color{gray}0.555 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$72.6 \mathrm{ms} \pm 478 \mathrm{μs}\left({\color{gray}1.84 \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/song/v/1 $$15.8 \mathrm{ms} \pm 214 \mathrm{μs}\left({\color{gray}4.86 \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 172 \mathrm{μs}\left({\color{gray}0.769 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$15.5 \mathrm{ms} \pm 174 \mathrm{μs}\left({\color{gray}-2.809 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$16.1 \mathrm{ms} \pm 174 \mathrm{μs}\left({\color{red}6.52 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$15.3 \mathrm{ms} \pm 158 \mathrm{μs}\left({\color{lightgreen}-14.550 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$15.5 \mathrm{ms} \pm 172 \mathrm{μs}\left({\color{gray}-0.419 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$15.8 \mathrm{ms} \pm 225 \mathrm{μs}\left({\color{lightgreen}-32.268 \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 208 \mathrm{μs}\left({\color{lightgreen}-24.325 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$16.0 \mathrm{ms} \pm 168 \mathrm{μs}\left({\color{gray}4.80 \mathrm{\%}}\right) $$ Flame Graph

@indietyp indietyp changed the title H-3500: harpc: Remove the ErrorEncoder and ErrorDecoder H-3500: harpc: Remove the ErrorEncoder and ErrorDecoder traits Oct 20, 2024
@indietyp indietyp added this pull request to the merge queue Oct 21, 2024
Merged via the queue into main with commit 9a12a9d Oct 21, 2024
162 checks passed
@indietyp indietyp deleted the bm/harpc/error-codec-remove branch October 21, 2024 11:18
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) type/eng > backend Owned by the @backend team
Development

Successfully merging this pull request may close these issues.

2 participants