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-721: Remove async-trait dependency #5315

Merged
merged 7 commits into from
Oct 5, 2024

Conversation

TimDiekmann
Copy link
Member

🌟 What is the purpose of this PR?

It's not needed anymore (except to implement third-party crates for axum)

🔍 What does this change?

  • Remove #[async_trait] for all define traits

@TimDiekmann TimDiekmann self-assigned this Oct 5, 2024
@github-actions github-actions bot added area/deps Relates to third-party dependencies (area) area/apps > hash* Affects HASH (a `hash-*` app) type/eng > backend Owned by the @backend team area/apps area/apps > hash-graph labels Oct 5, 2024
Comment on lines 214 to 223
#[instrument(level = "info", skip(self, filter))]
async fn read_vec(
fn read_vec(
&self,
filter: &Filter<'_, R>,
temporal_axes: Option<&QueryTemporalAxes>,
include_drafts: bool,
) -> Result<Vec<R>, QueryError> {
) -> impl Future<Output = Result<Vec<R>, QueryError>> + Send {
self.read(filter, temporal_axes, include_drafts)
.await?
.try_collect()
.await
.and_then(TryStreamExt::try_collect)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

and_then works quite nice here, no await is needed here 🚀

Copy link
Contributor

github-actions bot commented Oct 5, 2024

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 $$54.3 \mathrm{ms} \pm 374 \mathrm{μs}\left({\color{gray}1.40 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$50.5 \mathrm{ms} \pm 353 \mathrm{μs}\left({\color{gray}2.98 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$45.6 \mathrm{ms} \pm 235 \mathrm{μs}\left({\color{red}7.04 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$71.2 \mathrm{ms} \pm 727 \mathrm{μs}\left({\color{red}5.35 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$60.4 \mathrm{ms} \pm 367 \mathrm{μs}\left({\color{gray}3.86 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$40.6 \mathrm{ms} \pm 177 \mathrm{μs}\left({\color{gray}4.59 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$96.8 \mathrm{ms} \pm 627 \mathrm{μs}\left({\color{gray}3.77 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$95.1 \mathrm{ms} \pm 467 \mathrm{μs}\left({\color{red}6.56 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$82.0 \mathrm{ms} \pm 448 \mathrm{μs}\left({\color{gray}4.93 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$110 \mathrm{ms} \pm 826 \mathrm{μs}\left({\color{gray}3.15 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$99.4 \mathrm{ms} \pm 558 \mathrm{μs}\left({\color{gray}2.06 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$43.0 \mathrm{ms} \pm 217 \mathrm{μs}\left({\color{gray}0.548 \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/organization/v/1 $$16.5 \mathrm{ms} \pm 210 \mathrm{μs}\left({\color{gray}1.63 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$17.8 \mathrm{ms} \pm 210 \mathrm{μs}\left({\color{red}10.9 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$17.4 \mathrm{ms} \pm 223 \mathrm{μs}\left({\color{lightgreen}-23.935 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$16.6 \mathrm{ms} \pm 214 \mathrm{μs}\left({\color{gray}4.94 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$16.9 \mathrm{ms} \pm 222 \mathrm{μs}\left({\color{gray}-2.378 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$16.7 \mathrm{ms} \pm 178 \mathrm{μs}\left({\color{gray}4.32 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$17.2 \mathrm{ms} \pm 250 \mathrm{μs}\left({\color{red}27.2 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$17.9 \mathrm{ms} \pm 213 \mathrm{μs}\left({\color{red}11.8 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$18.2 \mathrm{ms} \pm 249 \mathrm{μs}\left({\color{red}15.8 \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 4.45 \mathrm{μs}\left({\color{gray}-0.188 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$2.06 \mathrm{ms} \pm 10.7 \mathrm{μs}\left({\color{gray}2.13 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$2.53 \mathrm{ms} \pm 13.2 \mathrm{μs}\left({\color{gray}2.11 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.92 \mathrm{ms} \pm 6.89 \mathrm{μs}\left({\color{gray}0.629 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$4.11 \mathrm{ms} \pm 15.3 \mathrm{μs}\left({\color{gray}1.09 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.90 \mathrm{ms} \pm 9.13 \mathrm{μs}\left({\color{gray}1.44 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$53.4 \mathrm{ms} \pm 217 \mathrm{μs}\left({\color{red}16.1 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$76.8 \mathrm{ms} \pm 387 \mathrm{μs}\left({\color{red}5.52 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$25.4 \mathrm{ms} \pm 165 \mathrm{μs}\left({\color{gray}2.32 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$278 \mathrm{ms} \pm 1.06 \mathrm{ms}\left({\color{gray}3.14 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$20.2 \mathrm{ms} \pm 110 \mathrm{μs}\left({\color{gray}0.727 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 10000 entities $$9.17 \mathrm{ms} \pm 113 \mathrm{μs}\left({\color{lightgreen}-27.228 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$1.90 \mathrm{ms} \pm 18.8 \mathrm{μs}\left({\color{gray}2.16 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.03 \mathrm{ms} \pm 9.19 \mathrm{μs}\left({\color{gray}1.50 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.75 \mathrm{ms} \pm 16.0 \mathrm{μs}\left({\color{gray}2.08 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.89 \mathrm{ms} \pm 11.3 \mathrm{μs}\left({\color{gray}2.65 \mathrm{\%}}\right) $$ Flame Graph

Copy link
Member

@indietyp indietyp left a comment

Choose a reason for hiding this comment

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

big fan of the change!

@TimDiekmann TimDiekmann added this pull request to the merge queue Oct 5, 2024
Merged via the queue into main with commit 6f15fce Oct 5, 2024
159 checks passed
@TimDiekmann TimDiekmann deleted the t/h-721-remove-async_trait-dependency branch October 5, 2024 15:17
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) type/eng > backend Owned by the @backend team
Development

Successfully merging this pull request may close these issues.

2 participants