From: Eric Wong <e@80x24.org>
To: raindrops-public@bogomips.org
Subject: [PATCH 1/3] aggregate/pmq: avoid false sharing of lock buffers
Date: Thu, 16 Mar 2017 03:14:10 +0000 [thread overview]
Message-ID: <20170316031412.16713-2-e@80x24.org> (raw)
In-Reply-To: <20170316031412.16713-1-e@80x24.org>
And rely on frozen string optimizations in Ruby while we're at it.
---
lib/raindrops/aggregate/pmq.rb | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/raindrops/aggregate/pmq.rb b/lib/raindrops/aggregate/pmq.rb
index a2dd45e..f543302 100644
--- a/lib/raindrops/aggregate/pmq.rb
+++ b/lib/raindrops/aggregate/pmq.rb
@@ -39,9 +39,9 @@ class Raindrops::Aggregate::PMQ
# :stopdoc:
# These constants are for Linux. This is designed for aggregating
# TCP_INFO.
- RDLOCK = [ Fcntl::F_RDLCK ].pack("s @256")
- WRLOCK = [ Fcntl::F_WRLCK ].pack("s @256")
- UNLOCK = [ Fcntl::F_UNLCK ].pack("s @256")
+ RDLOCK = [ Fcntl::F_RDLCK ].pack("s @256".freeze).freeze
+ WRLOCK = [ Fcntl::F_WRLCK ].pack("s @256".freeze).freeze
+ UNLOCK = [ Fcntl::F_UNLCK ].pack("s @256".freeze).freeze
# :startdoc:
# returns the number of dropped messages sent to a POSIX message
@@ -185,10 +185,12 @@ def lock! io, type # :nodoc:
def synchronize io, type # :nodoc:
@mutex.synchronize do
begin
+ type = type.dup
lock! io, type
yield io
ensure
- lock! io, UNLOCK
+ lock! io, type.replace(UNLOCK)
+ type.clear
end
end
end
--
EW
next prev parent reply other threads:[~2017-03-16 3:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-16 3:14 [PATCH 0/3] aggregate/pmq: various fixes and cleanups Eric Wong
2017-03-16 3:14 ` Eric Wong [this message]
2017-03-16 3:14 ` [PATCH 2/3] aggregate/pmq: remove io-extra requirement Eric Wong
2017-03-16 3:14 ` [PATCH 3/3] aggregate/pmq: avoid File#stat allocation Eric Wong
2017-03-21 23:48 ` [PATCH 0/3] aggregate/pmq: various fixes and cleanups Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/raindrops/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170316031412.16713-2-e@80x24.org \
--to=e@80x24.org \
--cc=raindrops-public@bogomips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/raindrops.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).