dry-rb/dry-core

Memoization is slow

ojab opened this issue · 1 comments

ojab commented

Describe the bug

https://www.reddit.com/r/ruby/comments/olksxg/optimizing_performance_in_memowise_a_new/h5fex06/?context=3
panorama-ed/memo_wise#189

I suppose we can steal something from memo_wise and make memoization faster (hey, they have the same license).
I'm planning to read their code and probably make a PR or two here, but time is scarce these days, so not sure when/if it will happen 😿

To Reproduce

Clone PR above, run benchmarks.

Expected behavior

dry-core is faster, of course.

My environment

  • Affects my production application: kinda?
  • Ruby version: 3.0.2
  • OS: linux x86_64

That's quite misleading. It's not slow because we did something wrong, it's just a comparison where people put some effort into performance optimizations. I don't find claiming memoization in dry-core slow justified. We check an internal cache for key presence, that's it. If you have a reasonable proposal on how to improve it, please send a PR or start a discussion at the forum.

P.S. I may send a PR too but I don't feel like it'll be "fixing an issue" so I'll close this one.