[ruby-cvs:64635] normal:r57469 (trunk): io.c: recycle garbage on write

normal at ruby-lang.org normal at ruby-lang.org
Tue Jan 31 05:40:18 JST 2017

normal	2017-01-31 05:40:18 +0900 (Tue, 31 Jan 2017)

  New Revision: 57469


    io.c: recycle garbage on write
    * string.c (STR_IS_SHARED_M): new flag to mark shared mulitple times
      (rb_str_tmp_frozen_acquire, rb_str_tmp_frozen_release): new functions
      (str_new_frozen): set/unset STR_IS_SHARED_M as appropriate
    * internal.h: declare new functions
    * io.c (fwrite_arg, fwrite_do, fwrite_end): new
      (io_fwrite): use new functions
    Introduce rb_str_tmp_frozen_acquire and rb_str_tmp_frozen_release
    to manage a hidden, frozen string.  Reuse one bit of the embed
    length for shared strings as STR_IS_SHARED_M to indicate a string
    has been shared multiple times.  In the common case, the string
    is only shared once so the object slot can be reclaimed immediately.
    minimum results in each 3 measurements. (time and size)
    Execution time (sec)
    name                            trunk   built
    io_copy_stream_write            0.682   0.254
    io_copy_stream_write_socket     1.225   0.751
    Speedup ratio: compare with the result of `trunk' (greater is better)
    name    built
    io_copy_stream_write            2.680
    io_copy_stream_write_socket     1.630
    Memory usage (last size) (B)
    name                            trunk           built
    io_copy_stream_write            95436800.000    6512640.000
    io_copy_stream_write_socket     117628928.000   7127040.000
    Memory consuming ratio (size) with the result of `trunk' (greater is better)
    name    built
    io_copy_stream_write            14.654
    io_copy_stream_write_socket     16.505

  Modified files:

More information about the ruby-cvs mailing list