From: Per Jessen <per@computer.org>
To: linux-c-programming@vger.kernel.org
Subject: Re: String comparison for fixed strings
Date: Fri, 17 Aug 2007 09:49:22 +0200 [thread overview]
Message-ID: <46C55302.2050209@computer.org> (raw)
In-Reply-To: <18116.37866.145972.803283@cerise.gclements.plus.com>
Glynn Clements wrote:
> In particular, branch instructions are dealt with by dedicated logic
> circuitry which does nothing but process branch instructions. This
> enables speculative execution to work handle branches even when the
> calculation of the branch condition hasn't completed.
Yep, I understand all that - it doesn't even have to be a particularly
modern CPU, even IBMs S390 architecture did this in the early '90s.
Speculative execution and branch prediction etc. have both been around
for a while, just not in the Intel world.
Regardless, I still wouldn't say "branches don't normally take any CPU
cycles", but maybe that's splitting hairs.
> The actual cost of a code cache miss varies depending upon the
> relative speed of the CPU and RAM, but 400 cycles is typical. You
> would need to have a lot of additional instructions before their cost
> outweighs that of a cache miss.
Very true, but given the size of L1 cache these days, you also have a
lot more leeway than you did e.g. in the 90s. A typical memcmp() for
short strings is unrolled by default by gcc. (at least I'm fairly
certain it does that).
/Per
next prev parent reply other threads:[~2007-08-17 7:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-15 11:06 String comparison for fixed strings KhaOsh
2007-08-15 13:18 ` Stephen Kratzer
2007-08-15 14:46 ` Glynn Clements
2007-08-15 17:26 ` Leslie P. Polzer
2007-08-16 1:44 ` Glynn Clements
2007-08-16 7:30 ` Per Jessen
2007-08-16 18:14 ` Glynn Clements
2007-08-17 7:49 ` Per Jessen [this message]
2007-08-17 20:22 ` KhaOsh
2007-08-16 1:54 ` Glynn Clements
2007-08-15 18:51 ` Jesse Ruffin
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=46C55302.2050209@computer.org \
--to=per@computer.org \
--cc=linux-c-programming@vger.kernel.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.
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).