Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Dynamic String/Symbol/Regexp create too much garbage #301

Closed
headius opened this Issue · 3 comments

1 participant

Charles Oliver Nutter
Charles Oliver Nutter
Owner

Rails and other libraries frequently use the form :"foo#{bar}" to generate symbols on the fly at runtime. With no caching or improvements, this creates two Ruby Strings, two ByteLists, a Java String and transcoding support classes even when the symbol exists, depending on what "bar" is (if it is not a String, there's a third String and ByteList created for it). I we can get this down to one ByteList total for all cases where bar is a String, Symbol, or Fixnum, which would cover the vast majority of cases.

Currently the interpreter can avoid creating a String for "foo", but that is about as far as it goes. The compiler does not avoid any creation, and every element of the DStr/DSymbol gets lifted all the way up to String before being appended and thrown away.

Charles Oliver Nutter
Owner

See #300 for additional work needed to make String => Symbol free.

Charles Oliver Nutter headius referenced this issue from a commit
Charles Oliver Nutter headius Improvements for DStr/DSymbol interpretation for #301.
* Special-case core classes in RubyString.append19 to avoid
dyncalls and transient objects.
* Special-case core classes in DNode's EvStr handling to use
append19 directly rather than coercing to a throw-away transient
String.
* Don't create a shared string in DNode, since it's a new ByteList
that's almost immediately written to anyway.
* DSymbol knows super will produce a String, so use more direct
path that doesn't immediately convert to Java String. See #300.
9649428
Charles Oliver Nutter
Owner

Bulk of compiler work completed in f772683. Work remains in both interpreter and compiler for DSymbol to avoid the intermediate String, but DStr should be greatly improved.

Charles Oliver Nutter headius closed this
Charles Oliver Nutter
Owner

DRegexp turned out to be a lot more work, btw, so I filed #302 for it.

Charles Oliver Nutter headius referenced this issue from a commit
Charles Oliver Nutter headius Eliminate transient strings from compiled DSymbol, DXStr logic.
Same general pattern as for DStr. See #301.
9cd88cd
प्रथमेश prathamesh-sonpatki referenced this issue from a commit in prathamesh-sonpatki/jruby
Charles Oliver Nutter headius Improvements for DStr/DSymbol interpretation for #301.
* Special-case core classes in RubyString.append19 to avoid
dyncalls and transient objects.
* Special-case core classes in DNode's EvStr handling to use
append19 directly rather than coercing to a throw-away transient
String.
* Don't create a shared string in DNode, since it's a new ByteList
that's almost immediately written to anyway.
* DSymbol knows super will produce a String, so use more direct
path that doesn't immediately convert to Java String. See #300.
4a5e311
प्रथमेश prathamesh-sonpatki referenced this issue from a commit in prathamesh-sonpatki/jruby
Charles Oliver Nutter headius Eliminate transient strings from compiled DSymbol, DXStr logic.
Same general pattern as for DStr. See #301.
eb59845
प्रथमेश prathamesh-sonpatki referenced this issue from a commit in prathamesh-sonpatki/jruby
Charles Oliver Nutter headius Improvements for DStr/DSymbol interpretation for #301.
* Special-case core classes in RubyString.append19 to avoid
dyncalls and transient objects.
* Special-case core classes in DNode's EvStr handling to use
append19 directly rather than coercing to a throw-away transient
String.
* Don't create a shared string in DNode, since it's a new ByteList
that's almost immediately written to anyway.
* DSymbol knows super will produce a String, so use more direct
path that doesn't immediately convert to Java String. See #300.
186f89a
प्रथमेश prathamesh-sonpatki referenced this issue from a commit in prathamesh-sonpatki/jruby
Charles Oliver Nutter headius Eliminate transient strings from compiled DSymbol, DXStr logic.
Same general pattern as for DStr. See #301.
69dcd6f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.