new vtkCutter in 9.4 has great performance loss

I have used vtkCutter codes like the following:

vtkSmartPointer<vtkPlane> cutFunction = vtkSmartPointer<vtkPlane>::New();
cutFunction->SetOrigin(origin);
cutFunction->SetNormal(normal);

vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New();
cutter->GenerateTriangleOff();
cutter->SetInputData(pointSetData);  // pointSetData is vtkPointSet * (which is actually vtkUnstructuredGrid.)

cutter->SetCutFunction(cutFunction);
cutter->Update();

I have compared the performance of such codes between 8.2 and 9.4. It has great performance loss in version 9.4 (which I built 9.4 with tbb/mpi support, but without tbb build option setting in 8.2). I have debugged to trace the code inside vtkCutter (UnstructureGridCutter method) without any positive feedback.

Any idea on this behavior? Thanks.

1 Like

Hi @cmodel. What kind of cells are in your unstructured grid. Can you provide an example dataset?

Yes, having a sample data set to reproduce the problem is essential. In addition to that, please provide more details:

  • Have you built both VTK 8.2 and 9.4 in Release mode? (Debug mode can be 10x slower)
  • What is the computation time in VTK 8.2 and 9.4?
  • What operating system do you use?
  • How exactly did you configure tbb/mpi support?
  • How much total RAM do you have and what is the peak RAM usage during cutting?
  • Where most of the time is spent? (you can determine it by building VTK in RelWithDebInfo mode and either use a profiler or just pause the computation during computation a couple of times and see what function/line you are at)

Hi @Andras, please see my answer.

Hi @cory.quammen , The test dataset has 384 thousand polyhedrons. I have exported the file into vtk xmlunstrucutred grid file, but it’s too large to transfer.

You can upload the file anywhere (dropbox, onedrive, google drive, github, etc.) and post the link here.

Please build VTK in RelWithDebInfo mode and report profiling results you get with that. Debug-mode builds are not usable for performance measurements, because the timings are completely different from release-mode builds.

Why have you enabled MPI?

You suggest I try one version without MPI enabled? @lassoan

Hi @lassoan @cory.quammen , I am afraid this test data set cannot be transferred to public domain. I will try some safe case to test this cutter issue.

@lassoan @cory.quammen

I debugged with the VTK version of ReleaseWithDebugInfo, it has 384k cells, and their types are polyhedron. For each GetDimension(), it will populate vtkPolyhedron. Here it takes much time.

I paused many times in some intervals, and here are some snapshots of the call stack.

vtkPoints
image

vtkObjectFactory
image

vtkCellArray

The issue https://gitlab.kitware.com/vtk/vtk/-/issues/19499 has already been fixed at commit https://gitlab.kitware.com/vtk/vtk/-/commit/e2b77b6615600bb923a829b2d8a3c00818973a7d which can be double checked that is part of 9.4.0 here https://gitlab.kitware.com/vtk/vtk/-/blob/v9.4.0/Common/DataModel/vtkCellTypes.cxx.

You can clearly see that the polyhedron case is handled properly.

If that’s not the case for you maybe you have a release candidate of VTK rather than the 9.4.0 release.

1 Like

@spyridon97 OK. I have changed to the release instead of RC2. The cutter has improvement compared to the RC2, but still slower than what it is with 8.2
I built 9.4 (release) with TBB.

I tested the following data:

unit is second
case    |    mesh                       |  vtk8.2   |  vtk9.4
dataA   |   380K polyhedron             |  3.001    |  3.796
dataB   |   230K polyheron              |  0.664    |  0.785
dataC  |  3.68 million tetra            |  0.834    |  1.198
dataD  |  6.21 million tetra + prism    |  0.849    |  2.476
dataE  |  19.65 million tetra + prism   |  5.786    |  19.667

Hi @spyridon97 @cory.quammen @lassoan

I tested the above data set with the codes in the screenshot.
Is there any wrong usage with the latest vtk9.4 ?

I can not tell what takes time without having a dataset.

If you have a dataset, let me know.

Hi @spyridon97 @cory.quammen @lassoan
I have uploaded one test dataset (810 MB)in the web storage site filen.io.
But I cannot get the public share link since I have not the subscription of that site.
Do you mind sign up, then I add you as the contact and share the link? Thanks.