Thread: Avisynth 2.6 MT
View Single Post
Old 8th August 2009, 20:37   #1  |  Link
SEt
Registered User
 
Join Date: Aug 2007
Posts: 374
Avisynth 2.6 MT

Current version 2015.02.20: https://www.dropbox.com/s/dckxoowjlz...th_20150220.7z

Previous version 2013.09.28: https://www.dropbox.com/s/6f56nvqvxr...th_20130928.7z


Note: Starting from version 2012.04.03 plugin's folder is searched first for its dll dependences. You can now move some things from system32 folder to plugins folder, but check that there are no unexpected old dll versions in plugins folder in case you see strange errors.

Here is my builds of Avisynth 2.6 with several (mostly MT) fixes. MT mode stability is way better than Avisynth 2.5.8, general stability - the same as official Avisynth 2.6 (which is again better than 2.5.8 due to many bugfixes since then).

How to use it correctly

1. Installation
Install any recent official version of Avisynth.
Replace avisynth.dll in your system32 (on 32-bit OS) or syswow64 (on 64-bit OS) folder with the one from this thread.

2. Usage in scripts
Understanding different MT modes would help a lot, but most things are going to work ok with script like this one:
Code:
SetMemoryMax(512)
SetMTMode(3)
source_filter()
SetMTMode(2)
processing_filters()
If you are using it with ffdshow for realtime processing - at the very end add
Code:
SetMTMode(1)
GetMTMode(false) > 0 ? distributor() : last
and ensure you have "Buffer back/ahead" enabled with enough number for "ahead" ("back" usually can be 0 with no problems). Use 1-2 more than it sets with "Use Current" button while playback is running.
Note: current ffdshow has bug in interaction with avisynth that results in often crashes on stop of MT scripts. It does not affect playback itself.

3. In case something crashes or works wrong
Avisynth is desinged in such a way that part of it is compiled into each plugin. That means if you experience crashes first of all you should check that all used plugins are built with recent headers as old ones are not compatible with multithreading.

The other thing is memory usage. Being 32-bit Avisynth has certain memory limits.
On 32-bit OS: you are likely limited to 2GB per process. With /3GB windows boot option it can be increased to 3GB but it's not problem free.
On 64-bit OS: it's 4GB per 32-bit application, so there are benefits of using 64-bit OS even if 32-bit applications are all you need.
Note: exe file of application must be correctly compiled to use mentioned above 3GB or 4GB. Not an avisynth or its plugins problem, but worth noting.

If you see (in Task Manager) that application crashes with memory usage near 2/3/4 GB (depending on your environment) - you are facing cache inefficiency of MT Avisynth. Try increasing or decreasing SetMemoryMax, fewer number of threads (second parameter in first SetMTMode). No guaranteed results here.

Plugins/scripts that depend on sequential frame requests are not going to work correctly with current MT mode. Not really MT problem, as they also won't work correctly in non-MT mode when frame requests from next filter are not sequential.

If you are sure mentioned above 3 cases don't apply to your crash/wrong result - post here a way to reproduce it.

4. Short guide to SetMTMode
SetMTMode is the command that switches Avisynth into MT mode. Without it MT Avisynth works like the usual one.
Useful MT modes:
1 - one filter instance per call in script, no guarding from Avisynth, only for filters that are designed for this mode, like distributor().
3 - one filter instance per call in script, Avisynth guards requests for output. The mode to use with source filters. (Mode 5 will do for them too, but is overkill and should be avoided.)
2 - each call in script produces N (number of threads) instances of filter. Use for the rest.

When using MT mode with filters that have ability to spawn several internal processing threads - be sure to set such filters to use only 1 thread. Otherwise for example with 8-thread system MT mode will spawn 8 threads with once instance of such filter per thread (in MT mode 2), each filter instance will spawn 8 threads. End result: 64 threads (ouch).


Older versions:
2013.03.09: https://www.dropbox.com/s/xhqggxameg...th_20130309.7z
2013.02.20: https://www.dropbox.com/s/x58c1ofdvc...th_20130220.7z
2012.08.28: http://www.mediafire.com/file/4dm34k...rk/avisynth.7z
2012.05.16: http://www.mediafire.com/file/20gn1c...4w/avisynth.7z
2012.04.03: http://www.mediafire.com/file/rlzn2k...71/avisynth.7z
2012.03.31: http://www.mediafire.com/file/k9g67q...xa/avisynth.7z
2011.09.13: http://www.mediafire.com/file/3gd385...q7/avisynth.7z
2011.07.19: http://www.mediafire.com/file/9jk0cb...uz/avisynth.7z
2011.07.14: http://www.mediafire.com/file/358wvs...gi/avisynth.7z
2009.09.19: http://www.mediafire.com/file/2dz4y0wztzz/avisynth.7z
2009.08.15: http://www.mediafire.com/file/zjaelw...avisynth_26.7z
2009.08.08: http://www.mediafire.com/file/hdvgzm...avisynth_26.7z
Attached Files
File Type: 7z diff.7z (29.8 KB, 3209 views)

Last edited by SEt; 20th February 2015 at 01:21.
SEt is offline   Reply With Quote