tag:blogger.com,1999:blog-20975090.post5231756037100374306..comments2024-03-11T10:18:55.852-05:00Comments on Headius: Performance: Inlining StringsCharles Oliver Nutterhttp://www.blogger.com/profile/06400331959739924670noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-20975090.post-15872868073398688862006-09-07T22:31:00.000-05:002006-09-07T22:31:00.000-05:00From the Eclipse performance bloopers page (via ja...From the Eclipse performance bloopers page (via javaperformancetuning.com):<br /><br /># String.intern() often degrades performance, dramatically in some cases depending on usage and JVM.Interning strings eagerly and early fills the intern table with increasingly more collisions - the intern table is often a static size.<br /># Use a private table rather than the String.intern table.<br /><br />--------------------<br /><br />java's HashMap is great, give a private table a shot.<br /><br />One interesting idea to read about is "minimally perfect hashing" which is kind of relevant to the problem here.<br /><br />I understand the attractiveness of low hanging fruit, but I'd take a whack at the problem with a profiler before doing much else.b0b0b0bhttps://www.blogger.com/profile/09035894926385999507noreply@blogger.comtag:blogger.com,1999:blog-20975090.post-59042847194864559632006-09-07T20:29:00.000-05:002006-09-07T20:29:00.000-05:00Yuri is right, but you might want to at least inte...Yuri is right, but you might want to at least intern() all keywords and possibly operators. They are few enough but frequent enough that they should help a little without the negative impact on the size of interned strings table.<br /><br />Speaking of Strings though, I just had a quick look at the JRuby source. I noticed that there are quite a few heavily used calls to Ruby.newString() where a StringBuffer is being converted to a String before being passed as a parameter. Now the RubyString constructor that eventually gets called takes a CharSequence, so you could save the hit to GC by just passing the StringBuffer (provided the SB is a local variable that has no other references to it, which was the case in every call I saw). If you change the newString() parameter to take a CharSequence, you can incrementally change the rest of the code to use it.<br /><br />BTW, I tried to SVN the code but it failed, at least with RapidSVN. I'd certainly consider contributing fixes (driven by inspection, manual tests and use of a profiler) but I'd need SVN access or at least a reasonable likelihood that my patches would be applied even if they were against a snapshot of the code.<br /><br />Well, best of luck with JRuby performance!Colm Smythhttps://www.blogger.com/profile/10297748176831639589noreply@blogger.com