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

Lazily create LootContext for criterions #9969

Conversation

MrPowerGamerBR
Copy link
Contributor

@MrPowerGamerBR MrPowerGamerBR commented Nov 25, 2023

For each player on each tick, enter block triggers are invoked, and these create loot contexts that are promptly thrown away since a lot of the times the predicate doesn't match. (in vanilla, it should only pass for the end gateway, or when the player is in water to get the boat's recipes, and iirc none of these requires a LootContext)

To avoid this, we now lazily create the LootContext if the criterion passes the predicate AND if any of the listener triggers require a loot context instance.

While the performance increase ain't that big (on a random profile with ~55 players on my server, the createContext call was using 0.10% according to spark), it would be nice to just avoid that useless allocation anyway, and theorically if you have a lot of players moving around, the performance impact of this call would be bigger.

For each player on each tick, enter block triggers are invoked, and these create loot contexts that are promptly thrown away since the trigger doesn't pass the predicate

To avoid this, we now lazily create the LootContext if the criterion passes the predicate AND if any of the listener triggers require a loot context instance
@MrPowerGamerBR MrPowerGamerBR requested a review from a team as a code owner November 25, 2023 04:27
@Owen1212055 Owen1212055 merged commit faa2f47 into PaperMC:master Nov 25, 2023
1 check passed
lynxplay pushed a commit to lynxplay/paper that referenced this pull request Feb 23, 2024
For each player on each tick, enter block triggers are invoked, and these create loot contexts that are promptly thrown away since the trigger doesn't pass the predicate

To avoid this, we now lazily create the LootContext if the criterion passes the predicate AND if any of the listener triggers require a loot context instance
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.

3 participants