servo / pathfinder

A fast, practical GPU rasterizer for fonts and vector graphics
Apache License 2.0
3.6k stars 201 forks source link

High CPU usage and strange timer query results on complex scenes #154

Open rvolgers opened 5 years ago

rvolgers commented 5 years ago

I'm using "Radeon RX 560" on Linux. Pathfinder is built in release mode.

When moving around in 3D in the demo on complex scenes such as "paper.svg" CPU usage is between 100-400% and stage 0 GPU time is dominating the rendering time at about 200ms. Even so, everything appears quite smooth.

I have a couple of questions about the performance:

This is certainly not urgent but I feel like these questions may arise with other people trying to evaluate Pathfinder's performance.

System specs:

Screenshot from 2019-05-22 17-59-36

pcwalton commented 5 years ago

Rendering should definitely not be smooth if the GPU time is 200 ms. Possibly you're hitting a driver bug regarding OpenGL timer queries.

Regarding the CPU usage, Pathfinder 3 is a hybrid CPU-GPU renderer that runs the CPU and GPU simultaneously for maximum performance, following the philosophy that we should use all the silicon in the device. So you should expect to see rather high CPU usage on complex scenes. Over time I would like to experiment with optionally moving some of the CPU steps to the GPU. This hasn't been done yet because (a) I'm not sure it will be a win, because the GPU is already fairly loaded; (b) it will probably require compute shader, which would raise the hardware requirements too high. However, I expect a more GPU-heavy pipeline could be useful in two primary cases: (1) lower-end mobile devices that have slower CPUs relative to the GPU; (2) applications that are already putting a lot of load on the CPU and don't have cycles to spare.

pcwalton commented 5 years ago

Also, eventually I'd like to add some kind of sprite feature for text so that glyphs can be cached. This is tricky to do in 3D without regressing quality, of course.

rvolgers commented 5 years ago

I made a mistake in the original report: it's "stage 0 GPU" that is dominating rendering time at ~200ms, not "stage 2" (which doesn't even exist, oops). Attached a screenshot to rule out confusion.

Thanks for the information about CPU usage and future caching possibilities.

pcwalton commented 5 years ago

Even so, if stage 0 GPU is really slow then it shouldn't be fast, since stage 0 is a necessary step. I still think there's some sort of timer query issue going on: either a driver bug or a bug on our end with how we use them.

rvolgers commented 5 years ago

I'm not sure how I could find out, Radeon-GPUProfiler does not support OpenGL and the older "GPU PerfStudio" needs a Windows client which doesn't work too well under Wine. RenderDoc seems to be a much better tool but might not give the right information, and I ran out of time to spend on this. I'll probably install it at some point though and if it shows anything weird on Pathfinder demo I'll mention it here.