Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

[1.10.2] Flowing water causes extreme lag #4

Closed
Brycey92 opened this issue Jan 19, 2018 · 5 comments
Closed

[1.10.2] Flowing water causes extreme lag #4

Brycey92 opened this issue Jan 19, 2018 · 5 comments

Comments

@Brycey92
Copy link
Collaborator

Whenever water is placed and allowed to flow with Universe Guard installed, whether inside or outside of a region, the server lags tremendously. Using Tick Profiler, I traced the lag back to com.universeguard.utils.RegionUtils.loadRegions, which calls com.google.gson.Gson.fromJson, which ends up using Java reflection to perform its task somewhere down the line, which causes extreme delays each tick. Switching to a different Json parser or adding other storage formats should resolve this problem.

@JimiIT92
Copy link
Owner

I know the flowing flags are extremely "heavy" to handle and i'm already looking into a way to make them "lighter". For the parser, i already plan at some point to introduce the ability to store regions into a Database (probably a RedisDB, or making the type of DB selectable by config). The actual Json parser has been used because it's already into the SpongeAPI, and also because is really simple parsing a Java class into a Json (wich is how Regions are saved). But of course if you know a better parser that is also easy to use please let me know and i'll see if i can use that :)

@Brycey92
Copy link
Collaborator Author

Brycey92 commented Jan 19, 2018

I did some work with IBM a little over a year ago, and we used the javax.json package for simple, fast json parsing and construction. The package is part of Java's JSON-P API, which can be found here. Just go to Download from the main page and click the link under the Specification heading. The API is typically part of Java EE, but the jar can be included in projects using Java SE.

Of course, Universe Guard shouldn't load regions from disk every single time an event needs to be checked. I believe other protection plugins cache their data in memory and only save to disk until/unless a data reload command is sent.

@JimiIT92
Copy link
Owner

THank you for your suggestion. Caching region is also something i'm working on, cause i know that handling many regions is heavy :) I hope to add this cache system into the next release ;)

@JimiIT92
Copy link
Owner

Region cache added in the next version ;)

@JimiIT92
Copy link
Owner

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants