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

Excessive CPU usage #77

Closed
AnthonyAMC opened this issue Jan 20, 2013 · 4 comments
Closed

Excessive CPU usage #77

AnthonyAMC opened this issue Jan 20, 2013 · 4 comments

Comments

@AnthonyAMC
Copy link
Contributor

I am doing a series of test using the NoLag Examiner and am posting my results here.

The first test i did is breaking items. This was me running around punching grass blocks and longgrass and flowers for 30 seconds in a test server.

Here are the details:
Total duration: 5500.267 ms / 600 ticks
Average duration: 9.167 ms/tick
Selected event: PlayerInteractEvent[NORMAL]
Plugin: NoItem
Location: class net.worldoftomorrow.noitem.events.Listeners

So this would correspond to:
https://github.com/World-of-Tomorrow/NoItem/blob/master/src/main/java/net/worldoftomorrow/noitem/events/Listeners.java#L40

And subsequently to:
https://github.com/World-of-Tomorrow/NoItem/blob/master/src/main/java/net/worldoftomorrow/noitem/events/Handlers.java#L122

The next test i did was holding items. I filled my hotbar with items and quickly scrolled through it for 30 seconds.

Here are the details:
Total duration: 4379.407 ms / 600 ticks
Average duration: 7.299 ms/tick
Selected event: PlayerItemHeldEvent[NORMAL]
Plugin: NoItem
Location: class net.worldoftomorrow.noitem.events.Listeners

This corresponds to:
https://github.com/World-of-Tomorrow/NoItem/blob/master/src/main/java/net/worldoftomorrow/noitem/events/Listeners.java#L34

And subsequently to:
https://github.com/World-of-Tomorrow/NoItem/blob/master/src/main/java/net/worldoftomorrow/noitem/events/Handlers.java#L98

I might run additional tests, but i get the feeling that these results are not highlighting the specific issues... But I hope this information helps narrow down the root causes.

@nisovin
Copy link

nisovin commented Jan 20, 2013

I'm fairly certain this lag is being caused by using Permission.addParent in PermMan.construct. I'm not sure why this is being done, but it certainly shouldn't be. Every time you run addParent, it recalculates the permissions on every player that has that permission. Since this is done up to four times per permission check, that gets expensive really quickly, especially when there is a large number of players on the server.

The addParent method should generally only be used when the plugin is loading, to set up the parent/child relationships for the permissions your plugin uses. It definitely shouldn't be run every time you check for permissions. In fact, you don't really need to use Permission objects at all, you should just be using strings.

@just-push-it
Copy link
Member

Argh! I did not realize that it was such a costly process! Makes me feel a bit silly honestly.. Anyway, I should have resolved the issue. Now I just need confirmation.

@AnthonyAMC
Copy link
Contributor Author

What CB is NoItem-b237 built against? I'm using Spigot-b375 http://ci.md-5.net/job/Spigot/375/
Threw a NPE

01:49:46 [INFO] [NoItem] Enabling NoItem v3.0.3-SNAPSHOT-237
01:49:46 [SEVERE] Error occurred while enabling NoItem v3.0.3-SNAPSHOT-237 (Is it up to date?)
java.lang.NullPointerException
at net.worldoftomorrow.noitem.Config.getBoolean(Config.java:94)
at net.worldoftomorrow.noitem.permissions.PermMan.(PermMan.java:14)
at net.worldoftomorrow.noitem.NoItem.setupStatic(NoItem.java:67)
at net.worldoftomorrow.noitem.NoItem.onEnable(NoItem.java:26)
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
at org.bukkit.craftbukkit.v1_4_6.CraftServer.loadPlugin(CraftServer.java:315)
at org.bukkit.craftbukkit.v1_4_6.CraftServer.enablePlugins(CraftServer.java:297)
at net.minecraft.server.v1_4_6.MinecraftServer.j(MinecraftServer.java:326)
at net.minecraft.server.v1_4_6.MinecraftServer.e(MinecraftServer.java:305)
at net.minecraft.server.v1_4_6.MinecraftServer.a(MinecraftServer.java:264)
at net.minecraft.server.v1_4_6.DedicatedServer.init(DedicatedServer.java:149)
at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:404)
at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)

just-push-it added a commit that referenced this issue Jan 21, 2013
Fix NPE on startup fixes problem that arose after fixing issue #77
@just-push-it
Copy link
Member

Should be fixed now. Was just a simple ordering problem

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

No branches or pull requests

3 participants