ox icon indicating copy to clipboard operation
ox copied to clipboard

Use "interned" (frozen and deduplicated) Strings in Ruby 3.0+ to minimize object allocations.

Open okeeblow opened this issue 3 years ago • 3 comments

I have a PR ready to go for this feature but this can be for discussion of the general concept.

  • Background info: https://en.wikipedia.org/wiki/String_interning
  • Available to C extensions since MRI Ruby 3.0:
    • https://bugs.ruby-lang.org/issues/13381
    • https://bugs.ruby-lang.org/issues/16029
  • Like https://ruby-doc.org/core/String.html#method-i-2B-40

okeeblow avatar Jul 20 '21 04:07 okeeblow

For what it's worth Ox is already the fastest Ruby XML parser for my use case even without this change. My library wouldn't be feasible without it since it's the only one that can parse shared-mime-info faster than ruby-mime-types starts up, so thank you! https://github.com/okeeblow/DistorteD/blob/master/CHECKING-YOU-OUT/docs/XML.md#Benchmarks

okeeblow avatar Jul 20 '21 05:07 okeeblow

I'll look over this tonight. Good to know about the latests string optimizations.

ohler55 avatar Jul 20 '21 12:07 ohler55

Can this be closed? Is it still relevant?

ohler55 avatar Apr 01 '22 23:04 ohler55