- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.8k
optimise CraftWorld#spawnParticle #13250
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
base: main
Are you sure you want to change the base?
optimise CraftWorld#spawnParticle #13250
Conversation
This optimisation is technically performance but the biggest improvement is with allocations from streams. Optimises the CraftWorld#spawnParticle method by moving some logic from ServerLevel#sendParticlesSource to avoid a heavy stream and collect operation.
| Your PR contains a lot of unrelated changes from some dev branch Owen worked on. Please remove these. | 
47dbe32    to
    dd501fc      
    Compare
  
    | not too sure how i managed to mess that up | 
| Have you tried just using  | 
| 
 This is no different to the stream in terms of allocations. I was originally just going to change the access of  | 
| 
 It is very different because the Stream will allocate a materialized list while Lists.transform creates a small wrapper and applies the function on access. That's why I asked if you gave it a try. Generally seeing some profiling information would be helpful. | 
| 
 How is allocation of a small helper list wrapper and a highly reusable lambda (jvm can be very smart about lambdas that don't use anything from the context) is the same as a complex structure like streams (and as just mentioned above a full list)? | 
This reverts commit dd501fc.
| after a quick test list transform is better than the stream, still not quite as good as directly looping over the original array but the difference is barely noticable | 
This removes the absurd allocation from the stream.
Optimises the CraftWorld#spawnParticle method by moving some logic from ServerLevel#sendParticlesSource to avoid a heavy stream and collect operation.