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-1628: Write a benchmark which runs queries as specified in a JSON file #5904

Merged

Conversation

TimDiekmann
Copy link
Member

🌟 What is the purpose of this PR?

Dynamically measure the performance for a specific query currently is quite hard. This adds a new benchmark to tests/graph/benches which can be run by yarn bench:integration:manual.
The queries will be read from the manual_queries directory and are in this shape:

  • type: "getEntities" | "getEntitySubgraph"
  • actorId: Uuid
  • request depending on type the exact same input as you’d pass to the graphApi functions

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

🐾 Next steps

  • It would be good to add more dynamic behavior by allowing certain parameters to be dynamic such as the ActorID or the graph resolve depths. This will be done later.

@TimDiekmann TimDiekmann requested a review from CiaranMn December 13, 2024 17:41
@TimDiekmann TimDiekmann self-assigned this Dec 13, 2024
@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 area/tests New or updated tests labels Dec 13, 2024
CiaranMn
CiaranMn previously approved these changes Dec 13, 2024
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 22.90%. Comparing base (5e43293) to head (a43d70f).
Report is 385 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5904      +/-   ##
==========================================
+ Coverage   22.87%   22.90%   +0.02%     
==========================================
  Files         572      572              
  Lines       19415    19394      -21     
  Branches     2752     2746       -6     
==========================================
  Hits         4442     4442              
+ Misses      14920    14899      -21     
  Partials       53       53              
Flag Coverage Δ
apps.hash-ai-worker-ts 1.32% <ø> (ø)
apps.hash-api 1.16% <ø> (-0.01%) ⬇️
local.hash-backend-utils 8.81% <ø> (ø)
local.hash-graph-sdk 58.62% <ø> (ø)
local.hash-isomorphic-utils 0.98% <ø> (ø)
local.hash-subgraph 24.54% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TimDiekmann TimDiekmann added this pull request to the merge queue Dec 13, 2024
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/playlist/v/1 $$16.8 \mathrm{ms} \pm 188 \mathrm{μs}\left({\color{lightgreen}-28.640 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$16.4 \mathrm{ms} \pm 238 \mathrm{μs}\left({\color{gray}-4.407 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$16.1 \mathrm{ms} \pm 187 \mathrm{μs}\left({\color{gray}-1.609 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$15.9 \mathrm{ms} \pm 156 \mathrm{μs}\left({\color{lightgreen}-11.170 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$17.6 \mathrm{ms} \pm 191 \mathrm{μs}\left({\color{gray}3.00 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$16.9 \mathrm{ms} \pm 226 \mathrm{μs}\left({\color{gray}-4.627 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$17.0 \mathrm{ms} \pm 200 \mathrm{μs}\left({\color{gray}-4.981 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$16.3 \mathrm{ms} \pm 176 \mathrm{μs}\left({\color{lightgreen}-33.340 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$17.5 \mathrm{ms} \pm 217 \mathrm{μs}\left({\color{lightgreen}-12.499 \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 $$67.1 \mathrm{ms} \pm 492 \mathrm{μs}\left({\color{gray}-2.598 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$40.2 \mathrm{ms} \pm 292 \mathrm{μs}\left({\color{gray}0.334 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$57.8 \mathrm{ms} \pm 401 \mathrm{μs}\left({\color{gray}-1.074 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$44.5 \mathrm{ms} \pm 289 \mathrm{μs}\left({\color{gray}2.19 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$49.9 \mathrm{ms} \pm 305 \mathrm{μs}\left({\color{gray}-1.074 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$54.7 \mathrm{ms} \pm 349 \mathrm{μs}\left({\color{gray}-0.295 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$109 \mathrm{ms} \pm 657 \mathrm{μs}\left({\color{gray}-2.413 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$44.1 \mathrm{ms} \pm 252 \mathrm{μs}\left({\color{gray}-0.431 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$100 \mathrm{ms} \pm 434 \mathrm{μs}\left({\color{gray}-2.832 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$84.5 \mathrm{ms} \pm 471 \mathrm{μs}\left({\color{gray}-0.979 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$93.3 \mathrm{ms} \pm 510 \mathrm{μs}\left({\color{gray}-2.849 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$95.7 \mathrm{ms} \pm 311 \mathrm{μs}\left({\color{gray}-4.026 \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.39 \mathrm{ms} \pm 5.04 \mathrm{μs}\left({\color{gray}-0.543 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$273 \mathrm{ms} \pm 1.73 \mathrm{ms}\left({\color{gray}2.56 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$26.5 \mathrm{ms} \pm 94.4 \mathrm{μs}\left({\color{gray}1.05 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$20.1 \mathrm{ms} \pm 97.5 \mathrm{μs}\left({\color{gray}-1.648 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$56.7 \mathrm{ms} \pm 1.48 \mathrm{ms}\left({\color{red}54.0 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$177 \mathrm{ms} \pm 1.17 \mathrm{ms}\left({\color{gray}-0.612 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$1.92 \mathrm{ms} \pm 5.33 \mathrm{μs}\left({\color{gray}0.466 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.11 \mathrm{ms} \pm 8.61 \mathrm{μs}\left({\color{gray}1.81 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$1.95 \mathrm{ms} \pm 7.02 \mathrm{μs}\left({\color{gray}-0.168 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.85 \mathrm{ms} \pm 11.5 \mathrm{μs}\left({\color{gray}1.09 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$9.30 \mathrm{ms} \pm 95.4 \mathrm{μs}\left({\color{lightgreen}-8.581 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$3.98 \mathrm{ms} \pm 17.5 \mathrm{μs}\left({\color{gray}0.900 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.95 \mathrm{ms} \pm 5.47 \mathrm{μs}\left({\color{gray}-1.062 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.93 \mathrm{ms} \pm 12.7 \mathrm{μs}\left({\color{gray}-0.143 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$2.19 \mathrm{ms} \pm 12.0 \mathrm{μs}\left({\color{gray}2.42 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$3.35 \mathrm{ms} \pm 19.4 \mathrm{μs}\left({\color{gray}0.838 \mathrm{\%}}\right) $$ Flame Graph

auto-merge was automatically disabled December 13, 2024 18:48

Pull Request is not mergeable

auto-merge was automatically disabled December 13, 2024 18:48

Pull Request is not mergeable

auto-merge was automatically disabled December 13, 2024 18:49

Pull Request is not mergeable

auto-merge was automatically disabled December 13, 2024 18:50

Pull Request is not mergeable

Merged via the queue into main with commit a0e38fe Dec 13, 2024
166 checks passed
@TimDiekmann TimDiekmann deleted the t/h-1628-write-large-scale-benchmark-tests-for-the-graph branch December 13, 2024 19:02
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) area/tests New or updated tests type/eng > backend Owned by the @backend team
Development

Successfully merging this pull request may close these issues.

2 participants