Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meshToVolume slowdown? #1817

Open
MakotoChiba opened this issue May 16, 2024 · 1 comment
Open

meshToVolume slowdown? #1817

MakotoChiba opened this issue May 16, 2024 · 1 comment

Comments

@MakotoChiba
Copy link

MakotoChiba commented May 16, 2024

I'm using openvdb 6.2.1 on the windows11.
meshToVolume getting slower and slower when system have lots of VDB grids.
Larger grids and many of grids get more significant slower.
And even if I delete the stored array, slowdown speed will not be restored.
Why is this happens?

Here is the simple test code.

std::vector<openvdb::FloatGrid::Ptr> Grids
tempLS.resize(100, NULL);
DWORD start, end;

for (int j = 0; j < 100; j++)
{
	start = GetTickCount64();
	Grids[j] = openvdb::tools::meshToVolume<openvdb::FloatGrid>(polymesh, *transform, exBand, inBand, 0, &polyIndexGrid);

	end = GetTickCount64();
	printf("%d : %.3lf sec\n", j, (double)(end - start) * 0.001);
}

And This is part of the result.
0: 0.563 sec
1: 0.563 sec
2: 0.562 sec
3: 0.563 sec
4: 0.562 sec
~
96: 0.758 sec
97: 0.753 sec
98: 0.764 sec
99: 0.753 sec
100: 0.762 sec
This issue occurs when I have multiple openvdb::grid::Prt as well as std grid array.

If I don't store grids to array, it have no slowdown., like this

openvdb::FloatGrid::Ptr grid;
DWORD start, end;
for (int j = 0; j < 100; j++)
{
	start = GetTickCount64();
	grid = openvdb::tools::meshToVolume<openvdb::FloatGrid>(polymesh, *transform, exBand, inBand, 0, &polyIndexGrid);

	end = GetTickCount64();
	printf("%d : %.3lf sec\n", j, (double)(end - start) * 0.001);
}

And This is part of the result.
0: 0.563 sec
1: 0.563 sec
2: 0.564 sec
3: 0.562 sec
4: 0.563 sec
~
96: 0.568 sec
97: 0.563 sec
98: 0.574 sec
99: 0.563 sec
100: 0.572 sec

thanks

@MakotoChiba
Copy link
Author

Here is another test code.

openvdb::FloatGrid::Ptr tempGrid;
std::vector<openvdb::FloatGrid::Ptr> tempLS;
tempLS.resize(400, NULL);
DWORD start, end;

for (int i = 0; i < 10; i++)
{
	start = GetTickCount64();
	tempGrid = openvdb::tools::meshToVolume<openvdb::FloatGrid>(polymesh, *transform, exBand, inBand, 0, &polyIndexGrid);
	end = GetTickCount64();
	printf("%d : %.3lf sec\n", i, (double)(end - start) * 0.001);

	for (int j = 0; j < 400; j++)
	{
		tempLS[j] = tempGrid->deepCopy();
	}
}

This result is
0: 0.563 sec
1: 0.672 sec
2: 0.672 sec
3: 0.688 sec
4: 0.687 sec
5: 0.672 sec
6: 0.672 sec
7: 0.688 sec
8: 0.657 sec
9: 0.672 sec
This means that have same problem which system have lot of array, meshToVolume get slower. But reuse of same grid array does not couse slowdown.

Then I add ->clear for array grid

openvdb::FloatGrid::Ptr tempGrid;
std::vector<openvdb::FloatGrid::Ptr> tempLS;
tempLS.resize(400, NULL);
DWORD start, end;

for (int i = 0; i < 10; i++)
{
	start = GetTickCount64();
	tempGrid = openvdb::tools::meshToVolume<openvdb::FloatGrid>(polymesh, *transform, exBand, inBand, 0, &polyIndexGrid);
	end = GetTickCount64();
	printf("%d : %.3lf sec\n", i, (double)(end - start) * 0.001);

	for (int j = 0; j < 400; j++)
	{
		tempLS[j] = tempGrid->deepCopy();
	}
	for (int j = 0; j < 400; j++)
	{
		tempLS[j]->clear();
	}
}

This result is
0: 0.547 sec
1: 0.766 sec
2: 0.985 sec
3: 1.141 sec
4: 1.250 sec
5: 1.328 sec
6: 1.437 sec
7: 1.578 sec
8: 1.704 sec
9: 1.719 sec
So, I get some more slow down. This means that grid->clear() might be cause heavy memory fragment or leak or something??

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant