Log in

View Full Version : speeding up


kolak
15th December 2011, 01:39
How to speed up script, which is basically one line:

directshowsource(file.grf)

Graph has just source file put through some DMO (very slow, not multithreaded) filter- that's it. It's dithering filter.

Speed is slow due to processing of this DMO filter. Is there a way (except splitting into many scripts) to speed up whole process?
I tried setmt and some other ways, but no luck :(

Thanks,
Andrew

kolak
2nd January 2012, 12:45
How can I force avisynth to process many source files in one scrpit in seperate threads?
Tried selectevery with setmt but no luck.

a=source..
b=source..
c=selecteven()
d=selectodd()
setmtmode(1)
interleave(c,d)

Is this forcing to process each source in different thread? Don't see speed boost at all.

Thanks

TheFluff
2nd January 2012, 13:43
One of the first things Avisynth does when you create a new script environment is
CoInitialize(NULL);
which I'm pretty sure ends up meaning that all COM stuff (such as various DirectShow things) will run in a single-threaded apartment. You'll have to use more than one Avisynth process to do what you want.

mastrboy
2nd January 2012, 13:47
there is the Threadrequest plugin, not sure if it would work for source filters though: http://forum.doom9.org/showthread.php?t=154886

kolak
2nd January 2012, 16:12
Will try threadrequest.

This seams to be the problem- all sources seams to be processed in one thread :(

update:

no luck- all slower than from single source.

No sure why it does not work- is there really no way to load each source in seperate thread?

TheFluff
2nd January 2012, 19:38
I already told you exactly why it doesn't work. Everything COM-related that is called from Avisynth will run in a single-thread apartment. There is no way to change this short of changing the CoInitialize() line I mentioned and recompiling Avisynth, but changing the COM initialization mode to COINIT_MULTITHREADED is most likely a very bad idea anyway since Avisynth isn't threadsafe and DirectShowSource probably isn't either.

However, I just noticed that MP_Pipeline (http://forum.doom9.org/showthread.php?t=163281) seems to offer exactly what you need, namely a way to run several Avisynth script environments in separate child processes and delivering all of the results to a single Avisynth script without any lossless intermediates. Most of the time this is useless for selectevery()+interleave() style multithreading since invoking any temporal filter will mean the same frames will have to be processed in all of the child processes anyway, but for your purposes it might actually work since you're not doing any temporal filtering. Try the "branch" directive and see what happens.

By the way, it is important to remember that there's a difference between "thread" and "process".

kolak
2nd January 2012, 19:40
Playing with MP pipeline now :)

kolak
3rd January 2012, 17:00
No luck- all methods are slower than simple one core converting.