29 - Database connections

Just testing v2.3 for someone on the Bukkit forums.

Just some pointers, which could make this plugin so much better :)

Your version checker should NOT run in the main thread. You need to run it in a async task else the whole server freezes while its trying to connect to your web-server (Which will always include a massive delay, unless your running your server right next to your web server.)

You should not need create a new Connection every time you need one, it takes about 1ms to make connections to the SQLite db which is madness. Try caching the connection for a certain amount of time. (Maybe make it expire after about 10-20 ms of not being used)

Also, if you did not know already, player.sendMessage("My Message"); can be called in separate threads. So, you can actually offload all of your commands onto a separate thread (After they have finished checking for stuff like permissions)

You could do that by creating a queue of commands (Just storing the onCommand arguments in a queue) and then running them in a separate thread.

Another idea to speed things up (which might be easier to implement than the above ideas) is to use a memory sqlite db as storage, and periodically update the MySQL/SQLite databases with changes in async. That way you don't have to worry about running a heap of async tasks. And reading/writing from the memory sqlite db is pretty much instant.

  • modreq.png
    Version Checker Delay
User When Change
sw123 Dec 10, 2013 at 10:33 UTC Changed status from New to Declined
ShadowDog007 Apr 06, 2013 at 22:22 UTC

Added attachment modreq.png

ShadowDog007 Apr 06, 2013 at 22:21 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of sw123 sw123 Apr 09, 2013 at 15:45 UTC - 0 likes

    @ShadowDog007: Go

    I pushed the latest code to github.


  • Avatar of ShadowDog007 ShadowDog007 Apr 08, 2013 at 19:01 UTC - 0 likes

    @sw123: Go

    Your version checker I checked the time it took to run with the Bukkit Timings profiler (Someone elses timings, which led me to bother checking it myself) This thing is awesome. Times how long every method runs (including bukkit methods your plugin calls)

    If you put your source on GitHub I would be interested in forking it and making some pull requests :)

    Your plugin is exactly what I need for my server :) Its great what you've done so far, and I would love to help improve it :)

    Last edited Apr 08, 2013 by ShadowDog007

  • Avatar of sw123 sw123 Apr 08, 2013 at 15:36 UTC - 0 likes

    What tool did you use to measure the speed, that way I can tweak performance. I will look into the methods you described above. Despite the fact that I like most of the methods before and that I was not aware of most of these, it might take a while to implement all of these methods. I will add the methods that improve performance the most first, and slowy make my way up the the less influencing methods.

    I will keep you up to date with my progress, as I try to finish this as soon as my spare time allows me to. My final exams are coming up in a few weeks and I need my time to prepare well. I am sure you would understand. I am adding the ModReq service in the may break. If you have any suggestions for the service, or in fact any another suggestion in general, they are welcome, and I will try to implement them as soon as I can.

    Greetings, sw123 (you may call me Sven, since that is my real name)



Last updated
Dec 10, 2013
Apr 06, 2013
Declined - We decided not to take action on this ticket.
Defect - A shortcoming, fault, or imperfection
Medium - Normal priority.

Reported by

Possible assignees