Skip to content

Conversation

@mayur-kambariya
Copy link
Contributor

No description provided.

@rafaelfranca
Copy link
Member

Can you provide benchmark and results for those performance improvements? Otherwise we can't merge

Comment on lines +15 to +17
# Check cache without mutex for common case (reading)
cached_value = @cache[key]
return cached_value if cached_value
Copy link
Contributor

@moberegger moberegger Jan 23, 2026

Choose a reason for hiding this comment

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

A similar optimization was added in #607

Comment on lines -366 to +379
BLANK == value
value == BLANK
Copy link
Contributor

Choose a reason for hiding this comment

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

My benchmark shows that the original version is faster, at least when comparing against a Hash.

value = { a: 1, b: 2, c: 3 }

Benchmark.ips do |x|
  x.report('value == BLANK') { value == BLANK }
  x.report('BLANK == value') { BLANK == value }

  x.compare!(order: :baseline)
end
ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
      value == BLANK     1.692M i/100ms
      BLANK == value     2.332M i/100ms
Calculating -------------------------------------
      value == BLANK     24.381M (± 2.0%) i/s   (41.02 ns/i) -    123.504M in   5.067597s
      BLANK == value     40.648M (± 2.0%) i/s   (24.60 ns/i) -    205.219M in   5.050778s

Comparison:
      value == BLANK: 24380939.0 i/s
      BLANK == value: 40647529.7 i/s - 1.67x  faster

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.

3 participants