Render statistics

Hey,

I’m trying to get a few additional render statistics, such as

  • total rays cast / paths created (maybe by types of rays)
  • total traversal steps / intersections tested

Is there any built-in way of getting these stats?
Do I have to hack 'em in myself and if so, I would greatly appreciate any hints on how to do it! :slight_smile:

only thing related I found is (Counting number of total rays cast) from April 19 so I guess with the new split kernel, this may have changed?

Thank you very much!

There are no such statistics currently. Note also that while we have our own BVH implementation, we use Embree by default for CPU rendering, and I’m not sure to what extent that supports counting traversal steps or intersections.

There is the option to run:

blender -- --cycles-print-stats

Which gives output like this.

Kernel statistics:
  Total render time               : Total 100.00% (148.85s), Self 12.49% (18.58s)
    Shade Surface                   : Total 34.54% (51.42s), Self 0.00% (0.00s)
      Shader Evaluation               : Total 9.57% (14.25s), Self 9.57% (14.25s)
      Direct Light                    : Total 9.55% (14.21s), Self 9.55% (14.21s)
      Indirect Light                  : Total 5.90% (8.79s), Self 5.90% (8.79s)
      Setup                           : Total 5.61% (8.36s), Self 5.61% (8.36s)
      Ambient Occlusion               : Total 3.31% (4.92s), Self 3.31% (4.92s)
      Render Passes                   : Total 0.60% (0.90s), Self 0.60% (0.90s)
    Intersect Closest               : Total 16.86% (25.10s), Self 16.86% (25.10s)
    Shade Shadow                    : Total 12.47% (18.56s), Self 0.00% (0.00s)
      Surface                         : Total 9.28% (13.81s), Self 9.28% (13.81s)
      Setup                           : Total 3.19% (4.75s), Self 3.19% (4.75s)
      Volume                          : Total 0.00% (0.00s), Self 0.00% (0.00s)
    Intersect Shadow                : Total 10.82% (16.11s), Self 10.82% (16.11s)
    Ray setup                       : Total 9.27% (13.80s), Self 9.27% (13.80s)
    Shade Light                     : Total 3.55% (5.28s), Self 0.00% (0.00s)
      Setup                           : Total 3.55% (5.28s), Self 3.55% (5.28s)
      Shader Evaluation               : Total 0.00% (0.00s), Self 0.00% (0.00s)
    Shade Volume                    : Total 0.00% (0.00s), Self 0.00% (0.00s)
      Setup                           : Total 0.00% (0.00s), Self 0.00% (0.00s)
      Integrate                       : Total 0.00% (0.00s), Self 0.00% (0.00s)
      Direct Light                    : Total 0.00% (0.00s), Self 0.00% (0.00s)
      Indirect Light                  : Total 0.00% (0.00s), Self 0.00% (0.00s)
    Intersect Subsurface            : Total 0.00% (0.00s), Self 0.00% (0.00s)
    Intersect Volume Stack          : Total 0.00% (0.00s), Self 0.00% (0.00s)

For analyzing render performance I think this is more useful than absolute ray counts, but you might have another use case in mind.

1 Like

Could be a good idea to expose this to the user in the UI (as a checkbox basically), also another statistic that could be very useful is memory consumption.

This is very important when we need to optimize a scene.

1 Like

Yes, the plan was this to add such logs to the info editor but we haven’t gotten around to it yet.

5 Likes

I would say that the console is more than enough in general, no need for the info editor because AFAIK it’s more complex.

IMO the important thing would be to make it accessible from wtihin the UI, avoiding to start blender with an specific flag.

Thx so far guys! I’m trying to get a blender performance stat such as MRays/s, so it would be great to be able to really count them.

I’m now trying to write a counter myself by:

  • writing header file with variables and functions
  • include to session.cpp for initializing and writing to file after render
  • include to kernel files such as intersect_closest.h or shade_surface.h where it calls increaseCounter() from inside a device function such as integrator_intersect_closest()

I run into some problems:

  • identifiers undefined in device code? Can I modify a local variable from device code?
  • multiply defined symbols (“already defined in cycles_kernel.lib”) Variables can’t be inlined?

Thank you for any tips!

I’m not sure what you mean by local variables exactly. But the kernel is compiled for multiple CPU architectures and defining global variables will lead to multiple definitions. Plus there are also multiple threads.

It’s probably cleanest to extend the CPU profiler code. You could add per-thread ray counter stats in the ProfilingState class, initialized to zero in Profiler::add_state and merged into global counters in Profiler::remove_state. And then in RenderStats::collect_profiling add them to the profiler output.

1 Like