Page MenuHome

Cycles: Clear kernel cache on start up
Needs ReviewPublic

Authored by Mai Lavelle (maiself) on May 1 2017, 7:24 PM.

Details

Reviewers
None
Group Reviewers
Cycles
Summary

This clears cached kernels, which can take up quite a lot of storage space, when Cycles is initialized. By default 1GB of kernels are kept and no kernels younger than two weeks are removed. Environment variables can be set to change these values.

Diff Detail

Event Timeline

Sergey Sharybin (sergey) added inline comments.
intern/cycles/util/util_path.cpp
371

Don't think it's best place for such things. It will slow down blender startup even more. More like the code belongs to a dedicated function, which is called when Session is actually constructed.

922

Use util_algorithm.h and ccl::sort instead.

933

Can go via VLOG().

intern/cycles/util/util_path.h
80

Not sure it's supposed to be int64 for size, such this is what size_t is supposed to store. Also not sure why to use int64 for days.

intern/cycles/util/util_time.cpp
18 ↗(On Diff #8747)

This is C++11 only header.

Made requested changes

intern/cycles/util/util_path.h
80

uint64_t is used as size_t on 32 bit systems is only enought for 4gb

Brecht Van Lommel (brecht) added inline comments.
intern/cycles/util/util_path.cpp
908–912

I think we should use VLOG too? This seems more of a debugging print in any case, I wouldn't print this normally.

946–948

Same comment here.

I would exclude release kernel from this. Many users work on stable but try buildbots regularly. As the buildbots use the same folder as the last and not the coming release, it will make the stable release to recompile all kernels every 2 weeks.

Kernels which are distributed with official releases (currently cubin's only) are excluded from this cleanup. We can't exclude kernels compiled with release version of blender from cleaning .cache directory because:

  1. We don't know what blender version the kernel was compiled for
  2. We don't want all the self-compiled kernels from the all previous releases

What would make sense is to touch kernel file when it is used. This way we never clean the kernel which was compiled long time ago but which is used all the time.

What would make sense is to touch kernel file when it is used. This way we never clean the kernel which was compiled long time ago but which is used all the time.

good idea indeed :)

  • Use VLOG only
  • Added code to touch cached files are they are used

It looks like the denoising kernels for CUDA are named differently and will be skipped by this patch. Should we change the names of those kernels to match all the others or should this patch be modified to work with multiple prefixes?

I suggest to rename the denoising kernels, I guess that will be simplest.