-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Improve performance of PoiCompetitorScan by unrolling stream #11871
Improve performance of PoiCompetitorScan by unrolling stream #11871
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's changing minecraft code, this can still use some paper comments
...r-server/patches/sources/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java.patch
Outdated
Show resolved
Hide resolved
The profiling results look very impressive. You may have forgotten to return the winner to ifPresent? .reduce |
The result wasn't used at all before so there is no need to return anything because the only thing it does is the sideffect. |
...r-server/patches/sources/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java.patch
Outdated
Show resolved
Hide resolved
745c836
to
fe1642a
Compare
I was debugging villagers and I noticed that the reduce on the stream has massive overhead so I decided to unroll it.
![image](https://private-user-images.githubusercontent.com/62996347/399457472-40dfdfe9-73b8-4920-91cd-ade6fd375222.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MDI1NjcsIm5iZiI6MTczOTQwMjI2NywicGF0aCI6Ii82Mjk5NjM0Ny8zOTk0NTc0NzItNDBkZmRmZTktNzNiOC00OTIwLTkxY2QtYWRlNmZkMzc1MjIyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDIzMTc0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUyMzYzNmZiNWE1ZWQzOWVkY2EwNTVmNGE1OGUwZmY4NzM0NDIwMzI0YWJlNWFkZDkyYmYyNzljYjI4YmI4NDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.hx5dLma3pR-UFuSVnN0jCT-u0m630m7TKPuKjdmP9_U)
Here are sparks for before and after:
Before
After
Those numbers are with 229 active villagers on R7 5700X with 64GB of RAM.
Here is the test world:
world.tar.gz