1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Performance Improvement: Use a cache which caches result for getFacePositions.

This greatly reduce the number of std::list generated by caching the result, which is always constant for each radius selected.
In the callgrind map, you will see original:
  * 3.3M calls to std::list for 9700 calls to getFacePositions
In the modified version, you will see:
  * 3.3K calls to std::list for 6900 call to getFacePositions
Callgrind map is here: #2321

it's a huge performance improvement to l_find_node_near
This commit is contained in:
Loic Blot 2015-02-15 17:30:38 +01:00
parent ed04e8e9e4
commit 7c8793cbea
4 changed files with 81 additions and 68 deletions

View file

@ -59,7 +59,7 @@ void RemoteClient::ResendBlockIfOnWire(v3s16 p)
}
}
void RemoteClient::GetNextBlocks(
void RemoteClient::GetNextBlocks (
ServerEnvironment *env,
EmergeManager * emerge,
float dtime,
@ -182,18 +182,15 @@ void RemoteClient::GetNextBlocks(
//bool queue_is_full = false;
s16 d;
for(d = d_start; d <= d_max; d++)
{
for(d = d_start; d <= d_max; d++) {
/*
Get the border/face dot coordinates of a "d-radiused"
box
*/
std::list<v3s16> list;
getFacePositions(list, d);
std::vector<v3s16> list = FacePositionCache::getFacePositions(d);
std::list<v3s16>::iterator li;
for(li=list.begin(); li!=list.end(); ++li)
{
std::vector<v3s16>::iterator li;
for(li = list.begin(); li != list.end(); ++li) {
v3s16 p = *li + center;
/*