[Release] ProTips on increasing performance

Junior Spellweaver
Joined
Mar 24, 2009
Messages
173
Reaction score
18
1) Remove the RMI. RMI causes more lag because of ObjectOutputStream/ObjectInputStream.

2) Replace the RMI with a faster method, like TCP/IP

3) Most server OutOfMemoryErrors are caused by cache overflow. Occasionally clear the cache.

4) Do NOT call System.gc(). gc() will only cause more leaks to happen.

5) Xmx is not a good way of allocating extra memory. You should fix the memory leaks, rather than try to force more memory into the JVM.

6) Close all PreparedStatements/ResultSets after use. A lot of leaks happen because of that.

6) Instead of Object obj, use WeakReference<Object> obj

7) Do not call classes which DON'T have to be loaded. Even better, create 2 projects for LoginServer/WorldServer

8) Rather than String s = "String " + " String", use StringBuilder sb = new StringBuilder(); sb.append(..);
 
RMI is remote method invocation.
7. Debatable.
9. Not always the case, if you concatenate 2 or 3 small strings then it's faster.
 
RMI is remote method invocation.
7. Debatable.
9. Not always the case, if you concatenate 2 or 3 small strings then it's faster.
I'm surprised your not arguing over -xmx being a forced method like I stated in my previous thread.

Anyway, as for the cache, it won't do much of a difference. Noones allocating memory properly. Keep in mind Odin is not like eAthena. it doesn't allocate automatically in all cases. You will need to tell Windows to allocate. It's good to clear your cache every month or so but it wont do much of a difference performance wise except munch up a bit more RAM
 
RenoriaServer has all these implemented, and is way more stable than HurricaneMS. I'm too lazy to remove RMI and things, but I'm leaving Maple Development so I may as well help the non-leechers.
 
@ X-tasis - Woops typo. 8*

Kippiеeej;4935220 said:
All small bits help.
- Don't do stuff like creating an entire new object for a random, while you can use nextInt

also


i'd be surprised if someone is able to do this
i think you should remove those two

It's really not that hard. Just time consuming if you want to redesign the way they connect


Whoevers interested - might give you better RMI connection.



I'm surprised your not arguing over -xmx being a forced method like I stated in my previous thread.

Anyway, as for the cache, it won't do much of a difference. Noones allocating memory properly. Keep in mind Odin is not like eAthena. it doesn't allocate automatically in all cases. You will need to tell Windows to allocate. It's good to clear your cache every month or so but it wont do much of a difference performance wise except munch up a bit more RAM

I still stand by my opinion. Xmx does not force memory but allows the JVM for a larger heap space.
"clear your cache every month"
How long has your server been on without a server check ? 2 weeks ?
 
Kippiеeej;4935220 said:
All small bits help.
- Don't do stuff like creating an entire new object for a random, while you can use nextInt

also


i'd be surprised if someone is able to do this
i think you should remove those two

Like PinkGatsby said, it's not hard to do just tedious.
 
1) Remove the RMI. RMI causes more lag because of ObjectOutputStream/ObjectInputStream.

2) Replace the RMI with a faster method, like TCP/IP

3) Most server OutOfMemoryErrors are caused by cache overflow. Occasionally clear the cache.

4) Do NOT call System.gc(). gc() will only cause more leaks to happen.

5) Xmx is not a good way of allocating extra memory. You should fix the memory leaks, rather than try to force more memory into the JVM.

6) Close all PreparedStatements/ResultSets after use. A lot of leaks happen because of that.

6) Instead of Object obj, use WeakReference<Object> obj

7) Do not call classes which DON'T have to be loaded. Even better, create 2 projects for LoginServer/WorldServer

8) Rather than String s = "String " + " String", use StringBuilder sb = new StringBuilder(); sb.append(..);

I don't get it, why StringBuilder is better..
less memoy, faster processing ?

-Use System.out.printIn or System.err.printIn instead of the slfj-logging shyt
-Remove logs, no one views it in the console unless for debug uses
-Use as little RMI connection as possible if you don't know how to redesign it
-Add a timer to cleanup every cached object in MapleItemInformationProvider every 6~12 hours
-Remove odinms login queue method, use for (ChannelServer.getAllInstances() : get all player count instead
-Change some values such as int to short / byte when you don't need that much
-Try to use SQL as little as possible
-Use array string/ int for guild informatiom then save then shutting server (Implement it at shutdown code)
-Set limit on the max number of BBS (To prevent PE-er crashing server)
-Redesign PlayerNPCs, do not let it to touch SQL database everytime character change map (Make a handler for it)
-Redesign the events such as ship / geenie and etc.. those are a huge memory leak of OdinMS created during flowsion shyt
 
Last edited:
I don't get it, why StringBuilder is better..
less memoy, faster processing ?

Are you serious ?

StringBuilder/StringBuffer is a sequence of character strings that can be altered.

String s = "Ping "+"Pong";

Strings cannot be altered once they've been created. Everytime you do '+' (Concatenating) it creates a new String object where as if you do StringBuilder.insert()/append() it adds it to the buffer.
PHP:
String[] example = {"Hello ", "I ", "am ", "PinkGatsby."};
String output = "";
for (String msg : example)
output += msg;
System.out.println(output);

That would create 5 String objects whereas this would create 2 objects, the starting and the final sb.toString().

PHP:
String[] example = {"Hello ", "I ", "am ", "PinkGatsby."};
StringBuilder sb = new StringBuilder();
for (String msg : example)
sb.append(msg);
System.out.println(sb.toString());
 
Back