Граф коммитов

1435 Коммитов

Автор SHA1 Сообщение Дата
normal f7c3b6ff72 io.c: IO.copy_stream uses poll on Linux
poll and ppoll have a superior API which doesn't require the
kernel to scan a potentially large bitmap to find a high-numbered
FD [ruby-core:35572].  So favor using poll in case IO.copy_stream
encounters a non-blocking FD.

We cannot reliably use poll on most OSes, because file types (e.g.
FIFOs) which work with select may not work with poll.  Fortunately,
Linux uses a common notification mechanism between all
select/poll/epoll variants, so all file types are equally supported
between the notification mechanisms.

Verified by watching strace on the following scripts:

*** maygvl_copy_stream_wait_read ***
require 'io/nonblock'
r, w = IO.pipe
r.nonblock = true
IO.copy_stream(r, "/dev/null")

*** nogvl_copy_stream_wait_write ***
require 'io/nonblock'
r, w = IO.pipe
w.nonblock = true
IO.copy_stream("/dev/zero", w)

* io.c (nogvl_wait_for_single_fd): new function for Linux
  (maygvl_copy_stream_wait_read): Linux-specific version
  (nogvl_copy_stream_wait_write): use nogvl_wait_for_single_fd
  [ruby-core:70051] [Feature #11377]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-20 20:33:50 +00:00
normal d4454d0123 io.c (argf_read_nonblock): support `exception: false'
This is a preparation for [ruby-core:69892]
("io.c: avoid kwarg parsing in C API")
since I noticed ARGF.read_nonblock did not properly catch up to
the `exception: false' change.

* io.c (argf_read_nonblock): support `exception: false'
  (io_nonblock_eof): new function
  (io_read_nonblock): use io_nonblock_eof
  (argf_getpartial): accept kwargs hash for `exception: false'
* test/ruby/test_argf.rb (test_read_nonblock): new test
  [ruby-core:70000] [Feature #11358]
* NEWS: add item for ARGF.read_nonblock

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17 18:02:53 +00:00
sorah 3876d75585 * ext/socket/basicsocket.c: [DOC] typo (Errno::AGAIN -> Errno::EAGAIN)
* ext/socket/socket.c: ditto

* ext/socket/tcpserver.c: ditto

* ext/socket/udpsocket.c: ditto

* ext/socket/unixserver.c: ditto

* io.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-12 00:21:32 +00:00
normal df4e282eeb delay `exception: false' checks for minor speedup
Delay hash lookups until we are about to hit an exception.  This
gives a minor speedup ratio of 2-3% in the new bm_io_nonblock_noex
benchmark as well as reducing code.

* benchmark/bm_io_nonblock_noex.rb: new benchmark
* ext/openssl/ossl_ssl.c (no_exception_p): new function
  (ossl_start_ssl): adjust for no_exception_p
  (ossl_ssl_connect): adjust ossl_start_ssl call
  (ossl_ssl_connect_nonblock): ditto
  (ossl_ssl_accept): ditto
  (ossl_ssl_accept_nonblock): ditto
  (ossl_ssl_read_internal): adjust for no_exception_p
  (ossl_ssl_write_internal): ditto
  (ossl_ssl_write): adjust ossl_write_internal call
  (ossl_ssl_write_nonblock): ditto
* ext/stringio/stringio.c (strio_read_nonblock):
  delay exception check
* io.c (no_exception_p): new function
  (io_getpartial): call no_exception_p
  (io_readpartial): adjust for io_getpartial
  (get_kwargs_exception): remove
  (io_read_nonblock): adjust for io_getpartial,
  check no_exception_p on EOF
  (io_write_nonblock): call no_exception_p
  (rb_io_write_nonblock): do not check `exception: false'
  (argf_getpartial): adjust for io_getpartial
  [ruby-core:69778] [Feature #11318]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-02 22:22:14 +00:00
nobu cb85fb9c46 io.c: remove unnecessary shared
* io.c (rb_io_reopen): FilePathValue() ensures the path
  NUL-terminated and frozen, so it is unnecessary to make it shared.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30 14:12:16 +00:00
nobu 347da440cf ensure paths NUL-terminated
* dir.c (check_dirname): ensure path name NUL-terminated for
  SHARABLE_MIDDLE_SUBSTRING.
* io.c (rb_sysopen): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30 14:11:56 +00:00
nobu 93446fedd3 io.c: reopen OS encoding path
* io.c (rb_io_reopen): freopen(3) with OS encoding path.
  [ruby-core:69780] [Bug #11320]
* win32/file.c (rb_freopen): wrapper of wchar version freopen(3).
  use _wfreopen_s() if available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30 08:28:28 +00:00
normal af9e072c7e io.c: reopen stdio streams correctly when given "w+"
* io.c (rb_io_oflags_modestr): handle O_TRUNC correctly
* test/ruby/test_io.rb (test_reopen_stdio): new test

Patch-by: cremno phobia <cremno@mail.ru>

[ruby-core:69779] [Bug #11319]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-29 23:24:56 +00:00
hsbt 5d6ca9e950 * include/ruby/ruby.h: $SAFE=2 is now obsolete.
* dir.c, ext/fiddle/handle.c, ext/socket/basicsocket.c, file.c
  gc.c, io.c, process.c, safe.c, signal.c, win32/file.c:
  removed code for $SAFE=2
* test/erb/test_erb.rb, test/fiddle/test_handle.rb
  test/ruby/test_env.rb: removed tests for $SAFE=2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-18 14:21:03 +00:00
eregon 0ebf2afa81 * io.c (rb_io_s_binread): close fd if seek offset is invalid.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-13 20:25:10 +00:00
nobu 16f37446f7 io.c: simplify rb_io_modestr_fmode
* io.c (io_encname_bom_p): needs len always.

* io.c (rb_io_modestr_fmode): check BOM only after a colon.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-13 12:30:35 +00:00
normal cee9f4a499 io.c: reduce size of :wait_*able code paths
* io.c (sym_wait_readable, sym_wait_writable): declare
  (io_getpartial): use sym_wait_readable
  (io_write_nonblock): use sym_wait_writable
  (Init_IO): initialize sym_wait_*able

On 32-bit x86:

   text    data     bss     dec     hex filename
 121003      56     252  121311   1d9df io.o
 121035      56     252  121343   1d9ff io.o.orig

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04 22:11:19 +00:00
nobu 5c0fb216f7 io.c: refine message
* io.c (prepare_getline_args): refine the expected arity in an
  exception message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-25 02:33:36 +00:00
nobu cac2c6d331 Fixes for grammar and style [ci skip]
* io.c (rb_f_select): [DOC] Fixes for grammar and style.
  [Fix GH-906]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 01:51:51 +00:00
akr f6b1dd28c9 * internal.h (rb_execarg_parent_end): Declared.
* process.c: "spawn" opens files in the parent process.
  (check_exec_redirect): Add an placeholder for fd in parameters
  for fd_open.
  (check_exec_fds_1): Delete fd_open condition.
  (check_exec_fds): Don't call check_exec_fds_1 with fd_open.
  (rb_execarg_parent_start): Open files specified as "spawn" options
  and add "dup2" options.
  (rb_execarg_parent_end): New function to close opened fds.
  (run_exec_open): Removed.
  (rb_execarg_run_options): Don't call run_exec_open.
  (rb_spawn_internal): Call rb_execarg_parent_end.

* io.c (pipe_open): Call rb_execarg_parent_end.

* ext/pty/pty.c (establishShell): Call rb_execarg_parent_end.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09 12:44:35 +00:00
akr 9960558337 * internal.h (rb_execarg_parent_start): Renamed from rb_execarg_fixup.
* process.c: Follows the above change.

* io.c: Ditto.

* ext/pty/pty.c: Ditto.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09 11:53:49 +00:00
nobu efbfd90272 io.c: use read/write methods if possible
* io.c (copy_stream_body): use the arguments without conversion if
  having read, readpartial, and write methods, than conversion by
  to_path method.  [ruby-core:68676] [Bug #11015]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-30 02:28:02 +00:00
nobu add8e1f5bb console.c: winsize on Windows
* ext/io/console/console.c (console_set_winsize): use handle for
  writing.  GetConsoleScreenBufferInfo seems failing on a handle
  for reading.
* io.c: [DOC] update the example of IO#winsize to use $stdout
  instead of $stdin, which does not work on Windows.  a patch by
  Jan Lelis <mail AT janlelis.de> at [ruby-core:68574].
  [Bug #10986]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-21 06:01:29 +00:00
nobu 89bfc9b70b io.c: don't raise after close
* io.c (rb_io_close_read, rb_io_close_write): don't raise after
  close same as IO#close.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-13 06:03:25 +00:00
nobu 3338bc99e5 io.c: rb_io_get_fptr
* io.c (rb_io_get_fptr): return non-null fptr.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-13 06:03:03 +00:00
nobu dbbccb3cff io.c: duplicate code
* io.c (rb_io_close_m): remove duplicate check.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-09 04:57:51 +00:00
nobu d8abb9daaf io.c: wipe away ioctl buffer
* io.c (setup_narg): wipe away expanded part of buffer to get rid
  of revealing uncleaned data.  reported by Dongkwan Kim <dkay AT
  kaist.ac.kr>.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-27 04:57:51 +00:00
nobu b84e28d133 io.c: discard buffer always
* io.c (copy_stream_fallback_body): discard buffer always before
  exit or exception.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-27 03:54:54 +00:00
nobu 19711c7803 io.c: redulce RSTRING_PTR and RSTRING_LEN
* io.c: replace repeating RSTRING_PTR and RSTRING_LEN with local
  variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-26 14:42:26 +00:00
akr 255955585c * io.c (rb_io_close_m): Don't raise when the IO object is closed.
[ruby-core:67444] [Feature #10718]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-15 15:26:03 +00:00
nobu 7fd45e90cb io.c: workaround for YARD doc
* io.c (rb_f_select): [DOC] workaround for YARD doc.  [Fix GH-799]
  [ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-29 01:37:29 +00:00
nobu eaa80a6fa5 io.c: Fix spelling [ci skip]
* io.c (io_read) Fix spelling in docco for read.  [Fix GH-781]
  try > tries

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-11 23:16:03 +00:00
hone 512705e62d io.c: Typo close -> closes.
Patch by @cirosantilli [Fixes GH-757]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-07 02:20:45 +00:00
nobu 4a69c35c72 io.c: fix rdoc [ci skip]
* io.c (Init_IO): ARGF is not a class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-05 20:43:47 +00:00
nobu e580a631be use 0 for reserved
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 06:38:04 +00:00
usa e5658a206b * eval_error.c (error_print): respect the encoding of the message.
* io.c (rb_write_error_str): use rb_w32_write_console() on Windows
  if stderr is a tty.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-28 21:11:22 +00:00
nobu 9519f6193a io.c: preserve encodings
* io.c (must_respond_to): preserve encodings of variable name and
  class name in warning message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-23 17:03:08 +00:00
nobu 4f160fa041 io.c: remove redundant assignment
* io.c (rb_io_sysread): Remove redundan assignment of 'n'.
  [Fix GH-767]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-22 22:46:57 +00:00
akr 2b9191e557 * internal.h: Gather declarations in non-header files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 15:13:05 +00:00
akr 8463a90871 * include/ruby/io.h (FMODE_WSPLIT): Removed. The write() system call
is not required to split.  It was useful to avoid whole process
  blocking in Ruby 1.8 but not useful since write() is invoked without
  GVL.
  (FMODE_WSPLIT_INITIALIZED): Ditto.

* io.c (wsplit_p): Removed.
  (io_writable_length): Removed.
  (rb_fcntl): Don't update the removed flags.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 09:10:59 +00:00
nobu c01aaf60a5 id.def: move IDs for exception
* defs/id.def: add :mesg and :exception and move from other
  sources.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-16 08:33:35 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
usa fd9f6bde95 * win32/win32.c, include/win32/win32.h (rb_w32_set_nonblock): new
function to support nonblock-mode of pipes.

* win32/win32.c (rb_w32_read): nonblock-mode pipe returns ERROR_NO_DATA
  if there is no data, but also returns it if remote-end is closed.

* win32/win32.c (rb_w32_write): if cannot to write any data, it may be
  blocking.

* io.c (rb_io_set_nonblock): use rb_w32_set_nonblock for Windows.

* ext/io/nonblock/nonblock.c (rb_io_nonblock_set): use ruby's API when
  setting nonblock-mode.

* test/ruby/test_io.rb: test nonblock pipes on Windows.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-10 10:42:19 +00:00
akr 1fe90db538 * io.c (io_binwrite_string): Test writev() failure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-25 13:34:21 +00:00
nobu c1397c573e io.c: enclose statements by ifdef
* io.c (maygvl_copy_stream_read): enclose following statements by
  ifdef, not only a case label.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-20 07:02:20 +00:00
yugui 57bc5eaf2f Fixes build failures on Portable Native Client.
Note: Some of the fixes are for newlib in general but not NaCl-specific.

* include/ruby/intern.h (rb_fd_select): declare struct timeval, or the
  struct gets local to the function in C99.

* file.c (#include): add nacl/stat.h for PNaCl.
  (utimes): added a declaration for PNaCl.
  (stat_atimespec): stat::st_atimensec is long long but
  timespec::tv_nsec is long in PNaCl.
  (stat_mtimespec, stat_ctimespec): ditto.
  (rb_group_member): disable getgroups unless HAVE_GETGROUPS.
  (eaccess): unify the fallback to generic defined(USE_GETEUID).

* io.c: include sys/time.h for struct timeval.
  (rb_close_before_exec): nothing we can do if F_GETFD is not
  available.
  (ioctl): pnacl newlib actually doesn't have ioctl.

* process.c (maxgroups): it is used iff
   defined(_SC_NGROUPS_MAX) || defined(NGROUPS_MAX) but not
   defined(HAVE_GETGROUPS) || defined(HAVE_SETGROUPS).
  (obj2gid): fail unless the object is a Fixnum if getgrnam is not
  available.
  (disable_child_handler_fork_child): sigaction is not available in
  PNaCl newlib.

* configure.in (warnflags, strict_warnflags): avoid -ansi for strlcpy.
  (rb_cv_gcc_atomic_builtins): also check
  __atomic_or_etch because it is used in ruby_atomic.h.
  (rb_cv_gcc_sync_builtins): ditto.
  (HAVE_GETGRNAM): added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 13:33:14 +00:00
yugui e4ac591a20 * io.c: fix issues in the last two commits. don't disable cloexec for
platforms other than NativeClient.
* ChangeLog: ditto. add entries for the last two commits.
Sat Oct 11 11:12:00 2014  Yuki Yugui Sonoda  <yugui@yugui.jp>

	* signal.c (install_signalhandler, init_sigchld): allow failure because it
	  always fails with ENOSYS on NaCl.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 02:29:00 +00:00
yugui 1a14a7a1d7 Allow failure of sighandler installation on NativeClient.
* signal.c (install_signalhandler, init_sigchld): allow failure because it
  always fails with ENOSYS on NaCl.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 02:12:00 +00:00
yugui 69ac654c90 Merges a patch form naclports.
* configure.in (RUBY_NACL and others): Supports PNaCl.
* dln.c: replace the old hacky dynamic loading over HTTP with nacl_io.
* file.c: tenatively use access(2) instead of eaccess.
  (rb_file_load_ok): weaken with attribute but not by postprocess.
* io.c (socket.h): now NaCl has socket.h
  (flock): disable here instead of nacl/ioctl.h
* nacl/GNUmakefile.in (CC, LD, NM, AR, AS, RANLIB, OBJDUMP, OBJCOPY):
  respect path to them if they are absolute.
  This helps naclports to build ruby in their source tree.
  (PROGRAM_NMF, .SUFFIXES): support .pnexe for PNaCl.
  (ruby.o, file.o): move the hack to attributes in ruby.c and file.c
* nacl/ioctl.h: removed. move the hack to io.c.
* nacl/nacl-config.rb: support arm, pnacl and others.
* nacl/pepper_main.c: support build in a naclports tree.
* ruby.c (rb_load_file): weaken with attribute but not by postprocess.

The patch is by sbc@google.com and the Native Client Authors.
It is available at:
* 873ca4910a/ports/ruby/nacl.patch

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 02:11:53 +00:00
nobu 12088a7e95 io.c: fix typo
* io.c (rb_io_make_open_file): remove useless backslash.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-10 11:26:22 +00:00
nobu b44c47d102 io.c: move RFile initialization
* io.c (rb_io_make_open_file): move from include/ruby/io.h, and
  hide too detailed implementations.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-10 02:34:24 +00:00
nobu e1b5111ff4 io.c: ID instead of Symbol
* io.c (get_kwargs_exception): rb_get_kwargs() expects IDs, but
  not Symbols.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-05 15:31:38 +00:00
normal 3aab1f8467 io.c (fptr_finalize): free memory before GC sweep
This releases memory on explict calls to rb_io_close,
reducing pressure on the GC.

Final massif snapshot shows reduced heap usage after RubyGems load
(valgrind --tool=massif ./ruby -e exit)

before:
	mem_heap_B=4821992
	mem_heap_extra_B=1302952

after:
	mem_heap_B=4791056
	mem_heap_extra_B=1192440

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-01 20:36:28 +00:00
normal 405c4abb9f io.c: common function to free IO buffers
This also allows easier tracking of freed memory for systems
without malloc_usable_size, and also makes future changes
to freeing buffer memory easier-to-implement.

* io.c (free_io_buffer): new function for a common pattern
  (clear_readconv): use free_io_buffer
  (rb_io_fptr_finalize): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-25 10:40:37 +00:00
normal d198d64e04 trivial packing for on-stack structs
* io.c (struct io_advise_struct): 32 => 24 bytes on 64-bit
* io.c (struct io_internal_writev_struct): 24 => 16 bytes on 64-bit
* process.c (struct waitpid_arg): ditto

Slightly reduce stack pressure.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-15 07:31:38 +00:00