Registered Member
|
Hi there,
I've recently done some renderings with kdenlive and the rendering takes awfully long because it doesn't seem to distribute work around cores properly. I've specified 12 threads in the rendering dialog, and melt is called with those 12 threads as an argument:
and there's PLENTY of threads actually created
However, only one to two of these threads seem to actually perform any work:
What could the reason for this be? How can I fix it? Thanks for your help! Joe |
Registered Member
|
|
Registered Member
|
Oh no way, so there are really thread-unsafe modules? That sucks Even with those, it still should be possible to fork twelve processes and have them render different chunks of the video, should it not? Then they could even be thread-unsafe, but still multicores could be used. That's a real shame. Took almost 3 hours to render the video on my beast of computer where the main "effect" was to rotate something 180°. That effect, I'm guessing, is not threadsafe. *sigh* Edit: Is there a way to find out which modules are non-threadsafe? I'd really like to avoid those in the future if there're alternatives. |
Moderator
|
https://github.com/mltframework/mlt/blo ... d_safe.txt |
Registered Member
|
Hmmm, if this list is correct though, the reason for the low utilization has to be something else. I built my kdenlive at 2015-09-05, i.e. frei0r v0.3+. Therefore, only these modules should be affected:
The ones I used heavily in the project though are
i.e. "crop" and "pan_zoom". Neither of which are on that list... So any other reason for the bad performance? |
Registered Member
|
Just 'cause this is on the front page today, the solution was to set real_time=-n where n is the number of parallel mlt threads you wish to allow to speed things up.
It was in the thread linked to by Dive-o. |
Registered Member
|
Afaik, On KF5-based Kdenlives, this parameter is exposed in the "Rendering" dialog as the number of "Encoder threads".
|
Registered Member
|
Nah, that's the threads=n (normal cpu threads) bit, you can control real_time=-n (mlt threads) by changing the processing threads in the configure -> mlt environment bit. I should really report it as a bug, since setting processing threads (mlt threads) to higher than 1 causes issues in kdenilve (to be fair it does say that >1 is experimental), but you still want to render with more mlt threads to take advantage of multi-core more. Setting threads (normal cpu threads) from the render screen is fairly useless, both in terms of the default being 1, and not being able to set it higher than number of cores (not sure why). It invariably leads to people setting it to as high as they can and then scratching their heads when mlt bottlenecks at an affine and they only get 100% cpu usage. In fact, what would be better in my humble opinion (since rendering from the render dialog does one job at a time anyway) would be to completely omit threads and let the encoder handle that on its own and then be able to set real_time=-n to whatever from there. That's pretty much what I end up doing with generated scripts anyhow. Obviously with the usual >1 mlt threads can cause glitches depending on filters warning. In the meantime, generate script, change real_time=-1 to real_time=-3 and you'll get your multicore use at the expense of not being able to use certain mlt effects. |
Registered Member
|
What you are refering to is "Configure" > "Environment", then "Processing threads". I'm refering to "Encoding threads". Unless you are describing something else, a third parameter.
I happen to know as on my core i7 I can't use processing threads other than 1. However, I'm just perfectly rendering using multiple processing threads in MLT. And I know because I watch my eight virtual CPUs only getting to 30%, but not sticking at 1/8th as it is the case for your parameter explanation. When I set processing threads to 8 then Kdenlive chokes, yet rendering crawls on a single core. I may still be wrong, then please point out exactly what encoding threads is used for. Thank you. |
Registered Member
|
Encoding threads in the rendering dialog sets the threads=n value in mlt, "Configure" > "Environment", then "Processing threads" sets the real_time=-n value in mlt. From the mlt docs:
Ergo, if you generate a script instead of render from the render dialog and edit the script to use, say, real_time=-3 and remove threads=8 you'll get better cpu usage. |
Registered Member
|
So, threads>1 would still provide better usage when combined with real_time=-3, as the former helps decoding/encoding H.264 which I heavily rely on. And real_time speeds up MLT somehow. So it's not either/or, but both. Time for another feature request...?
|
Registered Member
|
I stand corrected for the real_time parameter. Some more data to validate on my iCore 7 3.7GHz with a recent project, these are rough peak-stable numbers over certain parts of the project:
threads=8 real_time=-1 --> ~30% (25%) CPU <-- my Kdenlive configuration when directly rendering inside Kdenlive. threads=1 real_time=-3 --> ~40% (35%) CPU <-- script; as suggested ... better, not stellar, so decoding/encoding actually seems to be relevant, not only MLT. threads=5 real_time=-3 --> ~70% (50%) CPU <-- significantly better threads=8 real_time=-3 --> similar threads=5 These figures vary over the whole project, as some parts are computationally more intensive in the effect pipeline, while other parts are not. Thus, I've given here the consistent peak for several seconds, as well as the level during a significant part of the project. So, as I suspected and asked for, it's not "either/or", it is obviously "and" -- at least with the projects and footage I'm working. Looks as it is really time for filing a bug/feature report on this. |
Registered Member
|
I actually suggested omitting threads=n entirely. cores*1.5 is default for threads in x264 encoding. |
Registered Member
|
It's quicker for me to just adjust the real_time parameter.
Filed a feature request here: https://bugs.kde.org/show_bug.cgi?id=358695 |
Registered Member
|
Another chapter in the ongoing multicore utilisation saga.
For a recent project I worked on I let Kdenlive create a rendering script, then manually set real_time=-3 and threads=8. To my surprise this quickly brought up CPU usage on my Core i7 to 100% but also with memory consumption steadily growing and growing. Someone was leaking badly, I had to kill the script before the system got intro swap trashing. Because the project rendered fine from within Kdenlive, one or both of the parameters must be involved. So I played around with these parameters: removing threads= and keeping real_time=-3 got me around 40% CPU usage, without any visible memory leak. This therefore seems to point towards a problem in ffmpeg, but not in MLT, as the leak as well as CPU load disappeared when removing threads=8. For reference: rendering in Kdenlive (thus with real_time=-1) gives me typically around 25% CPU usage, whereas real_time=-3 causes around 40% CPU load. So yes, enabling multithreading within MLT itself improves the situation. Albeit not stellar... |
Registered users: Bing [Bot], Google [Bot], lockheed, Sogou [Bot]