PavelBlend / blender-molecular

molecular addon for blender
27 stars 7 forks source link

New cahce system. #15

Open OmidGhotbi opened 3 months ago

OmidGhotbi commented 3 months ago

Make a new cache system independent from the blender cache, and add dedicated thread for the cache system.

PavelBlend commented 3 months ago

Describe in more detail what the new cache means? My cache already does not depend on the blender cache. 01 02

OmidGhotbi commented 3 months ago

yes, this is good, if we write the cache inside C code and do not load it at all in Blender or just every few frames it can heavily affect the performance of the code. because at the moment it calculates every single substep for import, export, and load data, and as I can see it will take about 30% of all processing time. if we do all substeps and then just update the viewport at the end of it like what you did in writing the cache we can improve the code massively. the reason it will help is GIL lock in Python every time that code reports or gets back to Python need to slow down and respect the GIL lock. less data transfer more speed.

OmidGhotbi commented 3 months ago

The only way we can achieve best performance is to save data in the background without using any kind of sending and receiving data in a blender, and complete the detached task, in blender we check if the cache is available for a frame load it if not just skip until it's ready. in this way we can get 95% of CPU to work on the simulation not most of it on blender and just leave small pice on CPU not even a core or thread, the natural idle process for blender UI and loading the cache separately. i know it is hard because the current code needs blender particles and collision, etc.