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

Optimize LookClose's findNewTarget #2103

Merged
merged 1 commit into from
Apr 13, 2020
Merged

Conversation

Cryptite
Copy link
Contributor

@Cryptite Cryptite commented Apr 13, 2020

We can optimize a significant portion of LookClose's findNewTarget method with some changes:

-Build the list of all potential Players and THEN sort by distance. A good chunk of the method's time was spend sorting things it didn't need to including NPCs sorting amongst themselves.
-Second, reorder the player checks for best performance, where getNPC() is the cheapest check and isPluginVanished is the most expensive check.

In somewhat minimal testing, these changes almost dropped findNewTarget off of my profiling entirely

Here's the YK profiling of my live server with not that many people on, but this could easily scale poorly with upwards of 100 online, etc
image

…thod with some changes:

-Build the list of all potential Players and THEN sort by distance. A good chunk of the method's time was spend sorting things it didn't need to.
-Second, reorder the player checks for best performance, where getNPC() is the cheapest check and isPluginVanished is the most expensive check.

In somewhat minimal testing, these changes almost dropped findNewTarget off of my profiling entirely
@CLAassistant
Copy link

CLAassistant commented Apr 13, 2020

CLA assistant check
All committers have signed the CLA.

@Cryptite
Copy link
Contributor Author

I don't know why the diff looks like it changes 100% of the lines. It's basically only findNewTarget() that changed

@mergu
Copy link
Contributor

mergu commented Apr 13, 2020

Very likely carriage returns being removed/added. You can click the settings cog in the diff and hide whitespace changes.

@fullwall fullwall merged commit fe02492 into CitizensDev:master Apr 13, 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

4 participants