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

Create current_path arrays on read #4342

Merged
merged 6 commits into from
Feb 22, 2023
Merged

Create current_path arrays on read #4342

merged 6 commits into from
Feb 22, 2023

Conversation

rmosolgo
Copy link
Owner

@rmosolgo rmosolgo commented Feb 9, 2023

Currently, path.dup is one of the biggest object allocators at runtime. The fact is, that value is rarely used. It's only used by the runtime to add paths to errors, and it's exposed via extras: [:path], context[:current_path], and in trace payloads as path: ....

This PR creates path on-demand for extras: [:path] and context[:current_path] and removes it from trace payloads. (Those traces also get context, so code that used data[:path] could use data[:context][:current_path] instead.)

In my silly-large, all-overhead benchmark, this reduces allocations dramatically (ymmv 🍻):

  Calculating -------------------------------------
  Querying for 1000 objects
-                           4.024  (± 0.0%) i/s -     21.000  in   5.225396s
+                           4.372  (± 0.0%) i/s -     22.000  in   5.034931s

  ==================================
    Mode: wall(1)
    Samples: 511904 (42.93% miss rate)
-  GC: 5795 (1.28%)
+  GC: 3013 (0.65%)
  ==================================

- Total allocated: 11635600 bytes (127485 objects)
+ Total allocated: 7155360 bytes (45479 objects)


  allocated objects by class
  -----------------------------------
-      92274  Array
       17108  Hash
+      10270  Array
        8044  Proc

TODO:

@rmosolgo rmosolgo added this to the 2.0.18 milestone Feb 22, 2023
@rmosolgo rmosolgo merged commit d0fdeea into master Feb 22, 2023
@rmosolgo rmosolgo deleted the create-path-on-read branch February 22, 2023 19:03
@rmosolgo rmosolgo mentioned this pull request Feb 22, 2023
8 tasks
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