f3d icon indicating copy to clipboard operation
f3d copied to clipboard

Startup performance

Open Meakk opened this issue 1 year ago • 6 comments
trafficstars

Describe the bug A large amount of time is spent in the volume mapper initialization when launching f3d even if it's not used

2024-04-01-151421_1039x889

To Reproduce Steps to reproduce the behavior:

  1. Open the file using valgrind --tool=callgrind f3d --dry-run cow.vtp --output=/tmp/out.png

Expected behavior The time spent in volume mapper initialization should be negligible

System Information:

  • OS: all?
  • GPU and GPU driver: irrelevant

F3D Information Paste the content of f3d --version: 2.4 and current master

Meakk avatar Apr 01 '24 15:04 Meakk

I would like to try fixing this bug

kidharb avatar May 03 '24 06:05 kidharb

@kidharb here's an idea. We are using vtkNew which allocates the class immediately. Maybe we could use vtkSmartPointer instead and trigger the allocation only when it is needed.

Meakk avatar May 03 '24 06:05 Meakk

@kidharb here's an idea. We are using vtkNew which allocates the class immediately. Maybe we could use vtkSmartPointer instead and trigger the allocation only when it is needed.

I finally understand what you mean :-P I was able to reproduce the issue and see that vtkSmartVolumeMapper is taking up some time.

kidharb avatar May 17 '24 14:05 kidharb

From @mwestphal comments on Discord (slightly edited for Github)

The problem is that the Volume code is in vtkF3DGenericImporter and all of this Volume code should be in vtkF3DRendererWithColoring::ConfigureVolumeForColoring instead.

In short, vtkF3DGenericImporter should still hold a vtkSmartVolumeMapper which should be nullptr when we start the app. The first time vtkF3DRendererWithColoring::ConfigureVolumeForColoring tries to use vtkSmartVolumeMapper the vtkF3DGenericImporter should initialize it.

To solve this issue, create a vtkF3DGenericImporter::InitializeVolumeMapper and call it just before calling vtkF3DRendererWithColoring::ConfigureVolumeForColoring in vtkF3DRendererWithColoring, if and only if the propAndMapper.second == nullptr

kidharb avatar May 21 '24 08:05 kidharb

@kidharb what is that status of this ?

mwestphal avatar Jul 13 '24 16:07 mwestphal

Open to contribution

mwestphal avatar Jul 13 '24 16:07 mwestphal