New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-threading! #56
Comments
IMO both per-event and per-glyph sound promising. We should probably profile first what takes most time. My guess is rasterization and gaussian blur?
pthreads. If you dislike the pthreads-w32 dependency and want to sodomize yourself, you still could do a minimal pthread wrapper like x264 and ffmpeg do.
Avoiding deadlocks is trivial: keep a clear lock hierarchy, and always acquire locks in the same order according to the hierarchy. (Making a hierarchy that works is less trivial....)
1 thread per core sounds good for something CPU-bound. Yes, this could slow down other operations running in the background (like video decoding), but in the end you have only limitted CPU power. I guess it's better to avoid too many threads if overhead grows too fast... |
Events are completely independent from each other so they look like a good candidate. But there are issues with caching, and we might end up rendering stuff twice. Extensive locking will also only slow things down unreasonably. Years ago, I experimented with multithreading a bit and I split up rendering of individual glyphs into multiple threads. This somewhat worked with OK speedup, especially in case blur was used. I used OpenMP back then.
OpenMP is widely supported. Also, C11 includes a standard threading interface, maybe we could use that. Mesa has implementations for various platforms. |
C11 is not a good match. The only platform where C11 threads would help will never natively support C11 (MS Windows). All other platforms support pthreads just fine. |
See #107
|
Also relevant: #55 |
Multi-threaded rendering would almost certainly be a performance boost for libass, but we need to answer a lot of questions before we start work, including:
The text was updated successfully, but these errors were encountered: