ruby/test
naruse baf330be0a merge revision(s) 57469,57471,57472,57503,57508: [Backport #13299]
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
2017-03-12 18:15:33 +00:00
..
-ext- merge revision(s) 57510,57511: [Backport #13176] 2017-03-11 19:18:45 +00:00
base64 Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
benchmark Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
bigdecimal bigdecimal: version 1.3.0 2016-12-21 15:35:29 +00:00
cgi * lib/cgi/cookie.rb (parse): don't allow , as a separator. [Bug #12791] 2016-09-27 03:17:47 +00:00
coverage Coverage on non-positive lines 2016-06-26 23:56:57 +00:00
csv merge revision(s) 57406: [Backport #13149] 2017-03-11 17:45:18 +00:00
date date_strftime.c: check precision 2016-06-14 13:07:27 +00:00
dbm update comments. 2016-05-01 12:50:19 +00:00
digest test/digest/test_digest.rb: fold long lines 2016-10-27 06:26:09 +00:00
drb openssl: adapt OpenSSL::PKey to OpenSSL 1.1.0 opaque structs 2016-06-05 15:00:47 +00:00
dtrace dtrace: wait command 2016-07-26 16:22:56 +00:00
erb erb.rb: fronzen-string-literal in comment [Fix GH-1229] 2016-01-29 05:16:29 +00:00
etc Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
excludes TestException.rb: suppress warning 2016-04-11 08:27:19 +00:00
fiddle Removed the obstacle to running test-all with VC14. 2016-12-14 17:53:20 +00:00
fileutils test_fileutils.rb: fix deadlock 2016-11-24 03:01:59 +00:00
gdbm update comments. 2016-05-01 12:50:19 +00:00
io merge revision(s) 57289: [Backport #13114] 2017-03-12 07:46:26 +00:00
irb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
json json_generator_test.rb: no Bignum 2016-09-09 09:27:38 +00:00
lib merge revision(s) 57589: [Backport #13205] 2017-03-12 15:02:30 +00:00
logger logger.rb: fix next rotate time 2016-11-16 06:59:42 +00:00
matrix Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
minitest Use Integer instead of Fixnum and Bignum. 2016-05-17 13:15:57 +00:00
misc test_ruby_mode.rb: fix for Emacs 25.1 2016-09-24 01:19:43 +00:00
mkmf mkmf: Unquote directory strings 2016-03-24 16:10:43 +00:00
monitor Use qualified names 2016-08-30 06:22:30 +00:00
net Specify the socktype explicitly. 2016-12-04 05:05:54 +00:00
nkf Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
objspace Use JSON lines format for full heap dumps. 2016-09-16 17:44:45 +00:00
open-uri open-uri: don't use OpenSSL::TestUtils from open-uri tests 2016-11-29 15:48:46 +00:00
openssl merge revision(s) 57750: 2017-03-12 07:52:32 +00:00
optparse optparse/kwargs.rb 2016-10-14 13:26:13 +00:00
ostruct merge revision(s) 57515: [Backport #13169] 2017-03-12 07:34:42 +00:00
pathname Pathname#empty? implemented. 2016-11-05 03:29:08 +00:00
psych * ext/psych/*, test/psych/*: Update psych-2.1.1 2016-09-07 03:16:15 +00:00
rdoc * lib/rdoc/*, test/rdoc/*: Update rdoc-5.0.0 2016-11-05 09:18:10 +00:00
readline Supress warnings. 2016-11-30 01:22:05 +00:00
resolv fix Resolv::LOC::Coord.create. 2016-11-05 15:19:21 +00:00
rexml rexml: REXML::Element#[] accepts String or Symbol as attribute name 2016-12-06 13:57:56 +00:00
rinda test_rinda.rb: ipv6_mc 2016-12-22 02:00:02 +00:00
ripper parse.y: ripper generic input 2016-12-08 00:45:13 +00:00
rss Fix tests depending on sort stability 2016-10-13 02:31:43 +00:00
ruby merge revision(s) 57469,57471,57472,57503,57508: [Backport #13299] 2017-03-12 18:15:33 +00:00
rubygems object.c: no TypeError at special const dup 2016-11-27 11:07:27 +00:00
scanf Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
sdbm update comments. 2016-05-01 12:50:19 +00:00
shell Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
socket Use qualified names 2016-08-30 06:22:30 +00:00
stringio stringio.c: chomp CR 2016-12-10 08:54:40 +00:00
strscan Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
syslog Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
testunit assertions.rb: leave timeout to invoke_ruby 2016-05-19 03:46:20 +00:00
thread merge revision(s) 57492: 2017-03-12 07:34:58 +00:00
uri test_mailto.rb: overwritten methods 2016-12-17 00:58:47 +00:00
webrick Delay Utils.getservername until needed. 2016-12-07 12:59:48 +00:00
win32ole test/win32ole/test_win32ole_variant.rb: use other than Integer 2016-05-18 02:05:30 +00:00
yaml fix YAML::Store 2016-09-29 13:43:46 +00:00
zlib suppress warning: attempt to close unfinished zstream; reset forced. 2016-12-20 16:02:22 +00:00
colors default colors 2015-05-17 00:50:11 +00:00
runner.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_abbrev.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_cmath.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_delegate.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_find.rb find.rb: raise with the name 2016-02-19 14:38:28 +00:00
test_forwardable.rb * test/test_forwardable.rb (TestForwardable#test_on_private_method): add test for [Bug #12782] [Bug #12840] 2016-10-31 08:43:54 +00:00
test_ipaddr.rb IPAddr#== and IPAddr#<=> no longer raise an exception if coercion fails 2016-11-05 13:53:38 +00:00
test_mathn.rb merge revision(s) 57232: [Backport #13084] 2017-03-11 13:35:22 +00:00
test_mutex_m.rb Use qualified names 2016-08-30 06:22:30 +00:00
test_observer.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_open3.rb * lib/open3.rb: Specify frozen_string_literal: true. 2015-11-14 07:43:23 +00:00
test_pp.rb * lib/open-uri.rb: Remove indicator for "frozen_string_literal: true". 2015-11-10 11:48:14 +00:00
test_prettyprint.rb * lib/open-uri.rb: Remove indicator for "frozen_string_literal: true". 2015-11-10 11:48:14 +00:00
test_prime.rb * lib/prime.rb: Optimize prime? 2016-08-10 18:17:41 +00:00
test_pstore.rb test_pstore.rb: use queues 2016-09-28 14:12:33 +00:00
test_pty.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_rbconfig.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_securerandom.rb random.c: use bytes 2016-05-10 05:57:11 +00:00
test_set.rb Add Set#compare_by_identity and Set#compare_by_identity? 2016-11-05 09:23:14 +00:00
test_shellwords.rb Fix the handling of the backslash in double quotes 2016-11-05 04:58:48 +00:00
test_singleton.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_syslog.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_tempfile.rb merge revision(s) 57437: 2017-03-11 18:16:14 +00:00
test_time.rb Time.parse's "now" argument as nil works again. 2016-11-05 14:03:34 +00:00
test_timeout.rb Use our domain instead of other's domain 2016-09-07 12:32:04 +00:00
test_tmpdir.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_tracer.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_tsort.rb test/test_tsort.rb: Specify frozen_string_literal: true. 2015-11-14 09:43:18 +00:00
test_unicode_normalize.rb * test/ruby/enc/test_case_comprehensive.rb, test_regex_casefold.rb, 2016-07-03 09:51:46 +00:00
test_weakref.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_win32api.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00