Skip to content

Use language TLS specifier if it is possible. #3667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2020
Merged

Conversation

ko1
Copy link
Contributor

@ko1 ko1 commented Oct 19, 2020

To access TLS, it is faster to use language TLS specifier instead
of using pthread_get/setspecific functions.

Original proposal is: Use native thread locals. #3665

@ko1 ko1 force-pushed the use_language_tls branch 2 times, most recently from 75594d4 to ef17f78 Compare October 19, 2020 13:04
To access TLS, it is faster to use language TLS specifier instead
of using pthread_get/setspecific functions.

Original proposal is: Use native thread locals. ruby#3665
@ko1 ko1 force-pushed the use_language_tls branch from ef17f78 to 5cf18a7 Compare October 19, 2020 13:41
@ko1
Copy link
Contributor Author

ko1 commented Oct 19, 2020

Benchmark.driver(repeat_count: 5
                 #, runner: :once
                 ){|x|
  x.executable name: 'ruby27_static_miniruby', command: %w'../ruby_2_7_static/miniruby'
  x.executable name: 'ruby27_miniruby',        command: %w'../ruby_2_7/miniruby'
  x.executable name: 'master_static_miniruby', command: %w'../clean-st/miniruby'
  x.executable name: 'master_miniruby',        command: %w'../clean/miniruby'
  x.executable name: 'modified_miniruby',      command: %w'./miniruby'

  x.executable name: 'ruby27_static', command: %w'/home/ko1/ruby/v3/install/ruby_2_7_static/bin/ruby'
  x.executable name: 'ruby27',        command: %w'/home/ko1/ruby/v3/install/ruby_2_7/bin/ruby'
  x.executable name: 'master-static', command: %w'/home/ko1/ruby/v3/install/clean-st/bin/ruby'
  x.executable name: 'master',        command: %w'/home/ko1/ruby/v3/install/clean/bin/ruby'
  x.executable name: 'modified',      command: %w'/home/ko1/ruby/v3/install/trunk/bin/ruby'

  x.prelude %q{
    p $:
    f = Fiber.new do
      loop do
        Fiber.yield
      end
    end
  }
  x.report 'f.resume'
}
Warming up --------------------------------------
            f.resume                10.475M i/s -     10.524M times in 1.004680s (95.46ns/i, 361clocks/i)
Calculating -------------------------------------
                     ruby27_static_miniruby  ruby27_miniruby  master_static_miniruby  master_miniruby  modified_miniruby  ruby27_static      ruby27  master-static      master    modified
            f.resume                12.447M          10.077M                  8.664M           8.048M            11.155M        12.310M      9.430M         8.484M      7.927M     11.316M i/s -     31.425M times in 2.524700s 3.118576s 3.626964s 3.904665s 2.817025s 2.552897s 3.332431s 3.703976s 3.964356s 2.777091s

Comparison:
                         f.resume
ruby27_static_miniruby:  12447150.4 i/s
       ruby27_static:  12309671.8 i/s - 1.01x  slower
            modified:  11315913.9 i/s - 1.10x  slower
   modified_miniruby:  11155499.1 i/s - 1.12x  slower
     ruby27_miniruby:  10076819.6 i/s - 1.24x  slower
              ruby27:   9430148.9 i/s - 1.32x  slower
master_static_miniruby:   8664359.8 i/s - 1.44x  slower
       master-static:   8484214.3 i/s - 1.47x  slower
     master_miniruby:   8048149.4 i/s - 1.55x  slower
              master:   7926969.1 i/s - 1.57x  slower

@ko1 ko1 merged commit 319afed into ruby:master Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant