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

Use compare_by_identity on some runtime caches #4443

Merged
merged 4 commits into from
Apr 21, 2023

Conversation

rmosolgo
Copy link
Owner

@rmosolgo rmosolgo commented Apr 18, 2023

Some hashes in GraphQL-Ruby are by-type caches of things. Those will always have the same objects (Classes) as keys, so we could use compare_by_identity for them (suggested in #4431 (comment))

Initial results are good:

  Warming up --------------------------------------
  Querying for 1000 objects
-                           4.333  (± 0.0%) i/s -     22.000  in   5.082679s
+                           4.848  (± 0.0%) i/s -     25.000  in   5.158312s

  # ... 
  ==================================
       TOTAL    (pct)     SAMPLES    (pct)     FRAME
-      26656   (9.4%)       26656   (9.4%)     Kernel#hash
+      17766   (2.7%)       17766   (2.7%)     Kernel#hash


-      26300   (9.3%)       26300   (9.3%)     Kernel#class
+      68174  (10.4%)       68174  (10.4%)     Kernel#class

TODO:

  • Address some usages of schema.after_lazy to use this runtime method instead (perhaps by adding query. or context.after_lazy?) which uses a better cache

@rmosolgo rmosolgo added this to the 2.0.22 milestone Apr 21, 2023
@rmosolgo rmosolgo merged commit 732f223 into master Apr 21, 2023
@rmosolgo rmosolgo deleted the compare-by-identity-for-caches branch April 21, 2023 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant