TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Speeding Up Ruby with Shared Strings

194 pointsby tenderloveover 7 years ago

7 comments

hyperpapeover 7 years ago
The optimization of reusing the character array for a string was used in Java until roughly the Java 7 days, when it was dropped because it could cause a space leak: <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;15612157&#x2F;substring-method-in-string-class-causes-memory-leak#15612188" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;15612157&#x2F;substring-metho...</a>.<p>One difference in Java was that you could slice out the middle of a string (you just kept the start and end of the array, iirc). I wonder if that difference makes this approach workable for Ruby, or if that implies that one team made a mistake.
评论 #16363016 未加载
评论 #16363411 未加载
mmanfrinover 7 years ago
Aaron is my personal career idol. I love seeing his work come up on here, it gives me a view in to the deeper workings of ruby that are years beyond my expertise, but in a way that I can mostly grok what&#x27;s going on. I&#x27;m super happy github hired him to hack around on ruby.<p>Also, his talks are excellent; his closing keynote for RailsConf in particular seems worth recommending, as it was about his work speeding up Rails using kind of similar string optimizations&#x2F;caching:<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=BTTygyxuGj8" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=BTTygyxuGj8</a>
评论 #16368733 未加载
vidarhover 7 years ago
Object allocations really are a big deal with Ruby. My Ruby compiler project has been really slow moving again over the last year, but as far as I can tell the current main hurdle is a basic garbage collector, as even adding various object caching, I actually exhaust the 2GB heap (the compiler was started when i386 was a reasonable initial architecture choice...)...<p>Granted that&#x27;s worse that it&#x27;d be for MRI, as it includes allocating actual objects even for Fixnum and Symbol (MRI uses tagged values for both and just pretend they&#x27;re &quot;real&quot; objects), though I added caching for both that cut hundred of thousands of allocations..
heartbreakover 7 years ago
Is it documented anywhere what length of string can be embedded within an RString?
评论 #16361432 未加载
banachtarskiover 7 years ago
Looks like something that would benefit more from a string_view type abstraction.
PricelessValueover 7 years ago
So essentially string interning for Ruby?
评论 #16362772 未加载
raitomover 7 years ago
Kinda suprised when I see title like that on HN that not so many people are talking about Crystal <a href="https:&#x2F;&#x2F;crystal-lang.org" rel="nofollow">https:&#x2F;&#x2F;crystal-lang.org</a>. Basically Ruby with C performances.<p>So far I’ve been more convinced by Crystal than Elixir as the next language for a Ruby developer.
评论 #16362321 未加载
评论 #16362374 未加载
评论 #16362284 未加载
评论 #16362364 未加载
评论 #16364507 未加载
评论 #16363007 未加载
评论 #16364421 未加载
评论 #16371578 未加载
评论 #16364918 未加载