aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* vm.c: respect redefinition of Proc#callnobu2018-01-083-4/+34
| | | | | | | | | | | | | | | * vm.c (vm_redefinition_check_method_type): hoist out method definition type to check redefinition. * vm.c (rb_vm_check_redefinition_opt_method): should check optimized method too. * vm.c (vm_init_redefined_flag): check Proc#call. * vm_insnhelper.c (vm_call_opt_block_call): search proper method if redefined. [Bug #14335] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add parens [ci skip]kazu2018-01-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: show newline node marknobu2018-01-081-2/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Use last_loc.lineno instead of ruby_sourcelinemame2018-01-081-7/+7
| | | | | | State-less way is better. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Remove `$<num>$ = ruby_sourceline` hacksmame2018-01-081-119/+47
| | | | | | Instead, use bison's lineno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: compile_case2 branchnobu2018-01-081-2/+5
| | | | | | * compile.c (compile_case2): compile as a branch condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: constified NULL_LOCnobu2018-01-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* doc/NEWS-2.5.0: Time.at is a class methodmrkn2018-01-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Factor out special handling of a short-cut operator idmame2018-01-081-21/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Remove duplicated nd_loc setyui-knk2018-01-081-2/+0
| | | | | | * parse.y: nd_loc is set by NEW_CASE2/NEW_WHEN git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Embed simple wrapper functions for NEW_NODEsmame2018-01-081-46/+16
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Make NULL_LOC to be internalyui-knk2018-01-081-1/+1
| | | | | | | * parse.y (NULL_LOC): We will create NODEs only inside of parse.y, so make NULL_LOC to be internal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Remove unneeded wrapper functions for NEW_NODEsmame2018-01-081-267/+99
| | | | | | Just refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: set bison's first_loc.lineno to nd_line by defaultmame2018-01-081-189/+69
| | | | | | | | | | | | This change initializes nd_line, lineno of each node, by default, by using the first line number of code range that bison tracks, instead of extracting from lexer state. The lexer state basically provides only the last line number of code range, so many hacks are used to approximate the first line number. The hacks have been introduced on demand, or very ad-hocly. I think this change will make it possible to remove most of the hacks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: make all NEW_NODE macros receive locationmame2018-01-082-368/+304
| | | | | | This looks a big change, but just for refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* zlib: reduce garbage on Zlib::GzipReader#readpartialnormal2018-01-081-43/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For garbage-concious users who use the `outbuf' argument of `readpartial' to supply a destination buffer, this provides a drastic reduction in garbage when inflating large inputs in a streaming fashion. This results in a anonymous RSS reduction in the reader similar to the reduction in the writer from r61631. Results using the test script from r61631 <https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61631> Before: writer 7.359999 0.000000 7.359999 ( 7.360639) writer RssAnon: 4040 kB reader 6.346667 0.070000 6.416667 ( 7.387654) reader RssAnon: 98272 kB After: writer 7.309999 0.000000 7.309999 ( 7.310651) writer RssAnon: 4048 kB reader 6.146666 0.003333 6.149999 ( 7.334868) reader RssAnon: 4300 kB * ext/zlib/zlib.c (struct read_raw_arg): new struct (gzfile_read_raw_partial): use read_raw_arg (gzfile_read_raw_rescue): ditto (gzfile_read_raw): accept outbuf, use read_raw_arg (gzfile_read_raw_ensure): accept outbuf (gzfile_read_header): ditto (gzfile_check_footer): ditto (gzfile_read_more): ditto (gzfile_read_raw_until_zero): adjust for changes (gzfile_fill): ditto (gzfile_readpartial): ditto (gzfile_read_all): ditto (gzfile_getc): ditto (gzfile_reader_end_run): ditto (gzfile_reader_get_unused): ditto (rb_gzreader_initialize): ditto (gzreader_skip_linebreaks): ditto (gzreader_gets): ditto (zlib_gunzip_run): ditto [ruby-core:84660] [Feature #14319] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* open-uri: clear string after bufferingnormal2018-01-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since r58846 (in Ruby 2.5), it is safe to clear the string yielded to Net::HTTPResponse#read_body methods. This reduces malloc garbage (anonymous RSS) using the Linux-only script below: before: user system total real 0.030000 0.250000 0.280000 ( 0.280511) RssAnon: 60240 kB after: user system total real 0.050000 0.223333 0.273333 ( 0.273118) RssAnon: 6676 kB ------ # warning this script requires 1G free space for buffering require 'open-uri' require 'socket' require 'benchmark' s = TCPServer.new('127.0.0.1', 0) len = 1024 * 1024 * 1024 buf = ((0..255).map(&:chr).join * 128) nr = len / buf.size pid = fork do c = s.accept c.readpartial(16384).clear c.write("HTTP/1.1 200 OK\r\n" \ "Content-Length: #{len}\r\n" \ "Content-Type: application/octet-stream\r\n" \ "\r\n") buf.freeze # speeds up IO#write slightly nr.times { c.write(buf) } c.close end addr = s.addr open("http://#{addr[3]}:#{addr[1]}/", "rb") do |fp| bm = Benchmark.measure do while fp.read(16384, buf) end end puts bm end puts File.readlines("/proc/#$$/status").grep(/RssAnon/)[0] Process.waitpid2(pid) ------ * lib/open-uri.rb: clear string yielded by Net::HTTPResponse#read_body [ruby-core:84662] [Feature #14320] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* net/protocol: read directly into rbuf if it's emptynormal2018-01-081-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's no need to allocate a temporary string when @rbuf is empty, we can use it as the read_nonblock destination buffer to save both allocation overhead and avoid a later memcpy. This results in a halving user CPU time and tiny memory reduction with the script below: user system total real before 0.603333 0.539999 1.143332 ( 1.143347) RssAnon: 5624 kB after 0.283334 0.560000 0.843334 ( 0.846072) RssAnon: 5592 kB ------ require 'net/http' require 'benchmark' s = TCPServer.new('127.0.0.1', 0) len = 1024 * 1024 * 1024 * 2 pid = fork do c = s.accept c.readpartial(16384).clear c.send("HTTP/1.0 200 OK\r\nContent-Length: #{len}\r\n\r\n", Socket::MSG_MORE) IO.copy_stream('/dev/zero', c, len) c.close end addr = s.addr Net::HTTP.start(addr[3], addr[1]) do |http| http.request_get('/') do |res| puts(Benchmark.measure { res.read_body(&:clear) }) end end puts File.readlines("/proc/self/status").grep(/RssAnon/)[0] Process.waitpid2(pid) ------ * lib/net/protocol.rb (rbuf_fill): avoid allocation if rbuf is empty [ruby-core:84678] [Feature #14326] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* net/protocol: use binary string buffersnormal2018-01-081-5/+5
| | | | | | | | | | Not an encoding expert, but this seems necessary for the next change. All of the IO#read, IO#read_nonblock and related methods will return a binary string when given a length argument; so anything appended to these buffers via << will be binary. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Speedup `block.call` [Feature #14330]ko12018-01-077-6/+128
| | | | | | | | | | | | | | | | | | | | | | * insns.def (getblockparamproxy): introduce new instruction to return the `rb_block_param_proxy` object if possible. This object responds to `call` method and invoke given block (completely similar to `yield`). * method.h (OPTIMIZED_METHOD_TYPE_BLOCK_CALL): add new optimized call type which is for `rb_block_param_proxy.cal`. * vm_insnhelper.c (vm_call_method_each_type): ditto. * vm_insnhelper.c (vm_call_opt_block_call): ditto. * vm_core.h (BOP_CALL, PROC_REDEFINED_OP_FLAG): add check for `Proc#call` redefinition. * compile.c (iseq_compile_each0): compile to use new insn `getblockparamproxy` for method call. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/scanf.rb: [DOC] fix typosstomar2018-01-071-7/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * 2018-01-08svn2018-01-071-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* doc/NEWS-2.5.0: improve languagestomar2018-01-071-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: fix SEGV of `->(a:){}` when --dump=parsetreemame2018-01-071-2/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: do not overwrite case_body positionnobu2018-01-071-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: set case_body line position to argsnobu2018-01-071-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: removed unused macro new_command_callnobu2018-01-071-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: nd_line of new_qcallnobu2018-01-072-19/+46
| | | | | | * parse.y (new_qcall): set nd_line to the method name location. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c: reset in each linenobu2018-01-072-7/+27
| | | | | | | | * eval_error.c (print_errinfo): reset in each line, so that Exception#full_message ends with a newline and puts will not print an extra newline. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c: concat directlynobu2018-01-071-10/+4
| | | | | | | * eval_error.c (write_warn, write_warn2): get rid of unnecessary intermediate string objects, concat directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_exception.rb: fix messagenobu2018-01-071-2/+2
| | | | | | | * test/ruby/test_exception.rb (test_full_message): fix method name in a message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c: renamed an argumentnobu2018-01-071-8/+8
| | | | | | | * eval_error.c (print_errinfo): renamed argument `colored` as `highlight`, as it does not use colors. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: rb_stderr_to_original_pnobu2018-01-071-3/+9
| | | | | | | * io.c (rb_stderr_to_original_p): hoist out the condition to write messages to the stderr FD directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Added bundler for `test-bundled-gems` dependency.hsbt2018-01-071-1/+1
| | | | | | rake, did_you_mean, test-unit depends on bundler. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* prelude.rb: eliminate a private constantnobu2018-01-071-6/+5
| | | | | | | * prelude.rb (Thread.exclusive): eliminate a private constant, MUTEX_FOR_THREAD_EXCLUSIVE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* extmk.rb: exclude recursivelynobu2018-01-071-3/+7
| | | | | | * ext/extmk.rb: exclude extension libraries recursively. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * 2018-01-07svn2018-01-071-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* doc/NEWS-2.5.0: Fix the description of backtrace format changemrkn2018-01-071-2/+2
| | | | | | * The backtrace format change is affected by $stderr, but not STDERR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "net/protocol: use binary string buffers"normal2018-01-061-5/+5
| | | | | | | Oops, not ready, yet (will work on this tomorrow :x). This reverts commit r61638 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* net/ftp: fix FrozenError in BufferedSocketnormal2018-01-062-1/+7
| | | | | | | | | | | | | | I noticed this bug while working on something else with RUBYOPT=-d on, existing test cases all passed with it. Note: I use String.new because it is the local style, here, I prefer +'' (or ''.b, for a future commit) * lib/net/ftp.rb (BufferedSocket#read): use String.new * test/net/ftp/test_buffered_socket.rb (test_read_nil): new test [ruby-core:84675] [Bug #14323] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* net/protocol: use binary string buffersnormal2018-01-061-5/+5
| | | | | | | Not an encoding expert, but this seems necessary for the next change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_process.rb: skip not-found groupsnobu2018-01-061-1/+6
| | | | | | | | * test/ruby/test_process.rb (test_execopts_gid): under some network configuration (maybe with Open Directory but disconnected temporarily), some groups may fail to find. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: out-of-bounds accessnobu2018-01-061-1/+2
| | | | | | | * string.c (rb_str_enumerate_lines): fix out-of-bounds access when record separator is longer than the last element. [Bug #14257] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update Status Codekazu2018-01-061-11/+15
| | | | | | see https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add 103 Early Hintskazu2018-01-061-0/+4
| | | | | | see https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Specify frozen_string_literal: truekazu2018-01-061-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: clear Strings we create for IO.copy_streamnormal2018-01-051-2/+5
| | | | | | | | | | | | | While we can't recycle strings after giving them rb_funcall*, we can reduce their malloc overhead by resizing them to zero. This only affects cases where either `src' or `dst' is a non-IO object and either `copy_length' is passed or there is pre-existing data in the read buffer. * io.c (copy_stream_fallback_body): clear when done with `copy_length' (copy_stream_body): clear when done with pre-existing read buffer git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* zlib: reduce garbage on gzip writes (deflate)normal2018-01-051-11/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Zlib::GzipWriter generated large amounts of garbage from (struct zstream).input. Reuse the .input field when it is hidden, and recycle it when its lifetime is over. This change alone reduced memory usage of the writer from 90MB to 4.5MB. For the detached buffer of compressed data used by gzfile_write_raw, we can only clear the string (not recycle it) since user code may hold references to it (but the data would be clobbered, anyways). This reduced memory usage slightly by around 0.5MB (because it's smaller compressed data). Combined, these changes reduce the anonymous RSS memory of a dedicated writer process from over 90MB to under 4MB. before: # user system total real writer 7.823332 0.053333 7.876665 ( 7.881464) writer RssAnon: 92944 kB reader 6.969999 0.076666 7.046665 ( 7.906377) reader RssAnon: 109820 kB after: writer 7.359999 0.000000 7.359999 ( 7.360639) writer RssAnon: 4040 kB reader 6.346667 0.070000 6.416667 ( 7.387654) reader RssAnon: 98272 kB Script used: ------- require 'zlib' require 'benchmark' nr = 16384 * 2 def stats(pfx, bm) str = "#{bm}#{File.readlines("/proc/#$$/status").grep(/^RssAnon:/)[0]}" puts str.gsub!(/^/m, pfx) end rd, wr = IO.pipe pid = fork do buf = ((0..255).map(&:chr).join * 128).freeze rd.close gzip = Zlib::GzipWriter.new(wr) bm = Benchmark.measure do nr.times { gzip.write(buf) } gzip.close wr.close end stats('writer ', bm) end wr.close buf = '' gunzip = Zlib::GzipReader.new(rd) n = 0 bm = Benchmark.measure do begin gunzip.readpartial(16384, buf) n += buf.size rescue EOFError break end while true end stats('reader ', bm) Process.waitall ------- * ext/zlib/zlib.c (zstream_discard_input): reuse or recycle hidden input (zstream_reset_input): clear hidden input (zstream_run): detach input and recycle after use (gzfile_write_raw): clear buffer after write [ruby-core:84638] [Feature #14315] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Extend timeout of test_clear_unreachable_keyword_argsnaruse2018-01-051-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Show how many seconds it timeoutsnaruse2018-01-051-1/+1
| | | | | | By this we can easily extend timeout. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e