~eliasnaur/gio

5 2

Surprising Gio Vulkan vs. OpenGL Performance

Details
Message ID
<CAFcc3FT2GwcmMX+19K-kso7xHCVgdx0HuZ4kUtLFm7ZkeAp8Qg@mail.gmail.com>
DKIM signature
pass
Download raw message
Hey all,

I randomly happened to try building one of my applications yesterday
with `-tags novulkan` while profiling, and the results are really
surprising. The app was 3-5x faster (much shorter frame times) on
OpenGL. I recall being excited when we switched to Vulkan as the
default because (at the time) there was a small performance boost, but
now things look the other way around (maybe as a result of Dominik's
and Egon's work?).

I do most of my dev work from an old intel-based laptop with an
integrated GPU. Here are my results from running the kitchen example
benchmarks on this machine (Notice that making MESA-INTEL happy with
sysctl doesn't significantly change the numbers for the vulkan
results):

These results are from the gio-example commit b12a706.

https://paste.sr.ht/~whereswaldon/f628b0780806e610ccf51e8a19399e063854ca96

I didn't do anything fancy like disabling CPU frequency scaling, so
there's plenty of noise in these benchmarks. That being said, Vulkan
is 3x slower pretty consistently.

I've posted pprof CPU profiles with and without Vulkan enabled in [0]
for anyone interested in seeing them.

Based on this, I have a few questions for performance experts in the community:

- Is there an optimization similar to [1] that we can do to Vulkan?
- Can anyone explain why the layout portion of the benchmark would be
faster on OpenGL? That work is entirely CPU-based. I can't figure out
why using or not using Vulkan should influence it at all.
- Can anyone replicate a performance gap like this on other Linux
machines? Is it unique to Intel chips?

Cheers,
Chris

[0] https://drive.google.com/drive/folders/1_k6Nhsqb6rJk74Tccc71PTYoLb5edzB2?usp=sharing
[1] https://git.sr.ht/~eliasnaur/gio/commit/dab796808acab7948946ae45891686e5f3b4ad95
Details
Message ID
<CANtNKfpS09zNrkO9kuQ6aWwXjJve4KbUX-Kxd6k7eT85j9Fo5g@mail.gmail.com>
In-Reply-To
<CAFcc3FT2GwcmMX+19K-kso7xHCVgdx0HuZ4kUtLFm7ZkeAp8Qg@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
Can you try inspecting the differences in the profiling output
with `-cpuprofile cpu.prof` and `go tool pprof`? It's easier to figure
these things out based on the profile.

Can you try testing things with `-tags nox11`?

+ Egon

On Sat, Aug 13, 2022 at 4:11 PM Chris Waldon
<christopher.waldon.dev@gmail.com> wrote:
>
> Hey all,
>
> I randomly happened to try building one of my applications yesterday
> with `-tags novulkan` while profiling, and the results are really
> surprising. The app was 3-5x faster (much shorter frame times) on
> OpenGL. I recall being excited when we switched to Vulkan as the
> default because (at the time) there was a small performance boost, but
> now things look the other way around (maybe as a result of Dominik's
> and Egon's work?).
>
> I do most of my dev work from an old intel-based laptop with an
> integrated GPU. Here are my results from running the kitchen example
> benchmarks on this machine (Notice that making MESA-INTEL happy with
> sysctl doesn't significantly change the numbers for the vulkan
> results):
>
> These results are from the gio-example commit b12a706.
>
> https://paste.sr.ht/~whereswaldon/f628b0780806e610ccf51e8a19399e063854ca96
>
> I didn't do anything fancy like disabling CPU frequency scaling, so
> there's plenty of noise in these benchmarks. That being said, Vulkan
> is 3x slower pretty consistently.
>
> I've posted pprof CPU profiles with and without Vulkan enabled in [0]
> for anyone interested in seeing them.
>
> Based on this, I have a few questions for performance experts in the community:
>
> - Is there an optimization similar to [1] that we can do to Vulkan?
> - Can anyone explain why the layout portion of the benchmark would be
> faster on OpenGL? That work is entirely CPU-based. I can't figure out
> why using or not using Vulkan should influence it at all.
> - Can anyone replicate a performance gap like this on other Linux
> machines? Is it unique to Intel chips?
>
> Cheers,
> Chris
>
> [0] https://drive.google.com/drive/folders/1_k6Nhsqb6rJk74Tccc71PTYoLb5edzB2?usp=sharing
> [1] https://git.sr.ht/~eliasnaur/gio/commit/dab796808acab7948946ae45891686e5f3b4ad95
Details
Message ID
<CANtNKfqmO=pcXSnyAu0wuCqXgOJG3EiZPdBAaqL-_e1i5crEXA@mail.gmail.com>
In-Reply-To
<CANtNKfpS09zNrkO9kuQ6aWwXjJve4KbUX-Kxd6k7eT85j9Fo5g@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
Ah, I just noticed that there's a link at the end of the email to the
pprof files.

On Mon, Aug 15, 2022 at 8:54 AM Egon Elbre <egonelbre@gmail.com> wrote:
>
> Can you try inspecting the differences in the profiling output
> with `-cpuprofile cpu.prof` and `go tool pprof`? It's easier to figure
> these things out based on the profile.
>
> Can you try testing things with `-tags nox11`?
>
> + Egon
>
> On Sat, Aug 13, 2022 at 4:11 PM Chris Waldon
> <christopher.waldon.dev@gmail.com> wrote:
> >
> > Hey all,
> >
> > I randomly happened to try building one of my applications yesterday
> > with `-tags novulkan` while profiling, and the results are really
> > surprising. The app was 3-5x faster (much shorter frame times) on
> > OpenGL. I recall being excited when we switched to Vulkan as the
> > default because (at the time) there was a small performance boost, but
> > now things look the other way around (maybe as a result of Dominik's
> > and Egon's work?).
> >
> > I do most of my dev work from an old intel-based laptop with an
> > integrated GPU. Here are my results from running the kitchen example
> > benchmarks on this machine (Notice that making MESA-INTEL happy with
> > sysctl doesn't significantly change the numbers for the vulkan
> > results):
> >
> > These results are from the gio-example commit b12a706.
> >
> > https://paste.sr.ht/~whereswaldon/f628b0780806e610ccf51e8a19399e063854ca96
> >
> > I didn't do anything fancy like disabling CPU frequency scaling, so
> > there's plenty of noise in these benchmarks. That being said, Vulkan
> > is 3x slower pretty consistently.
> >
> > I've posted pprof CPU profiles with and without Vulkan enabled in [0]
> > for anyone interested in seeing them.
> >
> > Based on this, I have a few questions for performance experts in the community:
> >
> > - Is there an optimization similar to [1] that we can do to Vulkan?
> > - Can anyone explain why the layout portion of the benchmark would be
> > faster on OpenGL? That work is entirely CPU-based. I can't figure out
> > why using or not using Vulkan should influence it at all.
> > - Can anyone replicate a performance gap like this on other Linux
> > machines? Is it unique to Intel chips?
> >
> > Cheers,
> > Chris
> >
> > [0] https://drive.google.com/drive/folders/1_k6Nhsqb6rJk74Tccc71PTYoLb5edzB2?usp=sharing
> > [1] https://git.sr.ht/~eliasnaur/gio/commit/dab796808acab7948946ae45891686e5f3b4ad95
Details
Message ID
<CAFcc3FQZ90K9TtB7gUYi0mm2RPBfXzNpBEb2KgPB5zx0KAkX3g@mail.gmail.com>
In-Reply-To
<CANtNKfpS09zNrkO9kuQ6aWwXjJve4KbUX-Kxd6k7eT85j9Fo5g@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
> Can you try inspecting the differences in the profiling output
> with `-cpuprofile cpu.prof` and `go tool pprof`? It's easier to figure
> these things out based on the profile.

Sorry for not making the pprof profiles more prominent in my original
email. For anyone else reading, they can be found here:

https://drive.google.com/drive/folders/1_k6Nhsqb6rJk74Tccc71PTYoLb5edzB2?usp=sharing

> Can you try testing things with `-tags nox11`?

This testing was already performed from wayland, though I did neglect
to mention that. Sorry! Vulkan doesn't get used  on X11 unless you
patch Gio to re-enable it.

I tried running the benchmark with GODEBUG=cgocheck=0, and that didn't
improve the Vulkan numbers at all. I guess this isn't the same
category of problem as the OpenGL issue I linked earlier.

Thanks for looking at the profiles!

Cheers,
Chris
Details
Message ID
<CAFcc3FSzBz3cM3BDr-bkbhBrhturRuoPcH7AwyfkabFY44HFpA@mail.gmail.com>
In-Reply-To
<CANtNKfpS09zNrkO9kuQ6aWwXjJve4KbUX-Kxd6k7eT85j9Fo5g@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
> Can you try testing things with `-tags nox11`?

I profiled the default tags, nox11, novulkan, and the combination of
nox11+novulkan. For this one, I did lock my CPU frequency to 2.7Ghz
and ran a minimal environment for the duration, so there should be
much less noise in these numbers.

https://paste.sr.ht/~whereswaldon/7c7ffc6193ae493ae9d8e39aa964c8c8d8366d46
Details
Message ID
<CAFcc3FS1_q=psRbLaso=mROtJFJWHN6X45q_PQXD-3RUoJqp4Q@mail.gmail.com>
In-Reply-To
<CAFcc3FSzBz3cM3BDr-bkbhBrhturRuoPcH7AwyfkabFY44HFpA@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
> I profiled the default tags, nox11, novulkan, and the combination of
> nox11+novulkan. For this one, I did lock my CPU frequency to 2.7Ghz
> and ran a minimal environment for the duration, so there should be
> much less noise in these numbers.
>
> https://paste.sr.ht/~whereswaldon/7c7ffc6193ae493ae9d8e39aa964c8c8d8366d46

I will say that these numbers answer the question "Why is layout code
running faster with novulkan?". Now that I've locked the CPU
frequency, layout always takes the same amount of time, so the answer
there was "when running on OpenGL, the CPU ran at a higher average
frequency". However, the difference between Vulkan and OpenGL is quite
stark in these results. In the normal case, OpenGL is about 4x faster,
and in the extreme cases closer to 6x.
Reply to thread Export thread (mbox)