YOUR ACCOUNT

Login or Register to post new topics or replies
SpaceRay
SpaceRay

Posts: 12299
Filters: 35
I am sorry that I knew before what the Sample Cache was, but now I think I forgot what it is so please, can you be so kind to explain how it works with FF components?

I know that the Sample Cache is very important and can speed up sometimes a filter as it was told in the new FF 7.0

I want to optimize filters to have the best possible speed and so I could consider using some components that are faster over others slower, or not use some components if it is really not needed

THIS IS WHAT I HAVE SEEN IN THE FORUM

Quote
Vladimir Golovin wrote:In this thread here

External > Selection.

As for other components, I would not recommend duplicating them.

The renderer has an optimization called "sample cache" that can save you a significant amount of rendering time in situations when a single component has multiple outbound connections -- you won't get the speedup when using duplicates instead of connections.


Correct me if it is wrong, So then, does it mean that is much better to use (if possible) multiple times the same component with output to different components, than repeat this component for each of the components that would need it, although it may be more complex than this

Wondering what components get cached

Quote
uberzev wrote:
For example I know Blur does. What about complex curves and curve ops? etc.


Quote
Vladimir Golovin wrote:
All bitmap-based components get cached:
http://www.filterforge.com/more/help/...nents.html

Also, there is a single-sample cache that works for every component. For example, if you feed a component into three inputs and these inputs request samples at the same coordinates, the sample is calculated only once.


Quote
Vladimir Golovin wrote:
The sample cache is located at the output, not at the inputs of the component. Every component stores the coordinates and the value of the last calculated sample, and if the next sample has the same coordinates the component returns the cached value instead of evaluating the sample.



Quote
Vladimir Golovin wrote:
There's another problem -- the rendering time of one sample depends on the component itself, component inputs and parameters, and sample coordinates.

For example, every tile in the Tiles component is divided into several areas: sides, corners and the central rectangle. Samples in the central rectangle are the cheapest to calculate -- no profile curves/gradients, no complex hit testing against non-rectangular shapes. Samples on the sides take longer due to the profile curve sampling. Finally, samples in the corners are the most expensive due to hit-testing against a circular arc and the calculation of a circular gradient.

If we set Corners and Bevel Width to 100% and Mortar Width to 0, all samples will hit the corner region and therefore will take longer to render, while the sample count will remain unchanged.


Quote
Vladimir Golovin wrote:
And don't forget that inputs like Roughness can be mapped, so the calculation cost may vary for different areas.


Thanks very much for any possible help
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Caching: Ask the same question again, and you get a copy of the previous answer smile;-)

You're helping a friend (the result component). Your friend asks "What color is there at x = 1 and y = 1?". You don't know (you're the "Invert" type), but you know someone that knows someone (the component sub tree) and ask your sources. You have to wait though, because one of them is busy and another is just plain lazy.. but at some point you get an answer: "Red". You tell your friend "Cyan".
Now comes along another friend and ask you the same question: What color is there at x = 1 and y = 1?". You answer "Cyan" immediately, because you remembered.

Now the old sample cache could only remember one result, and would use that if the next question was about the same x and y values. If the next question was about different x or y values, it would ask its subtree, do its own thing and store that result for eventual reuse when asked about the same thing again. The old result from first question would simply get discarded (and if someone asked that original question again, it would have to recalculate the answer).

The new sample cache (V7 +) writes down the coordinates along with the answer, so even if asked different and reccuring questions in "random" order, old answers will be reused if the question matches.

Makes sense?

You write the following:
Quote
..does it mean that is much better to use (if possible) multiple times the same component with output to different components, than repeat this component for each of the components that would need it..


Well, given the explanation above: in pre V7 FF it would not be as simple as that, because distorters (Offset, Noise distortion etc) changes the x and y coordinates down the subtree. So with multiple connections with multiple x and y "questions", you'd end up reducing the chance for a hit or simply wasting the cached answers. In V7+ I'd say "YES - Reuse as much as possible".

I am curious though if the sample cache layer is always present, or the design is smarter and FF deduces when sample cache is needed (all those "if" checks stack up and becomes a performance matter alone). Vlad?
  Details E-Mail
Skybase
2D/3D Generalist

Posts: 4025
Filters: 76
Quote
I want to optimize filters to have the best possible speed and so I could consider using some components that are faster over others slower, or not use some components if it is really not needed


Honest thought about this: You don't need to get super technical. It only matters because the discussion (to me) is interesting or that there's a specific behavior I'm looking for in a construction. Either way, the sample caching system is technically something more so behind-the-scenes and it honestly shouldn't be something that bothers you on the surface.

It ultimately boils down to what you want to make. If it works, it works.

I tend to not even deal with it in my filters at all.

Additionally the ultimate tip when it comes to "fast filters" is just use less nodes.
  Details E-Mail
GMM
Moderator
Filter Forge, Inc
Posts: 3491
Quote
Sphinx. wrote:
I am curious though if the sample cache layer is always present, or the design is smarter and FF deduces when sample cache is needed (all those "if" checks stack up and becomes a performance matter alone).


I presume there is a separate check whether it is faster to access the cache or calculate the sample from scratch. At the moment I can't consult with the programmer who implemented the latest cache architecture. I could ask other developers to look into the code but only if you are very, very curious smile;-)
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Quote
GMM wrote:
I could ask other developers to look into the code but only if you are very, very curious


Nooo no no, that would mean even less time for fixing the script init situation smile;) smile:loveff:
  Details E-Mail
SpaceRay
SpaceRay

Posts: 12299
Filters: 35
Thanks very much for taking the time and for the well done and detailed explanation and I did understand it right. Great

Like how you explained it and how it has changed in FF 7 and is helpful and useful

Quote
Skybase wrote:
it honestly shouldn't be something that bothers you on the surface.

It ultimately boils down to what you want to make. If it works, it works.

I tend to not even deal with it in my filters at all.

Additionally the ultimate tip when it comes to "fast filters" is just use less nodes.


Thanks for answering , Yes, I agree that maybe is not very important to be aware and put much atention on this cache, and just only ,as you say, if it works right and good is ok, and if not try to find a different way, and what is good is to try to use less nodes possible to get what you want
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,712 Registered Users
+19 new in 30 days!

153,534 Posts
+31 new in 30 days!

15,348 Topics
+72 new in year!

Create an Account

Online Users Last minute:

8 unregistered users.