Project

General

Profile

Actions

Defect/Bug #94

closed

Grief Prevention Loading Time at 5 min. - B-Team

Added by Slind over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
-
Target version:
-
Start date:
2015-06-09
Due date:
2015-06-12
% Done:

100%

Estimated time:
5.00 h
Resolution:
Fixed/Completed
Modpack(s):
Attack of the B-Team
Node:

Description

The claim loading time on B-Team is extremely high. We should either look for an automated cleanup of claims from players that didn't spent much time or high improve the performance of the loading process.

Comparison:

B-Tema 1 (flat file)
    loading time     6m 32s
    claim data    6.421
    player data    34.694

B-Team 2 (flat file)
    loading time     6m 4s
    claim data    7.571
    player data    28.947

B-Team 3 (mysql)
    loading time     35s
    claim data    2.388
    player data    7.374

Script for flat file to db migration (not needed but at least 10 times faster than grief prevention's, but it is ignoring parent ships and non builder trust's, which are barely used) - created as grief prevention didn't want to convert in the first place

#!/usr/bin/python

import MySQLdb
import os

db = MySQLdb.connect("localhost","user","password","database")
cursor = db.cursor()

for fn in os.listdir('./plugins/GriefPrevention/ClaimData'):
    claim_id = fn
    claim_data = open('./plugins/GriefPrevention/ClaimData/' + fn, 'r')
    lines = claim_data.readlines()
    claim_data.close()

    if len(lines) > 4:
        claim_lessercorner = lines[0]
        claim_greatercorner = lines[1]
        claim_owner = lines[2]
        claim_builders = lines[3]

    cursor.execute("""INSERT INTO griefprevention_claimdata (id, owner, lessercorner, greatercorner, builders, containers, accessors, managers, parentid, neverdelete)
                          VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", (claim_id, claim_owner, claim_lessercorner, claim_greatercorner, claim_builders, "", "", "", -1, 0))
    db.commit()
    print (claim_owner)

for pn in os.listdir('./plugins/GriefPrevention/PlayerData'):
    player_name = pn
    player_data = open('./plugins/GriefPrevention/PlayerData/' + pn, 'r')
    lines = player_data.readlines()
    player_data.close()

    if len(lines) > 4:
        player_lastlogin = lines[0]
        player_accruedblocks = lines[1]
        player_bonusblocks = lines[2]

    cursor.execute("""INSERT INTO griefprevention_playerdata (name, lastlogin, accruedblocks, bonusblocks, clearonjoin)
                          VALUES(%s, %s, %s, %s, %s)""", (player_name, player_lastlogin, player_accruedblocks, player_bonusblocks, 0))
    db.commit()
    print (player_lastlogin)

db.close()

DB cleanup queries

DELETE
FROM `griefprevention_playerdata` 
WHERE (accruedblocks = 200 AND bonusblocks = 0) OR lastlogin < NOW() - INTERVAL 14 DAY;

DELETE c
FROM `griefprevention_claimdata` c
LEFT JOIN griefprevention_playerdata p
ON c.owner = p.name
WHERE c.builders = "" AND p.name IS NULL;

Actions

Also available in: Atom PDF