#725: [PATCH] Add c-level branch prediction annotations
----------------------+-----------------------------------------------------
Reporter: Infinoid | Owner:
Type: patch | Status: new
Priority: normal | Milestone:
Component: none | Version: 1.2.0
Severity: medium | Keywords:
Lang: | Patch: new
Platform: |
----------------------+-----------------------------------------------------
Gcc allows you to tell the optimizer which path of a branch is more
likely. The Linux kernel uses this heavily, through the use of the
likely() and unlikely() macros.
This patch adds these to parrot, and starts using them in a few places.
I intend to update this patch to add more annotations; I have callgrind
data from a non-optimized parrot, but I need to re-analyze it for an
optimized parrot. (non-optimized GCC doesn't make use of the annotations,
and optimized GCC generates code which looks quite a bit different.)
The first rev of this patch already seems to make about half a second of
difference. It's not huge, but it is measurable. Before:
{{{
./perl6 -e 'my $i = 0; while ( $i < 100000) { $i++ }' 39.32s user 1.39s
system 99% cpu 40.933 total
./perl6 -e 'my $i = 0; while ( $i < 100000) { $i++ }' 39.20s user 1.46s
system 99% cpu 40.991 total
./perl6 -e 'my $i = 0; while ( $i < 100000) { $i++ }' 39.08s user 1.41s
system 99% cpu 40.766 total
./perl6 -e 'my $i = 0; while ( $i < 100000) { $i++ }' 38.69s user 1.42s
system 99% cpu 40.250 total
./perl6 -e 'my $i = 0; while ( $i < 100000) { $i++ }' 39.25s user 1.38s
system 98% cpu 41.148 total
}}}
After:
{{{
./perl6 -e 'my $i = 0; while ( $i < 100000) { $i++ }' 38.54s user 1.40s
system 99% cpu 40.211 total
./perl6 -e 'my $i = 0; while ( $i < 100000) { $i++ }' 37.98s user 1.49s
system 98% cpu 40.193 total
./perl6 -e 'my $i = 0; while ( $i < 100000) { $i++ }' 38.57s user 1.46s
system 99% cpu 40.349 total
./perl6 -e 'my $i = 0; while ( $i < 100000) { $i++ }' 39.16s user 1.33s
system 99% cpu 40.864 total
./perl6 -e 'my $i = 0; while ( $i < 100000) { $i++ }' 37.91s user 1.53s
system 98% cpu 40.064 total
}}}
I believe we can improve this further, by making heavier use of it. This
will take some work to find these cases, though. Any case where you see a
branch in callgrind which hits 6 million times and misses 3 times (or
less), or vice versa, could use one of these annotations.
--
Ticket URL: <https://trac.parrot.org/parrot/ticket/725>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets