Front page | perl.perl5.porters |
Postings from January 2018
Re: regrepeat()
Thread Previous
From:
Karl Williamson
Date:
January 20, 2018 23:02
Subject:
Re: regrepeat()
Message ID:
dfe09121-8a68-b19d-a4c2-b4b79417ce27@khwilliamson.com
On 01/20/2018 11:52 AM, Karl Williamson wrote:
> As I write this, I realize that there is a way for the 2nd loop to
> figure out which byte it is without conditionals. The fastest way is to
> use xor and ffs(), if available (which on modern computers becomes a
> single machine instruction), but there are other ways, using shift, mask
> and integer multiply, similar to what S__variant_byte_number() in
> inline.h currently does.
It turned out to be easy to do this, and the result is at
https://perl5.git.perl.org/perl.git/commitdiff/6651cd938a2f4e2355783bab8cb4e30a6fc914e1
So the third loop only gets executed if there are bytes past the end of
the final full word, and that word is completely spanned. The
parallelization more than makes up for this.
The real issue these days is adding conditionals, and in particular ones
where the prediction fails. This code adds one in all cases, and a
second where the parallelization gets invoked (because of the loop to
get to the word boundary) But the parallelization cuts 3 or 7
conditionals for each loop iteration, so that more than balances that
2nd conditional. So, I'm now thinking the WORTH_IT value can be pretty
small.
Thread Previous