Skip to content
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

Use Mutex instead of Monitor #2561

Merged
merged 1 commit into from
Aug 15, 2019
Merged

Use Mutex instead of Monitor #2561

merged 1 commit into from
Aug 15, 2019

Conversation

ganmacs
Copy link
Member

@ganmacs ganmacs commented Aug 14, 2019

Signed-off-by: Yuta Iwama [email protected]

Which issue(s) this PR fixes:
Fixes #

What this PR does / why we need it:

I used Mutex when no need reentrant lock since Mutex is faster than Montior.

require 'benchmark/ips'

mo = Monitor.new
mu = Mutex.new

Benchmark.ips do |x|
  x.report("monitor") do
    mo.synchronize {}
  end

  x.report("mutex") do
    mu.synchronize {}
  end
end
Warming up --------------------------------------
             monitor   224.461k i/100ms
               mutex   371.210k i/100ms
Calculating -------------------------------------
             monitor      3.987M (± 2.4%) i/s -     19.977M in   5.013755s
               mutex     10.221M (± 2.5%) i/s -     51.227M in   5.015317s

Docs Changes:

no need

Release Note:

same as title

@ganmacs ganmacs added the enhancement Feature request or improve operations label Aug 14, 2019
@repeatedly repeatedly merged commit 5a7d949 into fluent:master Aug 15, 2019
@repeatedly
Copy link
Member

Looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request or improve operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants