optimize render sorting performance #117
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
question
rust
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ArkForgeLabs/BlueEngine!117
Loading…
Reference in a new issue
No description provided.
Delete branch "fereidani/master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hey Elham, Cool project!
This optimizes your render sorting by reducing sorting size(code isn't using &Arc reference and it only increase memory swap time while sorting(2x copy time)) and also pre-allocated the buffer so it doesn't heap allocate in the program render loop.
You can remove the unsafe part yourself later by adding lifetimes.
Important Note: If you merge this, you owe me a Kabuli Pulu!
regarding the PR itself, there are some issues:
Alternatively, a better optimization in my opinion would be caching the sort result and checking if any change have been made. This can be done as easily as a separate field with a boolean, which again is unnecessary for its scale. Another one that can help the engine in general would be swapping the hashing function of the HashMap that objects are stored in with a faster and cryptographically unsafe hashing algorithm.
All in all, it is an amazing PR, just perhaps the issues it can bring would be larger than the benefits in majority of our userbase's usecases
The Kabuli Palu is earned regardless of merge XD
Hey Elham,
Like the original algorithm, It is sorting references to objects(
Vec<&Object>) not objects so size of object wouldn't matter actually, and this algorithm is actually safe to use AFAIK and see, it is only sorting 8byte(64-bit) pointers which helps to reduce memory copies and also fits in cpu cache much better than what it was before.About the caching, you can add add a generation token, update that generation token whenever a object is removed or added to the ObjectStorage.
Now cache the sorted objects and reuse them if ObjectStorage token matches sorted objects token, regenerate the sorted list using same algorithm if token is changed.
Best way to implement it is to move sorting logic to ObjectStorage implementation.
Apart these:
The Kabuli Pulu argument was the most important thing that is now resolved
This is really interesting, I'll do a stress test this coming weekend, will report here once done.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.