summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-05-21Improve Time#+ & Time#- performancewatson1978
* time.c (wadd): use internal addv() function to calculate internal value in Time object. On 64-bit machine, Time object might have Fixnum object internally by default and addv() can calculate Fixnum objects directly. * time.c (wsub): use internal subv() function due the same reason in above. Time#+ & Time#- will be faster around 15%. [ruby-dev:50036] [Bug #13357] [Fix GH-1547] ### Before user system total real Time#+ 0.820000 0.000000 0.820000 ( 0.818081) Time#- 0.810000 0.000000 0.810000 ( 0.813835) ### After user system total real Time#+ 0.710000 0.000000 0.710000 ( 0.710241) Time#- 0.710000 0.010000 0.720000 ( 0.714151) ### Test code require 'benchmark' Benchmark.bmbm do |x| x.report "Time#+" do t = Time.now 2000000.times do t + 1 end end x.report "Time#-" do t = Time.now 2000000.times do t - 1 end end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-21Improve Time#<=> performancewatson1978
* time.c (wcmp): use internal cmp() function for comparing internal Fixnum value in Time objects. On 64-bit machine, Time object might have Fixnum object internally by default and cmp() can compare the Fixnum objects directly. Time#<=> will be faster around 60% on 64-bit machine. * time.c (cmp): add optimized path for comparing internal Bignum value by using rb_big_cmp() API. On 32-bit machine, Time object might have Bignum object internally by default. Time#<=> will be faster around 50% on 32-bit machine. [ruby-dev:50034] [Bug #13354] [Fix GH-1546] ### Before user system total real Fixnum 1.410000 0.000000 1.410000 ( 1.407848) Bignum 1.550000 0.000000 1.550000 ( 1.549145) ### After user system total real Fixnum 0.880000 0.000000 0.880000 ( 0.886662) Bignum 1.050000 0.000000 1.050000 ( 1.047994) ### Test code require 'benchmark' Benchmark.bmbm do |x| x.report "Fixnum" do t1 = Time.now t2 = Time.now 10000000.times do t1 <=> t2 end end x.report "Bignum" do t1 = Time.at(2 ** 64) t2 = Time.at(2 ** 64 + 1) 10000000.times do t1 <=> t2 end end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-21Remove redundant square bracketskazu
Use character class directly instead of character class in character class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Allow trimming CR in all trim_modesk0kubun
to unify a behavior with r58823 and r58825. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Allow explicit trimming carriage returnk0kubun
when trim_mode is "-", for Windows environments. [ruby-core:39625] [Bug #5339] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20doc/maintainers.rdoc: Add me to ERB maintainersk0kubun
The current maintainer suggested this in ruby-dev:50113. Please ping me if an issue happens in ERB. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Allow trimming carriage returnk0kubun
when trim_mode is "<>", for Windows environments. [Bug #11464] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Prevent potential unexpected rescuek0kubun
of LoadError in some method calls, not from `require "strscan"`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20* 2017-05-21svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20Clean proxynaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Drop unused scanner implementationk0kubun
Original `SimpleScanner` was used only in tests. Since `SimpleScanner` and `SimpleScanner2` work in the same way, I want to drop the one which can't be used in a normal situation. The only difference was `SimpleScanner` can be loaded without strscan dependency but I think there's no situation that strscan is unavailable because it's a standard library. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20* properties.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20Add coverage measurement mode by using gcovmame
This experimental feature is only for Ruby-core team, not for casual users. Usage: `./configure --enable-gcov && make && make exam && make gcov` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20ripper.c should have `#line "ripper.c"`, not `#line "parse.c"`mame
The order of sed commands in Makefile of ripper was wrong: it tries to replace `y.tab.c` with `ripper.c`, but before that, ytab.sed replaced `y.tab.c` with `parse.c`, which led to a wrong result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20compile.c: optimize branchesnobu
* compile.c (compile_branch_condition, iseq_compile_each0): eliminate unreachable branches in NODE_IF. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20compile.c: binary logop checknobu
* compile.c (compile_branch_condition): turn recursion at binary logical operator into loop by goto, and check the result of RHS of NODE_OR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20prime.rb: remove alias after timeout teststomar
* test/test_prime.rb: remove alias after timeout test. * lib/prime.rb: fix typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20speed up IO#close with many threadsnormal
Today, it increases IO#close performance with many threads: Execution time (sec) name trunk after vm_thread_close 4.276 3.018 Speedup ratio: compare with the result of `trunk' (greater is better) name after vm_thread_close 1.417 This speedup comes because rb_notify_fd_close only scans threads inside rb_thread_io_blocking_region, not all threads in the VM. In the future, this type data structure may allow us to notify waiters of multiple FDs on a single thread (when using Fibers). * thread.c (struct waiting_fd): declare (rb_thread_io_blocking_region): use on-stack list waiter (rb_notify_fd_close): walk vm->waiting_fds instead (call_without_gvl): remove old field setting (th_init): ditto * vm_core.h (typedef struct rb_vm_struct): add waiting_fds list * (typedef struct rb_thread_struct): remove waiting_fd field (rb_vm_living_threads_init): initialize waiting_fds list I am now kicking myself for not thinking about this 3 years ago when I introduced ccan/list in [Feature #9632] to optimize this same function :< git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20Improve Hash#merge performancewatson1978
* hash.c (rb_hash_merge): use rb_hash_dup() instead of rb_obj_dup() to duplicate Hash object. rb_hash_dup() is faster duplicating function for Hash object which got rid of Hash#initialize_dup method calling. Hash#merge will be faster around 60%. [ruby-dev:50026] [Bug #13343] [Fix GH-1533] ### Before user system total real Hash#merge 0.160000 0.020000 0.180000 ( 0.182357) ### After user system total real Hash#merge 0.110000 0.010000 0.120000 ( 0.114404) ### Test code require 'benchmark' Benchmark.bmbm do |x| hash1 = {} 100.times { |i| hash1[i.to_s] = i } hash2 = {} 100.times { |i| hash2[(i*2).to_s] = i*2 } x.report "Hash#merge" do 10000.times do hash1.merge(hash2) end end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20compile.c: fix catch-table labels optimizationnobu
* compile.c (remove_unreachable_chunk): do not eliminate chunks followed by labels in catch-table entries. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20lib/prime: Fix primality of some large integers [#13492].marcandre
* lib/prime.rb: Use accurate sqrt to insure all factors are tested. Patch by Marcus Stollsteimer. * test/test_prime.rb: Adapt test for timeout git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Merge gemspec from ruby/fileutils.hsbt
* Replaced homepage option to source code location as github. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19fix off-by-one in r58806normal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19test/ruby/test_io.rb: new test for IO.select exception setnormal
Ensure this rarely-used feature of IO.select continues to work properly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19thread_sync.c: rewrite the rest using using ccan/listnormal
The performance improvement increases as the number of waiters increases, due to avoiding the O(n) behavior of rb_ary_delete on the waiting thread. Uncontended queues and condition variables performance is not altered significantly. Function entry cost is slightly increased for ConditionVariable, since the data pointer is separately allocated and not embedded into the RVALUE slot. [ruby-core:81235] [Feature #13552] name |trunk |built ----------------------|------:|------: vm_thread_condvar1 | 0.858| 0.858 vm_thread_condvar2 | 1.003| 0.804 vm_thread_queue | 0.131| 0.129 vm_thread_sized_queue | 0.265| 0.251 vm_thread_sized_queue2| 0.892| 0.859 vm_thread_sized_queue3| 0.879| 0.845 vm_thread_sized_queue4| 0.599| 0.486 Speedup ratio: compare with the result of `trunk' (greater is better) name |built ----------------------|------: vm_thread_condvar1 | 0.999 vm_thread_condvar2 | 1.246 vm_thread_queue | 1.020 vm_thread_sized_queue | 1.057 vm_thread_sized_queue2| 1.039 vm_thread_sized_queue3| 1.041 vm_thread_sized_queue4| 1.233 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19thread_sync.c: rename mutex_waiter struct to sync_waiternormal
We will reuse this struct for ConditionVariable, Queue, and SizedQueue, so it is no longer Mutex-specific. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Define classes for r58800naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19* properties.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Net::HTTP::STATUS_CODES is added as HTTP Status Code Repository [Misc #12935]naruse
Note that 418 I'm a teapot doesn't exist because RFC 2324 and RFC 7168 are not registered in IANA repository. https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Add more HTTP status classesnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19* 2017-05-20svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Net::HTTP#start now pass :ENV to p_addr by default [Bug #13351]naruse
To avoid this, pass nil explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19compile.c: dump_disasm_list_with_cursornobu
* compile.c (dump_disasm_list_with_cursor): improve disassemble list. show whole elemetns and mark the current element. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Merge latest dtoa.c [Bug #13545]naruse
Apply some part of http://www.netlib.org/fp/dtoa.c with my eyes... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Of course, opened file is not able to unlink on Windowsusa
* test/test_tempfile.rb (test_create_with_block): close the tempfile before unlink. fixed a failure on Windows introduced at r58791. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19tempfile.rb: do not call File.identical? on closed streamnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19net/imap: Net::IMAP#append should not block when NO response is receivedshugo
[ruby-dev:50129] [Bug#13579] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19tempfile.rb: remove in Tempfile.createnobu
* lib/tempfile.rb (Tempfile.create): should not fail even if the temporary file has been removed in the block, just ignore. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19add specs for Unicode-wide case conversions introduced in Ruby 2.4duerst
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19improve examples, fix one improbably should_not valueduerst
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19specify unsigned (fix r58784).ko1
* method.h (rb_method_definition_t#type): specify unsigned explicitly. Some compilers (includes VC) returns negative value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19fix syntax errornobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19eval_error.c: enrich backtracenobu
* eval_error.c (print_backtrace): add frame number when printing in reverse order. [Feature #8661] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Add NEWS about [Feature #8661]naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19method.h: pack rb_method_definition_t structnormal
We only have 12 method types, so 4 bits is enough for rb_method_type_t. Size reductions: - x86-64 48 => 40 bytes - x86 28 => 24 bytes * method.h (enum method_optimized_type): split out for CPP (struct rb_method_definition struct): pack on unaligned systems (rb_method_definition_t): split typedef to help ctags [ruby-core:81236] [Feature #13494] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-18Fix strange indentationk0kubun
which I introduced at r58773. Hard tabs and spaces are mixed... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-18* 2017-05-19svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-18common.mk: path in parse.cnobu
* common.mk (parse.c): replace source file name in #line pragmas with the path in the source directory, so that binary utilities, e.g. gcov, can find it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-18potential memory leaknobu
* dir.c (rb_dir_getwd): get rid of potential memory leak. * util.c (ruby_getcwd): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e