Sphinx.
![]() |
I'm working on a filter with a rather heavy initialization section. In theory the initialization script part should execute one time (I'm testing with only CPU core), however I counted more than 60 executions :-S
Here is a dedicated test script that shows the problem (also attached, note it is unsafe due to the os.time() call):
Here is the output (Filter Forge x86.log):
Variable "do_initialize" should remain false, but for some reason it doesn't. "Prepare" is only executed once, so what the h*** is going on here? Is this related to the rendering "tiles"? Ini Test.ffxml |
|||||
Posted: August 21, 2011 7:41 am | ||||||
Sphinx.
![]() |
This is very annoying :-S I can't prepare the script in function Prepare because get_sample calls are not allowed (I need to analyze multiple image inputs to get average color of the inputs).
So I'm left with the option to analyze the images in the main get_sample function (with a similar initialization setup as described above). But the extreme overhead caused by the multiple executions (as described above) makes it practically unusable.. ![]() We really need a middle way here: some sort of initialization function that allows get_sample calls and can produce data that is shared in all threads/tiles.. FF programmers.. any comments? |
|||||
Posted: August 21, 2011 8:11 am | ||||||
Igor Lorents
Posts: 39 |
Sphinx, thank you for reporting the issue.
The problem seems to be in our architecture. Changes you've made in the Global table which contains definition for all global variables after the first initialization (which is made by calling the prepare() routine) do not propagate properly. That's why your initialization code in get_sample() function executes each time when the new rendering block is started. The problem should still persist even if you use single-threaded rendering, and your test sample illustrates it very well. So, this issue seems to be a pretty large piece of work, and unfortunately I won't have time for it until the release of version 3.0. Sorry for the inconvenience. |
|||||
Posted: August 22, 2011 5:27 am | ||||||
Sphinx.
![]() |
I see - after Prepare has been called you assume the global table is not changed and simply copy the table...
Could you possibly add some sort of "super global" table that works across tiles, or allow get_sample calls in prepare? |
|||||
Posted: August 22, 2011 7:16 am | ||||||
Igor Lorents
Posts: 39 |
Unfortunately no, because the behavior of the suggested "super global" table is absolutely equal to the intended behavior of the global table. We'll just have to implement it properly ![]() |
|||||
Posted: August 22, 2011 7:42 am | ||||||
Sphinx.
![]() |
Sigh... well, that "bug" along with the darn unpersist error blocks several of my projects. Patience..
Thanks for the explanation anyways. |
|||||
Posted: August 22, 2011 9:06 am | ||||||
Sphinx.
![]() |
Alright, FF3 released - time to bring this up again
![]() The problem still persists: Global variables are not truly global, but only "global" inside a given rendering block. This will ruin smart logic such as initialization regions. A typical scenario: collect a set of samples and use their properties to determine global filtering (e.g. auto levels). This initial sample collection is only necessary to do once. |
|||||
Posted: November 17, 2011 5:43 am | ||||||
Sphinx.
![]() |
So, any news on this issue? Script filters with heavy prepare/initialization sections are unreasonably slow...
|
|||||
Posted: November 21, 2014 2:14 am | ||||||
Sphinx.
![]() |
Here is ThreeDee's cool circle packer filter. It uses an initialization section to prepare some stuff based on sampler inputs. Its essentially the same as using the prepare method only you blocked the possibility to use sampler sources for preparation, so he has to use an init variable and do it in get_sample.. nothing weird about that design.
I stripped the actual rendering script so all this filter is doing in theory is that one initialization, however in reality this seems to be called for each of your internal temporary rendering tiles ![]()
Circle packing 6B - SLOW INIT.ffxml |
|||||
Posted: November 21, 2014 3:20 am | ||||||
Ramlyn
![]() |
Humm... so it repeats the same process also when it is not needed.
|
|||||
Posted: November 21, 2014 9:26 am | ||||||
Sphinx.
![]() |
Yes, for each of those rendering blocks you see being completed during rendering.. and if you have multiple pass rendering enabled (that is default) it is number of blocks x number of passes..
|
|||||
Posted: November 21, 2014 9:28 am | ||||||
ThreeDee
![]() |
Hey, I had a thought:
How about using an unsafe script to store the precalculation to a (comma-delimited?) text file when a checkbox is activated. You can set it up so that only the first thread does this calculation and saving of the file by making sure the coordinates are less than 1/16th of the shorter dimension of the image (and init ==0). Other threads do nothing while the checkbox in on. Then when the checkbox is clicked off the filter reads the precalculation file instead of doing the calculation. Hopefully this can be done during the Prepare() function so it doesn't have to be done for each thread. This is similar solution to what Ken (with some help from the undersigned) did with the embedded external image: https://www.filterforge.com/forum/read...sage120745 Won't be able to submit to library as it is an unsafe script. Otherwise I don't see why it wouldn't work. |
|||||
Posted: November 23, 2014 3:34 pm | ||||||
Sphinx.
![]() |
Yes, that will probably do as a temporary workaround for private filters (since we can't submit unsecure filters).
However the main point of this 3 year, 3 months and 3 days old thread is still very valid: script filters with heavy global initialization are quite inefficiently executed. I wish they had a "fastmode" render mode that skipped all the render block stuff all together. One render block to rule them all (and that one blocks resolution = the output image resolution). No magic, no preview, no multipass.. just raw to the bone processing. |
|||||
Posted: November 24, 2014 2:26 am | ||||||
Sphinx.
![]() |
||||||
Posted: November 25, 2014 5:52 am | ||||||
ThreeDee
![]() |
Couldn't agree with you more. Lack of such an option makes script optimization a bitch. |
|||||
Posted: November 26, 2014 10:06 am | ||||||
Sphinx.
![]() |
Vlad, GMM anyone... are you going to address this multithreading performance issue in V5?
|
|||||
Posted: July 12, 2015 1:44 pm | ||||||
GMM
Moderator
Posts: 3491 |
I hope this is going to be fixed at the time we implement LuaJIT which is supposed to be faster and better overall. I'm not sure LuaJIT will make its way into FF5 but it's in the works.
|
|||||
Posted: July 13, 2015 5:40 am | ||||||
trung
Posts: 1 |
longish iterative process, and not really necessary if you can use other commands
|
|||||
Posted: September 8, 2015 10:13 pm | ||||||
Sphinx.
![]() |
Filter Forge x86 5.006.38069.21538.
Problem still present - an init call that theoretically should called *once* is called for each rendering tile etc. ![]()
Above script produces the following log output. Ideally we should see one line only.
|
|||||
Posted: November 21, 2015 2:43 am | ||||||
Indigo Ray
![]() |
FF 7.001: Still a problem. Really hampers the scripting feature in FF.
I adapted Sphinx's code to output an image instead of text ( ![]() script_init.ffxml |
|||||
Posted: May 24, 2017 10:36 pm | ||||||
Indigo Ray
![]() |
||||||
Posted: May 24, 2017 10:39 pm | ||||||
Sphinx.
![]() |
Any news on this issue?
This is a major performance issue in advanced scripts... |
|||||
Posted: October 12, 2017 2:42 am | ||||||
GMM
Moderator
Posts: 3491 |
I'm afraid no news for FF7 in this matter.
|
|||||
Posted: October 12, 2017 7:02 am | ||||||
Sphinx.
![]() |
||||||
Posted: October 12, 2017 7:47 am | ||||||
Sphinx.
![]() |
GMM/Vlad - is this issue going to be addressed in V9 at some point?
|
|||||
Posted: August 2, 2019 6:46 am | ||||||
GMM
Moderator
Posts: 3491 |
I'm afraid not in V9
![]() |
|||||
Posted: August 2, 2019 6:52 am | ||||||
Sphinx.
![]() |
Sigh! I guess its more profitable adding new bells and whistles than polishing/fixing the existing ones (Psst... loop sample cache!). Oh well, true global initialization would also be needed for green to gray conversion I guess. Fingers crossed. Thanks for the answer
![]() |
|||||
Posted: August 2, 2019 7:56 am | ||||||
Rico
![]() |
Wow, this thread is nearly 11 years old!
I am trying to work on circle-packing, like many others before me. I have made some good headway building on ThreeDee's excellent work, but the primary problem is the inability to cache properly, which is tied to this initialisation issue. I want to build my tables once and once only. Dear moderators can you tell us if this will ever be fixed please? Thank you. |
|||||
Posted: March 28, 2022 3:54 am | ||||||
GMM
Moderator
Posts: 3491 |
Ever? Probably yes. Soon? I'm afraid not. |
|||||
Posted: March 28, 2022 8:52 am |
Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!
33,711 Registered Users
+18 new in 30 days!
153,531 Posts
+39 new in 30 days!
15,347 Topics
+72 new in year!
23 unregistered users.