mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00

io.c: recycle garbage on write * string.c (STR_IS_SHARED_M): new flag to mark shared mulitple times (STR_SET_SHARED): set STR_IS_SHARED_M (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 string.c (rb_str_tmp_frozen_release): release embedded strings Handle the embedded case first, since we may have an embedded duplicate and non-embedded original string. * string.c (rb_str_tmp_frozen_release): handled embedded strings * test/ruby/test_io.rb (test_write_no_garbage): new test [ruby-core:78898] [Bug #13085] io.c (rb_io_syswrite): avoid leaving garbage after write As with IO#write, IO#syswrite also generates garbage which can be harmful in hand-coded read-write loops. * io.c (swrite_arg, swrite_do, swrite_end): new (rb_io_syswrite): use new functions to cleanup garbage [ruby-core:78898] [Bug #13085] Add class name to assert messages io.c: remove rb_ensure usage for rb_str_tmp_frozen_* calls Using rb_ensure pessimizes the common case and makes the code more difficult to read and follow. If we hit an exceptions during write, just let the GC handle cleanup as the exception is already bad for garbage. * io.c (io_fwrite): call rb_str_tmp_frozen{acquire,release} directly (rb_io_syswrite): ditto (fwrite_do, fwrite_end, swrite_do, swrite_end): remove git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@57941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
73 lines
2.1 KiB
C
73 lines
2.1 KiB
C
#define RUBY_VERSION "2.4.0"
|
|
#define RUBY_RELEASE_DATE "2017-03-13"
|
|
#define RUBY_PATCHLEVEL 96
|
|
|
|
#define RUBY_RELEASE_YEAR 2017
|
|
#define RUBY_RELEASE_MONTH 3
|
|
#define RUBY_RELEASE_DAY 13
|
|
|
|
#include "ruby/version.h"
|
|
|
|
#ifndef TOKEN_PASTE
|
|
#define TOKEN_PASTE(x,y) x##y
|
|
#endif
|
|
#define ONLY_ONE_DIGIT(x) TOKEN_PASTE(10,x) < 1000
|
|
#define WITH_ZERO_PADDING(x) TOKEN_PASTE(0,x)
|
|
#define RUBY_BIRTH_YEAR_STR STRINGIZE(RUBY_BIRTH_YEAR)
|
|
#define RUBY_RELEASE_YEAR_STR STRINGIZE(RUBY_RELEASE_YEAR)
|
|
#if ONLY_ONE_DIGIT(RUBY_RELEASE_MONTH)
|
|
#define RUBY_RELEASE_MONTH_STR STRINGIZE(WITH_ZERO_PADDING(RUBY_RELEASE_MONTH))
|
|
#else
|
|
#define RUBY_RELEASE_MONTH_STR STRINGIZE(RUBY_RELEASE_MONTH)
|
|
#endif
|
|
#if ONLY_ONE_DIGIT(RUBY_RELEASE_DAY)
|
|
#define RUBY_RELEASE_DAY_STR STRINGIZE(WITH_ZERO_PADDING(RUBY_RELEASE_DAY))
|
|
#else
|
|
#define RUBY_RELEASE_DAY_STR STRINGIZE(RUBY_RELEASE_DAY)
|
|
#endif
|
|
|
|
#if !defined RUBY_LIB_VERSION && defined RUBY_LIB_VERSION_STYLE
|
|
# if RUBY_LIB_VERSION_STYLE == 3
|
|
# define RUBY_LIB_VERSION STRINGIZE(RUBY_API_VERSION_MAJOR)"."STRINGIZE(RUBY_API_VERSION_MINOR)"."STRINGIZE(RUBY_API_VERSION_TEENY)
|
|
# elif RUBY_LIB_VERSION_STYLE == 2
|
|
# define RUBY_LIB_VERSION STRINGIZE(RUBY_API_VERSION_MAJOR)"."STRINGIZE(RUBY_API_VERSION_MINOR)
|
|
# endif
|
|
#endif
|
|
|
|
#if RUBY_PATCHLEVEL == -1
|
|
#define RUBY_PATCHLEVEL_STR "dev"
|
|
#else
|
|
#define RUBY_PATCHLEVEL_STR "p"STRINGIZE(RUBY_PATCHLEVEL)
|
|
#endif
|
|
|
|
#ifndef RUBY_REVISION
|
|
# include "revision.h"
|
|
#endif
|
|
#ifndef RUBY_REVISION
|
|
# define RUBY_REVISION 0
|
|
#endif
|
|
|
|
#if RUBY_REVISION
|
|
# if RUBY_PATCHLEVEL == -1
|
|
# ifndef RUBY_BRANCH_NAME
|
|
# define RUBY_BRANCH_NAME "trunk"
|
|
# endif
|
|
# define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "STRINGIZE(RUBY_REVISION)
|
|
# else
|
|
# define RUBY_REVISION_STR " revision "STRINGIZE(RUBY_REVISION)
|
|
# endif
|
|
#else
|
|
# define RUBY_REVISION_STR ""
|
|
#endif
|
|
|
|
# define RUBY_DESCRIPTION \
|
|
"ruby "RUBY_VERSION \
|
|
RUBY_PATCHLEVEL_STR \
|
|
" ("RUBY_RELEASE_DATE \
|
|
RUBY_REVISION_STR") " \
|
|
"["RUBY_PLATFORM"]"
|
|
# define RUBY_COPYRIGHT \
|
|
"ruby - Copyright (C) " \
|
|
RUBY_BIRTH_YEAR_STR"-" \
|
|
RUBY_RELEASE_YEAR_STR" " \
|
|
RUBY_AUTHOR
|