From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] replace a mfence instruction by an xchg instruction
Date: Sat, 15 Aug 2015 16:17:55 -0400 [thread overview]
Message-ID: <20150815201755.GL31018@brightrain.aerifal.cx> (raw)
In-Reply-To: <1439621420.9803.20.camel@dysnomia.u-strasbg.fr>
On Sat, Aug 15, 2015 at 08:51:41AM +0200, Jens Gustedt wrote:
> according to the wisdom of the Internet, e.g
>
> https://peeterjoot.wordpress.com/2009/12/04/intel-memory-ordering-fence-instructions-and-atomic-operations/
>
> a mfence instruction is about 3 times slower than an xchg instruction.
Uhg, then why does this instruction even exist if it does less and
does it slower?
> Here we not only had mfence but also the mov instruction that was to be
> protected by the fence. Replace all that by a native atomic instruction
> that gives all the ordering guarantees that we need.
>
> This a_store function is performance critical for the __lock
> primitive. In my benchmarks to test my stdatomic implementation I have a
> substantial performance increase (more than 10%), just because malloc
> does better with it.
Is there a reason you're not using the same approach as on i386? It
was faster than xchg for me, and in principle it "should be faster".
Rich
next prev parent reply other threads:[~2015-08-15 20:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-15 6:51 Jens Gustedt
2015-08-15 20:17 ` Rich Felker [this message]
2015-08-15 21:01 ` Jens Gustedt
2015-08-15 23:28 ` Rich Felker
2015-08-16 12:42 ` Jens Gustedt
2015-08-16 15:16 ` Rich Felker
2015-08-16 15:50 ` Jens Gustedt
2015-08-16 15:58 ` Rich Felker
2015-08-16 16:16 ` Jens Gustedt
2015-08-16 18:30 ` Rich Felker
2015-08-16 16:07 ` Rich Felker
2015-08-16 16:34 ` Jens Gustedt
2015-08-16 16:28 ` Rich Felker
2015-08-16 16:38 ` Jens Gustedt
2015-08-16 17:00 ` Rich Felker
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150815201755.GL31018@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
/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://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).