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

tweak sort for validating chunk n^2 cost #4179

Merged

Conversation

pollend
Copy link
Member

@pollend pollend commented Oct 4, 2020

this sort for chunk relevance adds an n^2 cost to the search. since it will try to sort the current chunks against all possible nearby chunks. this function only add the chunk from the region if its valid or creates a new chunk if its not available. This same problem is also apparent with ChunkTaskRelevanceComparator. Some better strategies would need to be setup if there are a lot of relevant entities.

 Chunk chunk = chunkProvider.getChunk(pos);
                            if (chunk != null) {
                                region.checkIfChunkIsRelevant(chunk);
                            } else {
                                chunkProvider.createOrLoadChunk(pos);
                            }

@pollend pollend changed the title remove sort for validating chunk n^2 cost tweak sort for validating chunk n^2 cost Oct 4, 2020
@pollend
Copy link
Member Author

pollend commented Oct 4, 2020

I exit the for loop early if the distance is at 0. Probably want to think about some better strategies to managing these queries.

Copy link
Contributor

@DarkWeird DarkWeird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it needs to rethink for algorithm.
It is enough now, when a bit regions used

@DarkWeird DarkWeird merged commit 55154dc into MovingBlocks:develop Oct 14, 2020
@pollend pollend deleted the fix/performance-chunk-relevance branch October 14, 2020 13:57
@Cervator Cervator added this to the v4.1.0 milestone Dec 5, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants