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-3437: harpc: Simplify signature of harpc_server::serve #5400

Merged
merged 14 commits into from
Oct 15, 2024

Conversation

indietyp
Copy link
Member

@indietyp indietyp commented Oct 14, 2024

🌟 What is the purpose of this PR?

This simplifies the signature of the serve function by using tower::MakeService, additionally the codec argument has been removed. Router now creates a service that packs automatically using the same codec.

Additionally the requirement for BoxedResponse has been removed, Route has been factored out into it's own file just to keep things tidy.

(serve is also correct now, we previously did not call poll_ready on the make_service service, it does now)

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

@indietyp indietyp requested a review from TimDiekmann October 14, 2024 11:29
@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 14, 2024
@vilkinsons vilkinsons changed the title harpc: simplify signature of harpc_server::serve H-3437: harpc: Simplify signature of harpc_server::serve Oct 14, 2024
TimDiekmann
TimDiekmann previously approved these changes Oct 15, 2024
Base automatically changed from bm/harpc/codec-erasure to main October 15, 2024 12:29
@indietyp indietyp dismissed TimDiekmann’s stale review October 15, 2024 12:29

The base branch was changed.

# Conflicts:
#	libs/@local/harpc/server/examples/account.rs
#	libs/@local/harpc/server/src/router.rs
@indietyp indietyp requested a review from TimDiekmann October 15, 2024 12:50
@indietyp indietyp enabled auto-merge October 15, 2024 12:51
Copy link
Contributor

Benchmark results

@rust/graph-benches – Integrations

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$16.1 \mathrm{ms} \pm 190 \mathrm{μs}\left({\color{red}22.2 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$15.8 \mathrm{ms} \pm 190 \mathrm{μs}\left({\color{lightgreen}-6.754 \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 209 \mathrm{μs}\left({\color{lightgreen}-23.751 \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 168 \mathrm{μs}\left({\color{lightgreen}-34.030 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$16.0 \mathrm{ms} \pm 168 \mathrm{μs}\left({\color{gray}1.76 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$15.2 \mathrm{ms} \pm 157 \mathrm{μs}\left({\color{gray}-3.919 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$15.3 \mathrm{ms} \pm 182 \mathrm{μs}\left({\color{gray}-3.564 \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 167 \mathrm{μs}\left({\color{gray}-3.954 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$16.5 \mathrm{ms} \pm 185 \mathrm{μs}\left({\color{gray}-2.564 \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 4.72 \mathrm{μs}\left({\color{gray}0.222 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$4.07 \mathrm{ms} \pm 21.4 \mathrm{μs}\left({\color{gray}2.07 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$2.02 \mathrm{ms} \pm 11.0 \mathrm{μs}\left({\color{gray}-1.926 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$2.56 \mathrm{ms} \pm 26.1 \mathrm{μs}\left({\color{lightgreen}-11.138 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.85 \mathrm{ms} \pm 8.57 \mathrm{μs}\left({\color{gray}-0.064 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.88 \mathrm{ms} \pm 7.70 \mathrm{μs}\left({\color{gray}-0.575 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 1000 entities $$2.76 \mathrm{ms} \pm 17.1 \mathrm{μs}\left({\color{gray}-3.882 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.01 \mathrm{ms} \pm 6.06 \mathrm{μs}\left({\color{gray}1.39 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$1.84 \mathrm{ms} \pm 5.26 \mathrm{μs}\left({\color{gray}0.170 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$12.5 \mathrm{ms} \pm 138 \mathrm{μs}\left({\color{gray}1.14 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.87 \mathrm{ms} \pm 6.28 \mathrm{μs}\left({\color{gray}1.25 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$59.2 \mathrm{ms} \pm 511 \mathrm{μs}\left({\color{gray}-0.278 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$67.9 \mathrm{ms} \pm 401 \mathrm{μs}\left({\color{gray}-1.158 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$39.6 \mathrm{ms} \pm 234 \mathrm{μs}\left({\color{gray}-1.446 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$43.7 \mathrm{ms} \pm 324 \mathrm{μs}\left({\color{gray}-1.312 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$54.5 \mathrm{ms} \pm 282 \mathrm{μs}\left({\color{gray}-1.791 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$50.1 \mathrm{ms} \pm 279 \mathrm{μs}\left({\color{gray}-1.214 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$98.2 \mathrm{ms} \pm 518 \mathrm{μs}\left({\color{gray}-1.782 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$107 \mathrm{ms} \pm 654 \mathrm{μs}\left({\color{gray}-1.418 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$42.3 \mathrm{ms} \pm 361 \mathrm{μs}\left({\color{gray}-0.190 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$79.9 \mathrm{ms} \pm 559 \mathrm{μs}\left({\color{gray}-1.206 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$94.1 \mathrm{ms} \pm 360 \mathrm{μs}\left({\color{gray}-1.455 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$89.7 \mathrm{ms} \pm 541 \mathrm{μs}\left({\color{gray}-1.633 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$271 \mathrm{ms} \pm 1.42 \mathrm{ms}\left({\color{gray}-1.357 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$51.1 \mathrm{ms} \pm 189 \mathrm{μs}\left({\color{gray}-1.106 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$73.1 \mathrm{ms} \pm 400 \mathrm{μs}\left({\color{gray}-0.121 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$19.8 \mathrm{ms} \pm 73.5 \mathrm{μs}\left({\color{gray}0.251 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$24.7 \mathrm{ms} \pm 127 \mathrm{μs}\left({\color{gray}0.411 \mathrm{\%}}\right) $$ Flame Graph

@indietyp indietyp added this pull request to the merge queue Oct 15, 2024
Merged via the queue into main with commit 958822e Oct 15, 2024
161 checks passed
@indietyp indietyp deleted the bm/harpc/make-service branch October 15, 2024 13:59
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