aboutsummaryrefslogtreecommitdiffstats
path: root/cont.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Add experimental `RUBY_SHARED_FIBER_POOL_FREE_STACKS` to control madvise.Samuel Williams2019-07-181-0/+5
|
* Make fiber_pool more conservative on platforms with limited address space.Samuel Williams2019-07-181-12/+12
| | | | | | | 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.
* Add `struct fiber_pool {int free_stacks;}` to control usage of madvise.Samuel Williams2019-07-181-1/+10
| | | | | | | `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.
* Add FIBER_POOL_ALLOCATION_FREE to control allocation/free strategy.Samuel Williams2019-07-181-8/+43
|
* Limit expansion of fiber pool on 32-bit platforms.Samuel Williams2019-07-181-46/+150
| | | | | | | | | 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.
* Enable `madvise` to release stack space back to OS.Samuel Williams2019-07-181-98/+142
|
* Improve build process and coroutine implementation selection.Samuel Williams2019-07-181-6/+1
|
* Stack copying implementation of coroutines.Samuel Williams2019-07-181-2/+23
|
* Implement fiber pool for reduced fiber allocation overhead.Samuel Williams2019-07-181-192/+508
| | | | | | | 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.
* Make FIBER_USE_NATIVE the default and reformat code.Samuel Williams2019-07-181-518/+252
|
* * expand tabs.git2019-07-081-35/+35
|
* Fix indentNobuyoshi Nakada2019-07-081-4/+4
|
* Renamed fib to fiberNobuyoshi Nakada2019-07-081-244/+244
|
* Use native coroutine implementation on OpenBSD-amd64Jeremy Evans2019-06-261-1/+0
| | | | When using native fibers, do not load ucontext, as it isn't needed.
* Add `ucontext` coroutine implementation for generic fallback.Samuel Williams2019-06-261-4/+4
|
* * remove trailing spaces.git2019-06-241-1/+1
|
* Print warning if not using native coroutine.Samuel Williams2019-06-241-0/+2
|
* Transition root fiber into state FIBER_TERMINATED.Samuel Williams2019-06-201-0/+11
| | | | | | | During fork, it's possible that threads with root fibers are terminated, but fiber state is not updated. `fiber_verify` will subsequently fail. We forcefully enter the FIBER_TERMINATED state when terminating the root fiber.
* Ensure that vm_stack is cleared in `thread_cleanup_func_before_exec`.Samuel Williams2019-06-201-9/+2
| | | | | | | | If `vm_stack` is left dangling in a forked process, the gc attempts to scan it, but it is invalid and will cause a segfault. Therefore, we clear it before forking. In order to simplify this, `rb_ec_clear_vm_stack` was introduced.
* Revert failed attempt at fixing invalid usage of vm_stack.Samuel Williams2019-06-201-2/+9
|
* Ensure `vm_stack` is cleared after fork.Samuel Williams2019-06-201-10/+2
|
* Set `cfp` to null (along with vm_stack) in `rb_fiber_close`.Samuel Williams2019-06-201-0/+1
|
* Adjust indentNobuyoshi Nakada2019-06-191-1/+1
|
* Remove IA64 support.Samuel Williams2019-06-191-92/+1
|
* Use shared implementation of `rb_ec_initialize_vm_stack`.Samuel Williams2019-06-191-13/+1
|
* Track how stack was allocated for `cont_free`.Samuel Williams2019-06-191-8/+21
|
* Better handling of root fiber.Samuel Williams2019-06-191-4/+3
|
* * expand tabs.git2019-06-121-3/+3
|
* Add compaction support for more types.Aaron Patterson2019-06-111-5/+37
| | | | | | | | This commit adds compaction support for: * Fibers * Continuations * Autoload Constants
* ia64: Don't clear register_stack_startJames Clarke2019-04-271-1/+0
| | | | | | | | r59829 stopped clearing stack_start and enabled the code for !FIBER_USE_NATIVE, but we need to do the same for register_stack_start on ia64, otherwise we end up with NULL in cont_save_machine_stack. Closes: https://github.com/ruby/ruby/pull/2155
* [DOC] fix markups [ci skip]nobu2019-03-221-25/+24
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix styles [ci skip]nobu2019-01-091-2/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix #endif annotation.samuel2018-12-281-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Don't allow rb_fiber_resume to raise exception on unborn fiber.samuel2018-12-281-0/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Implement Fiber#raise. Fixes #10344.samuel2018-12-281-0/+29
| | | | | | | This allows raising exceptions in another fiber, similarly to Thread#raise. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Avoid GCing dead stack after switching away from a fibersamuel2018-12-011-0/+1
| | | | | | | Fixes <https://bugs.ruby-lang.org/issues/14561> and discussed <https://bugs.ruby-lang.org/issues/15362>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Give up support for cross-callcc set_trace_func.ko12018-11-261-1/+4
| | | | | | | * cont.c (cont_restore_thread): cause error if trace-status is changed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Support targetting TracePoint [Feature #15289]ko12018-11-261-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * vm_trace.c (rb_tracepoint_enable_for_target): support targetting TracePoint. [Feature #15289] Tragetting TracePoint is only enabled on specified method, proc and so on, example: `tp.enable(target: code)`. `code` should be consisted of InstructionSeuqnece (iseq) (RubyVM::InstructionSeuqnece.of(code) should not return nil) If code is a tree of iseq, TracePoint is enabled on all of iseqs in a tree. Enabled tragetting TracePoints can not enabled again with and without target. * vm_core.h (rb_iseq_t): introduce `rb_iseq_t::local_hooks` to store local hooks. `rb_iseq_t::aux::trace_events` is renamed to `global_trace_events` to contrast with `local_hooks`. * vm_core.h (rb_hook_list_t): add `rb_hook_list_t::running` to represent how many Threads/Fibers are used this list. If this field is 0, nobody using this hooks and we can delete it. This is why we can remove code from cont.c. * vm_core.h (rb_vm_t): because of above change, we can eliminate `rb_vm_t::trace_running` field. Also renamed from `rb_vm_t::event_hooks` to `global_hooks`. * vm_core.h, vm.c (ruby_vm_event_enabled_global_flags): renamed from `ruby_vm_event_enabled_flags. * vm_core.h, vm.c (ruby_vm_event_local_num): added to count enabled targetting TracePoints. * vm_core.h, vm_trace.c (rb_exec_event_hooks): accepts hook list. * vm_core.h (rb_vm_global_hooks): added for convinience. * method.h (rb_method_bmethod_t): added to maintain Proc and `rb_hook_list_t` for bmethod (defined by define_method). * prelude.rb (TracePoint#enable): extracet a keyword parameter (because it is easy than writing in C). It calls `TracePoint#__enable` internal method written in C. * vm_insnhelper.c (vm_trace): check also iseq->local_hooks. * vm.c (invoke_bmethod): check def->body.bmethod.hooks. * vm.c (hook_before_rewind): check iseq->local_hooks and def->body.bmethod.hooks before rewind by exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use VirtualAlloc/VirtualProtect/VirtualFree for windows stack allocation.samuel2018-11-221-53/+63
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix conditionnobu2018-11-201-2/+2
| | | | | | | FIBER_USE_NATIVE is always defined as 0 or 1, use `#if` instead of `#ifdef`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Make fiber_entry staticnobu2018-11-201-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix windows builds.samuel2018-11-201-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Expose stack functions to coroutine and non-windows implementations.samuel2018-11-201-12/+16
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix exposure of stack allocations.samuel2018-11-201-2/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use malloc/free for windows stack allocation.samuel2018-11-201-11/+20
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove trailing whitespace.samuel2018-11-201-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Restore native non-coroutine code path.samuel2018-11-201-2/+11
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* It cannot be const because it is being passed to destructive operation ↵samuel2018-11-201-1/+1
| | | | | | (destroy). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Better support for amd64 platformssamuel2018-11-201-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Native implementation of coroutines to improve performance of fiberssamuel2018-11-201-16/+63
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e