some code performance questions...

If something doesn't fit in any other forum then post it here.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
rychoo84
Posts: 58
Joined: Fri Jan 01, 2010 11:26 am
Location: Breslau

some code performance questions...

Post by rychoo84 »

hi everyone,
as a non-pro part time noob dev I always try to pay attention to code effectiveness/efficiency/performance etc. I would like to ask you (and I bet there are at least dozens or so pro devs among all ppl involved in l2j project) several questions:

1. What's less "heavy" for the server? let's say we have e.g.:

Code: Select all

 // code 1NpcHtmlMessage msg = new NpcHtmlMessage(0)msg.setHtml(HtmCache.getInstance().getHtm(prefix, path));player.sendPacket(msg); // code 2// subquestion: what about TextBuilder() classStringBuilder sb = new StringBuilder(); sb.append( /* html tags */);NpcHtmlMessage msg = new NpcHtmlMessage(0);msg.setHtml(sb.toString());player.sendPacket(msg); 
2. I'm thinking about adding custom field in characters table which will contain player's amount of deaths during pvp. In order to fill the fields I'm going to put some checks into doDie method inside the L2PcInstance class.

My question is: will it affect a lot the gameplay performance if I update the DB every time the char dies in pvp? (which means every death = DB connection) or would it be better if I store the deaths amount in a variable somewhere inside the L2PcInstance class and update it using threadpoolmanager? (I must take under consideration that some chars may catch DC and handle that occurence too)

I hope you don't mind me asking these questions. Looking forward to get some hints.
Thx in advance!
Last edited by rychoo84 on Mon Jan 31, 2011 10:51 am, edited 1 time in total.
User avatar
BiggBoss
L2j Veteran
L2j Veteran
Posts: 1104
Joined: Wed Apr 15, 2009 3:11 pm
Location: Spain

Re: some code performance questions...

Post by BiggBoss »

1)
Htm files are cached into memory (lazy cache just when is used at first time, non lazy cache at server start up). So always will be faster the first option

2) Obviously, store the var into memory and just save on player logs out will be better than a db connection on each die, but i doubt that the database connection on each die would kill your server :roll:
Image
User avatar
rychoo84
Posts: 58
Joined: Fri Jan 01, 2010 11:26 am
Location: Breslau

Re: some code performance questions...

Post by rychoo84 »

allrite, thx for your help BigBoss
Cheers
Post Reply