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

Experiment: Linked list for Context #1597

Closed
wants to merge 1 commit into from

Conversation

fbogsany
Copy link
Contributor

bogsanyi@franciss-mbp benchmarks % bundle exec ruby context_bench.rb
Allocations -------------------------------------
linked list with_value
                           4/0  alloc/ret        0/0  strings/ret
    array with_value       4/1  alloc/ret        0/0  strings/ret
Warming up --------------------------------------
linked list with_value
                       103.622k i/100ms
    array with_value   109.858k i/100ms
Calculating -------------------------------------
linked list with_value
                          1.336M (± 0.4%) i/s -      6.735M
    array with_value      1.452M (± 0.3%) i/s -      7.360M

Comparison:
    array with_value:  1452403.1 i/s
linked list with_value:  1335513.3 i/s - 1.09x slower

Allocations -------------------------------------
linked list with_values
                           3/3  alloc/ret        0/0  strings/ret
   array with_values       2/0  alloc/ret        0/0  strings/ret
Warming up --------------------------------------
linked list with_values
                       113.765k i/100ms
   array with_values   123.378k i/100ms
Calculating -------------------------------------
linked list with_values
                          1.520M (± 0.6%) i/s -      7.622M
   array with_values      1.634M (± 0.8%) i/s -      8.266M

Comparison:
   array with_values:  1633881.6 i/s
linked list with_values:  1519551.6 i/s - 1.08x slower

Allocations -------------------------------------
linked list with_value recursive
                          30/3  alloc/ret        0/0  strings/ret
array with_value recursive
                          20/0  alloc/ret        0/0  strings/ret
Warming up --------------------------------------
linked list with_value recursive
                        13.911k i/100ms
array with_value recursive
                        15.145k i/100ms
Calculating -------------------------------------
linked list with_value recursive
                        146.918k (± 0.4%) i/s -    737.283k
array with_value recursive
                        156.918k (± 0.7%) i/s -    787.540k

Comparison:
array with_value recursive:   156917.5 i/s
linked list with_value recursive:   146917.6 i/s - 1.07x slower

With yjit:

bogsanyi@franciss-mbp benchmarks % bundle exec ruby --yjit context_bench.rb
Allocations -------------------------------------
linked list with_value
                           4/0  alloc/ret        0/0  strings/ret
    array with_value       4/1  alloc/ret        0/0  strings/ret
Warming up --------------------------------------
linked list with_value
                       170.330k i/100ms
    array with_value   187.176k i/100ms
Calculating -------------------------------------
linked list with_value
                          2.940M (± 0.4%) i/s -     14.819M
    array with_value      3.470M (± 1.1%) i/s -     17.407M

Comparison:
    array with_value:  3470179.8 i/s
linked list with_value:  2939828.0 i/s - 1.18x slower

Allocations -------------------------------------
linked list with_values
                           3/0  alloc/ret        0/0  strings/ret
   array with_values       2/0  alloc/ret        0/0  strings/ret
Warming up --------------------------------------
linked list with_values
                       185.121k i/100ms
   array with_values   202.576k i/100ms
Calculating -------------------------------------
linked list with_values
                          3.277M (± 1.4%) i/s -     16.476M
   array with_values      4.054M (± 0.9%) i/s -     20.460M

Comparison:
   array with_values:  4054172.0 i/s
linked list with_values:  3276817.5 i/s - 1.24x slower

Allocations -------------------------------------
linked list with_value recursive
                          30/0  alloc/ret        0/0  strings/ret
array with_value recursive
                          20/0  alloc/ret        0/0  strings/ret
Warming up --------------------------------------
linked list with_value recursive
                        25.197k i/100ms
array with_value recursive
                        29.579k i/100ms
Calculating -------------------------------------
linked list with_value recursive
                        271.735k (± 0.6%) i/s -      1.361M
array with_value recursive
                        316.777k (± 0.9%) i/s -      1.597M

Comparison:
array with_value recursive:   316777.4 i/s
linked list with_value recursive:   271735.4 i/s - 1.17x slower

@fbogsany
Copy link
Contributor Author

This was an experiment to help with open-telemetry/opentelemetry-ruby-contrib#772. The performance impact is significant enough that we shouldn't proceed with this.

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.

None yet

1 participant