From 23e1803a81af4fdb4099aff8dcabea86b133f992 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Mon, 29 Sep 2014 16:12:32 -0700 Subject: [PATCH] Better boot logging and performance. Improved boot logs to get more specific performance numbers, and eliminated some non-essential boot steps to improve performance. --- .../GriefPrevention/DataStore.java | 25 ++++--------------- .../GriefPrevention/GriefPrevention.java | 9 ++++++- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/DataStore.java b/src/me/ryanhamshire/GriefPrevention/DataStore.java index 54725ce..1f5c6a2 100644 --- a/src/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/me/ryanhamshire/GriefPrevention/DataStore.java @@ -94,26 +94,12 @@ public abstract class DataStore { GriefPrevention.AddLogEntry(this.claims.size() + " total claims loaded."); - //make a list of players who own claims - Vector playerNames = new Vector(); - for(int i = 0; i < this.claims.size(); i++) - { - Claim claim = this.claims.get(i); - - //ignore admin claims - if(claim.isAdminClaim()) continue; - - if(!playerNames.contains(claim.ownerID)) - playerNames.add(claim.ownerID); - } - - GriefPrevention.AddLogEntry(playerNames.size() + " players have staked claims."); - //load up all the messages from messages.yml this.loadMessages(); + GriefPrevention.AddLogEntry("Customizable messages loaded."); //if converting up from an earlier schema version, write all claims back to storage using the latest format - if(this.getSchemaVersion() < this.latestSchemaVersion) + if(this.getSchemaVersion() < latestSchemaVersion) { GriefPrevention.AddLogEntry("Please wait. Updating data format."); @@ -121,13 +107,12 @@ public abstract class DataStore { this.saveClaim(claim); } + + GriefPrevention.AddLogEntry("Update finished."); } - //collect garbage, since lots of stuff was loaded into memory and then tossed out - System.gc(); - //make a note of the data store schema version - this.setSchemaVersion(this.latestSchemaVersion); + this.setSchemaVersion(latestSchemaVersion); } //removes cached player data from memory diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 5a4e298..50836b3 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -171,7 +171,7 @@ public class GriefPrevention extends JavaPlugin //initializes well... everything public void onEnable() { - AddLogEntry("Grief Prevention enabled."); + AddLogEntry("Grief Prevention boot start."); instance = this; @@ -660,6 +660,8 @@ public class GriefPrevention extends JavaPlugin this.config_pvp_blockedCommands.add(commands[i].trim()); } + AddLogEntry("Finished loading configuration."); + //when datastore initializes, it loads player and claim data, and posts some stats to the log if(databaseUrl.length() > 0) { @@ -713,6 +715,9 @@ public class GriefPrevention extends JavaPlugin } } + String dataMode = (this.dataStore instanceof FlatFileDataStore)?"(File Mode)":"(Database Mode)"; + AddLogEntry("Finished loading data " + dataMode + "."); + //unless claim block accrual is disabled, start the recurring per 5 minute event to give claim blocks to online players //20L ~ 1 second if(this.config_claims_blocksAccruedPerHour > 0) @@ -779,6 +784,8 @@ public class GriefPrevention extends JavaPlugin GriefPrevention.AddLogEntry("ERROR: Vault was unable to find a supported economy plugin. Either install a Vault-compatible economy plugin, or set both of the economy config variables to zero."); } } + + AddLogEntry("Boot finished."); } //handles slash commands