Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JRuby 1.7: ArgumentError: argument too big in RubyString #3243

Open
mjc opened this issue Aug 10, 2015 · 8 comments
Open

JRuby 1.7: ArgumentError: argument too big in RubyString #3243

mjc opened this issue Aug 10, 2015 · 8 comments

Comments

@mjc
Copy link
Contributor

mjc commented Aug 10, 2015

Tried to generate a 10GB string in Ruby 1.7.20 and it looks like the number is too big for RubyString?

irb(main):001:0> GB = 1024*1024*1024; a = "a" * GB * 10
ArgumentError: argument too big
    from org/jruby/RubyString.java:1195:in `*'
    from (irb):1:in `evaluate'
    from org/jruby/RubyKernel.java:1111:in `eval'
    from org/jruby/RubyKernel.java:1511:in `loop'
    from org/jruby/RubyKernel.java:1274:in `catch'
    from org/jruby/RubyKernel.java:1274:in `catch'

MRI successfully generates this string. JRuby 9k does the same thing as 1.7.

@mjc mjc changed the title ArgumentError: argument too big in RubyString JRuby 1.7: ArgumentError: argument too big in RubyString Aug 10, 2015
@enebo enebo added this to the JRuby 1.7.22 milestone Aug 10, 2015
@enebo enebo added the core label Aug 10, 2015
@enebo enebo removed this from the JRuby 1.7.22 milestone Aug 10, 2015
@enebo
Copy link
Member

enebo commented Aug 10, 2015

I was going to change int as index to long as index in RubyString but I realize that we will run into platform issues (which is likely why this was originally capped at MAX_INT). Without significant changes to how RubyString is defined (like using ropes/multiple lists internally) this will not get solved easily.

I am leaving this open as I think we can solve this but I do not anticipate us fixing this near term.

@mjc
Copy link
Contributor Author

mjc commented Aug 10, 2015

Is there another way to generate a massive string you'd recommend in the interim?

@enebo
Copy link
Member

enebo commented Aug 11, 2015

@mjc Perhaps make a string-like class which aggregates a list of strings. This may not sound appealing but it does have a useful property: Not all memory needs to be contiguously allocated. Finding a single contiguous region of 10G of memory is potentially challenging but 10 1G segments much less so.

@rtyler
Copy link

rtyler commented Aug 17, 2015

@mjc out of curiosity, have you tried creating very large strings in MRI as well? I wonder if we're behaving appropriately here

@mjc
Copy link
Contributor Author

mjc commented Aug 17, 2015

Yes, this works fine in MRI, as big a string as memory and swap allow.

On Mon, Aug 17, 2015 at 10:57 AM, R. Tyler Croy notifications@github.com
wrote:

@mjc https://github.com/mjc out of curiosity, have you tried creating
very large strings in MRI as well? I wonder if we're behaving appropriately
here


Reply to this email directly or view it on GitHub
#3243 (comment).

@enebo
Copy link
Member

enebo commented Aug 17, 2015

@rtyler MRI is long so they may work or likely work for larger than max int

@headius
Copy link
Member

headius commented Aug 18, 2015

It's not possible for us to represent a large string like this with standard JVM code, since a byte[] in Java can only be indexed by a 32-bit signed integer. It would be possible to do this if we had a ByteList that used tricks like Unsafe, but that's a really big leap to make.

@enebo
Copy link
Member

enebo commented Aug 19, 2015

If we make aggregate bytelist with @nirvdrum bytelist extension changes we can support it through that but then we would need long signatures on bytelist (jotting notes here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants