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

When dumping to IO, dump directly #538

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Aug 15, 2023

  1. When dumping to IO, dump directly

    Json.dump allows you to pass an IO to which the dump output will
    be sent, but it still buffers the entire output in memory before
    sending it to the given IO. This leads to issues on JRuby like
    jruby/jruby#6265 when it tries to create a byte[] that exceeds the
    maximum size of a signed int (JVM's array size limit).
    
    This commit plumbs the IO all the way through the generation logic
    so that it can be written to directly without filling a temporary
    memory buffer first. This allow JRuby to dump object graphs that
    would normally produce more content than the JVM can hold in a
    single array, providing a workaround for jruby/jruby#6265.
    
    It is unfortunately a bit slow to dump directly to IO due to the
    many small writes that all acquire locks and participate in the
    IO encoding subsystem. A more direct path that can skip some of
    these pieces could be more competitive with the in-memory version,
    but functionally it expands the size of graphs that cana be dumped
    when using JRuby.
    
    See ruby#524
    headius committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    7576f5c View commit details
    Browse the repository at this point in the history