| Age | Commit message (Collapse) | Author |
|
The old code lost information of lineno. Now, an assertion error will
output a correct lineno (but now gcc 8 requires 250 MB, unfortunately).
|
|
The assertion blows up gcc 8 by consuming approx. 1.8 GB memory.
This change reduces the amount of memory required to about 200 MB.
A follow-up of ae750799c1b28b06d02e50cd26450b9903516526.
|
|
|
|
"Therefore, `fiber_pool_stack_free(&vacancy->stack)` can do the wrong
thing..." should be "... `fiber_pool_stack_free(stack)` ...".
|
|
After calling `fiber_pool_vacancy_reset`, `vacancy->stack` and `stack` are
no longer in sync. Therefore, `fiber_pool_stack_free(&vacancy->stack)` can
do the wrong thing and clobber the vacancy data.
Additionally, when testing using VM_CHECK_MODE > 0, use MADV_DONTNEED if
possible, to catch issues w.r.t. clobbered vacancy data earlier.
|
|
Change debug_counters for Hash object counts:
* obj_hash_under4 (1-3) -> obj_hash_1_4 (1-4)
* obj_hash_ge4 (4-7) -> obj_hash_5_8 (5-8)
* obj_hash_ge8 (>=8) -> obj_hash_g8 (> 8)
For example on rdoc benchmark:
[RUBY_DEBUG_COUNTER] obj_hash_empty 554,900
[RUBY_DEBUG_COUNTER] obj_hash_under4 572,998
[RUBY_DEBUG_COUNTER] obj_hash_ge4 1,825
[RUBY_DEBUG_COUNTER] obj_hash_ge8 2,344
[RUBY_DEBUG_COUNTER] obj_hash_empty 553,097
[RUBY_DEBUG_COUNTER] obj_hash_1_4 571,880
[RUBY_DEBUG_COUNTER] obj_hash_5_8 982
[RUBY_DEBUG_COUNTER] obj_hash_g8 2,189
|
|
FL_TEST() uses FL_ABLE() which test data types. However,
in array.c we don't need to check it (all of them should be
T_ARRAY), so I changed from FL_TEST() to FL_TEST_RAW() which
does not check FL_ABLE(). Instead of FL_ABLE(), add assertion
to check given object is a T_ARRAY object.
For example, rb_ary_free() becomes slim:
with FL_TEST():
0000000000006a30 <rb_ary_free>:
6a30: 40 f6 c7 07 test $0x7,%dil
6a34: 48 8b 07 mov (%rdi),%rax
6a37: 75 09 jne 6a42 <rb_ary_free+0x12>
6a39: 48 f7 c7 f7 ff ff ff test $0xfffffffffffffff7,%rdi
6a40: 75 1e jne 6a60 <rb_ary_free+0x30>
6a42: a9 00 00 00 02 test $0x2000000,%eax
6a47: 74 07 je 6a50 <rb_ary_free+0x20>
6a49: f3 c3 repz retq
6a4b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
6a50: 48 8b 7f 20 mov 0x20(%rdi),%rdi
6a54: e9 00 00 00 00 jmpq 6a59 <rb_ary_free+0x29>
6a59: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
6a60: 89 c2 mov %eax,%edx
6a62: 83 e2 1f and $0x1f,%edx
6a65: 83 fa 1b cmp $0x1b,%edx
6a68: 74 d8 je 6a42 <rb_ary_free+0x12>
6a6a: f6 c4 60 test $0x60,%ah
6a6d: 74 d3 je 6a42 <rb_ary_free+0x12>
6a6f: eb d8 jmp 6a49 <rb_ary_free+0x19>```
with FL_TEST_RAW():
0000000000006a30 <rb_ary_free>:
6a30: 48 f7 07 00 60 00 02 testq $0x2006000,(%rdi)
6a37: 74 07 je 6a40 <rb_ary_free+0x10>
6a39: f3 c3 repz retq
6a3b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
6a40: 48 8b 7f 20 mov 0x20(%rdi),%rdi
6a44: e9 00 00 00 00 jmpq 6a49 <rb_ary_free+0x19>
|
|
|
|
Shared arrays created by Array#dup and so on points
a shared_root object to manage lifetime of Array buffer.
However, sometimes shared_root is called only shared so
it is confusing. So I fixed these wording "shared" to "shared_root".
* RArray::heap::aux::shared -> RArray::heap::aux::shared_root
* ARY_SHARED() -> ARY_SHARED_ROOT()
* ARY_SHARED_NUM() -> ARY_SHARED_ROOT_REFCNT()
Also, add some debug_counters to count shared array objects.
* ary_shared_create: shared ary by Array#dup and so on.
* ary_shared: finished in shard.
* ary_shared_root_occupied: shared_root but has only 1 refcnt.
The number (ary_shared - ary_shared_root_occupied) is meaningful.
|
|
|
|
|
|
|
|
|
|
|
|
ruby/ruby.h includes ruby/assert.h, and RUBY_NDEBUG is defined
by checking NDEBUG. In other words, NDEBUG is only seen just
after ruby/ruby.h. This patch also cheks NDEBUG just after
including ruby_assert.h.
Without this patch, assertions in array.c are always enabled.
|
|
[Feature #16003] [ruby-dev:50814]
|
|
fiber->cont.saved_ec.cfp should be initialized by NULL
because no vm_stack is allocated. However, cont_init()
captures current Fiber's cfp for continuation, so it should
only initialize fibers.
|
|
This reverts commit d7fdf45a4ae1bcb6fac30a24b025d4f20149ba0a.
|
|
|
|
`cont_init` didn't initialize `cont->saved_ec.cfp`. Calling `cont_mark`
would result in an invalid `cfp` in `rb_execution_context_mark`. Because
fibers lazy-initialize the stack, fibers that are created but not resumed
could cause this problem to occur.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If `mmap` fails to allocate memory, try half the size, and so on.
Limit FIBER_POOL_ALLOCATION_MAXIMUM_SIZE to 1024 stacks. In typical
configurations this limits the memory mapped region to ~128MB per
allocation.
|
|
|
|
|
|
We use COROUTINE_LIMITED_ADDRESS_SPACE to select platforms where address
space is 32-bits or less. Fiber pool implementation enables more book
keeping, and reduces upper limits, in order to minimise address space
utilisation.
|
|
`madvise(free)` and similar operations are good because they avoid swap
usage by clearing the dirty bit on memory pages which are mapped but no
longer needed. However, there is some performance penalty if there is no
memory pressure. Therefore, we do it by default, but it can be avoided.
|
|
|
|
On 32-bit platforms, expanding the fiber pool by a large amount may fail,
even if a smaller amount may succeed. We limit the maximum size of a single
allocation to maximise the number of fibers that can be allocated.
Additionally, we implement the book-keeping required to free allocations
when their usage falls to zero.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Replace previous stack cache with fiber pool cache. The fiber pool
allocates many stacks in a single memory region. Stack allocation
becomes O(log N) and fiber creation is amortized O(1). Around 10x
performance improvement was measured in micro-benchmarks.
|
|
|
|
|
|
See https://bugs.ruby-lang.org/issues/16009 for more details.
|
|
|
|
to suppress many warnings of Coverity Scan
|