* 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
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
* 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
* 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
* 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
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
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
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
* 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
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
* 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
* 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
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
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
* 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
* spec/rubyspec/command_line/dash_upper_s_spec.rb: enable tests on vboxsf
(VirtualBox shared directory) and change tests to match /success$/ to
ignore warnings. This technique is suggested by @unak.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
for future backport to ruby/spec repository.
See r58772 r58773 r58774.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to make it compatible with ERB::Util.url_encode.
ext/cgi/escape/escape.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Based on patch by madeofcode (Mark Dodwell).
[ruby-core:46168] [Bug #6696] [Fix GH-54]
`~` is a unreserved character.
https://tools.ietf.org/html/rfc3986#section-2.3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c (process_options): encode script name to locale encoding
instead of associate, if UTF-8 path.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* .gdbinit (nd_tree): use rb_str_tmp_new to get rid of
`__extension__'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/ruby/test_dir_m17n.rb (test_entries_compose): read in
filesystem encoding instead of default external encoding on
Windows too. these two encodings may differ on some
environments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e