Search Unity

Question Performance issue with CullResult.CreateSharedRendererScene / ExtractRenderNodeQueue

Discussion in 'General Graphics' started by Peter77, Jul 22, 2021.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    Unity 2019.4.20f1, Android Samsung Galaxy S6, Built-in RenderPipeline, Forward Rendering.

    A significant amount of time is being spent in
    CullResult.CreateSharedRendererScene
    and
    ExtractRenderNodeQueue
    .

    The very weird part of the problem is that it's even that expensive at locations where the camera looks at pretty much nothing. For example when I place the camera at the end of the world and look towards the world border and skydome only. While in other locations, where a huge part of the level is actually visible, this
    ExtractRenderNodeQueue
    cost does not exist.

    There is only a single active Camera that renders the world and it uses Occlusion Culling. I have another Camera that renders a minimap and is placed below the world, it does not use Occlusion Culling. I also tested with OcclusionCulling turned off, but the cost is still there.

    What is this
    CullResult.CreateSharedRendererScene
    and how can I get rid of the cost?

    profiler.png
     
    Last edited: Jul 28, 2021
  2. thomas-weltenbauer

    thomas-weltenbauer

    Joined:
    Oct 23, 2013
    Posts:
    72
    We have the same issue... And don't know why :D
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    In my specific case it's caused by LightProbe's.

    Sometimes Unity requires a huge amount of time to find the closest LightProbe in specific areas in one of our levels and for whatever reason, the cost is hidden under the "CreateSharedRendererScene" profiler entry.
     
    Last edited: Dec 11, 2021
    forestrf likes this.
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    @MartinTilo Can you add a profiler-marker to make the "find the closest LightProbe" cost more visible? At the moment it seems it's tracked as CreateSharedRendererScene.
     
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,453
    Hi @Peter77,
    I've pinged the light-transport team about it and they replied that there has been a recent improvement around light probe performance, which came with new markers ...
    There was a related bug, which may provide some context, but the changes were implemented as a new feature, so there are no plans to backport this.
     
    Peter77 likes this.
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    Thank you!
     
  7. EP-Toushirou

    EP-Toushirou

    Joined:
    Nov 19, 2019
    Posts:
    40

    Hello, any api can do a operate like preload in Editor or Runtime? If has this api, i want to place it on a loading ui to prevent visible performance issue.

    For Editor, if I can know which File need to open, I can read the file in a loading ui

    upload_2022-3-31_18-12-16.png

    UnityVersion:2020.3
     
  8. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,453
    Hello,
    This gets out of my area of expertise so I'm not sure how much I can help with that. This may be better to be placed in it's own thread in an appropriate subforum. I'll try to give you some pointers though to get you started:

    In 2020.3, you have the AsyncReadManagerMetrics API to record the operatuons done by the AsyncReadManager. That could probably help you identify the files that were read with this operation.
    Also, in the CPU Profiler Module's Hierarchy view, the toolbar for that view has a drop-down menu at it's far right labeled "No Details". In there is an option to show Related Data. With that details view added, and the File.Open sample selected, you may be able to see further data like the file name. I'm not certain if that was added in 2020 or 2021.
    Also, if you switch to Timeline view and turn on Flow Event visualization, you may be able to see which AsyncReadManager requests this code is being synced on, and when selecting these, see the correlated file names in the selection tooltip.

    If you update to 2021.3, there is also a new Asset Loading Profiler Module as well as a File Access Profiler Module, that may be able to provide further insights.

    As for preloading these assets to avoid these hitches, I'm not sure what could be done there. I guess it partially depends on what assets these are and if they can maybe be split into smaller ones, combined into bigger ones or loaded via Asset Bundles? I'm unsure what would provide what kind of benefits or drawbacks for either approach and would have to experiment myself, but with the Profiler to measure the results, and possibly Profile Analyzer to help compare the results in the broader scheme, this may put you in a better spot at optimizing this hitch out of your game.

    If not, as I said, I'd take your findings to the forums and start a new thread :)
     
    PutridEx likes this.
  9. EP-Toushirou

    EP-Toushirou

    Joined:
    Nov 19, 2019
    Posts:
    40
    Hello, thanks for the detail answer, I use profiler and see File.Open first open a material and then open some Library/Artifacts files, and the amount is same with the material depedent textures, so I think these files are textures' Library files.

    We use AssetBundle load in final game, but in editor LoadAssetAtDataBase is more convenience, so leads this performance issue, now I think I can use AssetDatabase.GetDependcies before load asset and preload all these dependcies in loading ui.

    Thanks again.
     
    MartinTilo likes this.
  10. forestrf

    forestrf

    Joined:
    Aug 28, 2010
    Posts:
    231
    Same here. After reading your reply the easiest solution for me was to add a gameobject with a lightprobe group, with several dozen lightprobes scattered around the map so that all the objects that use lightprobes have at least 3 somewhat close. That made the problem go away.
     
    Last edited: Jul 24, 2022
    richardkettlewell likes this.