From: nobu@... Date: 2018-05-05T12:00:18+00:00 Subject: [ruby-core:86905] [Ruby trunk Feature#14739] Improve fiber yield/resume performance Issue #14739 has been updated by nobu (Nobuyoshi Nakada). ioquatix (Samuel Williams) wrote: > > Also, asm needed to be replaced with `__asm__` to compile with Apple clang > > I didn't have this problem. What version of the developer tools are you using? ``` $ clang --version Apple LLVM version 8.0.0 (clang-800.0.42.1) Target: x86_64-apple-darwin15.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin ``` > If you get that, something is wrong, it's definitely a much bigger improvement than that. Did you try it on Linux? On Ubuntu 18.04, it has the effect with `gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)`. ### trunk ``` $ ./x86_64-linux/exe/ruby src/fiber_benchmark.rb 10000 1000 setup time for 10000 fibers: 0.153903 execution time for 1000 messages: 25.395488 ``` ### fiber-libcoro ``` $ make -C x86_64-linux prog > /dev/null && ./x86_64-linux/exe/ruby src/fiber_benchmark.rb 10000 1000 In file included from ../src/libcoro/coro.c:41:0, from ../src/cont.c:51: ../src/cont.c: In function ���cont_free���: ../src/libcoro/coro.h:401:28: warning: statement with no effect [-Wunused-value] # define coro_destroy(ctx) (void *)(ctx) ^~~~~~~~~~~~~ ../src/cont.c:370:2: note: in expansion of macro ���coro_destroy��� coro_destroy((coro_context *)&fib->context); ^~~~~~~~~~~~ ../src/cont.c: In function ���fiber_initialize_machine_stack_context���: ../src/cont.c:862:32: warning: passing argument 2 of ���coro_create��� from incompatible pointer type [-Wincompatible-pointer-types] coro_create(&fib->context, rb_fiber_start, NULL, fib->ss_sp, fib->ss_size); ^~~~~~~~~~~~~~ In file included from ../src/cont.c:51:0: ../src/libcoro/coro.c:331:1: note: expected ���coro_func {aka void (*)(void *)}��� but argument is of type ���__attribute__((noreturn)) void (*)(void)��� coro_create (coro_context *ctx, coro_func coro, void *arg, void *sptr, size_t ssize) ^~~~~~~~~~~ In file included from ../src/libcoro/coro.c:41:0, from ../src/cont.c:51: ../src/cont.c: In function ���rb_fiber_terminate���: ../src/libcoro/coro.h:401:28: warning: statement with no effect [-Wunused-value] # define coro_destroy(ctx) (void *)(ctx) ^~~~~~~~~~~~~ ../src/cont.c:1799:5: note: in expansion of macro ���coro_destroy��� coro_destroy(&fib->context); ^~~~~~~~~~~~ ../src/cont.c: At top level: cc1: warning: unrecognized command line option ���-Wno-self-assign��� cc1: warning: unrecognized command line option ���-Wno-constant-logical-operand��� cc1: warning: unrecognized command line option ���-Wno-parentheses-equality��� setup time for 10000 fibers: 0.146823 execution time for 1000 messages: 7.855211 ``` ---------------------------------------- Feature #14739: Improve fiber yield/resume performance https://bugs.ruby-lang.org/issues/14739#change-71867 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- I am interested to improve Fiber yield/resume performance. I've used this library before: http://software.schmorp.de/pkg/libcoro.html and handled millions of HTTP requests using it. I'd suggest to use that library. As this is used in many places in Ruby (e.g. enumerable) it could be a big performance win across the board. Here is a nice summary of what was done for RethinkDB: https://rethinkdb.com/blog/making-coroutines-fast/ Does Ruby currently reuse stacks? This is also a big performance win if it's not being done already. -- https://bugs.ruby-lang.org/ Unsubscribe: