Jump to content

Recommended Posts

Posted (edited)

ConcurrentDictionary is similar to ConcurrentHashMap ? Cause atm you simply need a HashMap, as you simply use it to check, and that map is fed normally only once (and content never replaced, removed or edited anew).

 

You obviously didn't noticed that he creates and runs a new thread for handling and running a dumb client request (they may come as thousands per second on a decent server), so I guess optimization and efficieny is the least of his concerns for now at least, his just making things that should work no matter the cost.

Edited by xxdem
Posted

Threadhandling and concurrency and async tasks is handled differently in CLR than JVM so you cant compare it.

 

My thread will be disposed in milliseconds once its executed. If the call was synchronous i would have performance issues.

 

All of those thread will be handled by enqueue eventually if they need to.

Posted (edited)

You obviously didn't noticed that he creates and runs a new thread for handling and running a dumb client request (they may come as thousands per second on a decent server), so I guess optimization and efficieny is the least of his concerns for now at least, his just making things that should work no matter the cost.

 

Until I missed the point, the map is used as a static checker for packet opcode and class reference, nothing else.

 

It worked fine before. I don't see the use of replacement, except winning 200 lines (at best and only for GS) on a never edited class.

 

----

 

K then, if it's differently handled. I clearly doubt concurrent is better performance than a simple switch = new object though. It must perform similar anyway.

Edited by Tryskell
Posted

Until I missed the point, the map is used as a static checker for packet opcode and class reference, nothing else.

 

It worked fine before. I don't see the use of replacement, except winning 200 lines (at best and only for GS) on a never edited class.

 

----

 

K then, if it's differently handled. I clearly doubt concurrent is better performance than a simple switch = new object though. It must perform similar anyway.

Only time will tell. Forget the concurrent keyword. It is just there because i use a Synchronization attribute in the class .

Technically it could be a simple Dictionary and i will test it that way too as a simple dictionary upon population is almost 2 times faster.

Posted

You obviously didn't noticed that he creates and runs a new thread for handling and running a dumb client request (they may come as thousands per second on a decent server), so I guess optimization and efficieny is the least of his concerns for now at least, his just making things that should work no matter the cost.

Interestingly enough I debugged the threads and yeah they where disposed really fast but I removed them, see how it performs and add a queue if it is needed.

 

About the benchmarking it performs exactly the same (Apart of the initial Dictionary loading which happens on startup anyway) but it is just way more easy to maintain and debug (which is very important for a project that is still adding the packets).

I can add a packet in one line instead of 5 and stepping through the code it way better.

Posted

Interestingly enough I debugged the threads and yeah they where disposed really fast but I removed them, see how it performs and add a queue if it is needed.

 

About the benchmarking it performs exactly the same (Apart of the initial Dictionary loading which happens on startup anyway) but it is just way more easy to maintain and debug (which is very important for a project that is still adding the packets).

I can add a packet in one line instead of 5 and stepping through the code it way better.

 

Just make 2-8 Thread workers and add Client Requests on their Queues, these threads are supposed to sleep a given time and execute from the queue forever.

 

I can tell you many reasons why creating a new thread sucks for every client request one of them and most important from me is that the Player has direct access on your resources both soft and hard, whereas in a worker queue design he can't

Posted

Just make 2-8 Thread workers and add Client Requests on their Queues, these threads are supposed to sleep a given time and execute from the queue forever.

 

I can tell you many reasons why creating a new thread sucks for every client request one of them and most important from me is that the Player has direct access on your resources both soft and hard, whereas in a worker queue design he can't

Yeah Enqueue should be fine. Really glad i got rid of that ugly switch statement. Thanks for the recommendation.

Posted

Yeah Enqueue should be fine. Really glad i got rid of that ugly switch statement. Thanks for the recommendation.

 

the switch statement has nothing to do with that, it was ugly but supper fast. Your design has the overhead of searching every time for the class and then initiating its instance through reflection. I guess its 100x slower but for sure cleaner and the overhead impact is unnoticeable 

Posted

the switch statement has nothing to do with that, it was ugly but supper fast. Your design has the overhead of searching every time for the class and then initiating its instance through reflection. I guess its 100x slower but for sure cleaner and the overhead impact is unnoticeable 

It is as fast as checking a small HashMap for a key value which is technically the same as as switch of the same size.

Posted

It is as fast as checking a small HashMap for a key value which is technically the same as as switch of the same size.

 

Im not talking about the HashMap, HashMap is super fast O(1) in most cases, Im talking about Class.newInstance which most probably is done with reflection on the runtime, I doubt that EnterWorld.class.getConstructor().newInstance() is anything close to "new EnterWorld()" in terms of perfomance

Posted

Im not talking about the HashMap, HashMap is super fast O(1) in most cases, Im talking about Class.newInstance which most probably is done with reflection on the runtime, I doubt that EnterWorld.class.getConstructor().newInstance() is anything close to "new EnterWorld()" in terms of perfomance

It is indeed using reflection but it caches the action so once it's done then it acts the same as new EnterWorld(), because it uses System instead of Reflection to create the instances. But that means that every single packet would have to be created with reflection at least once.

Posted

bWxaYHh.png

 

After some benchmarking it seems that in heavy load (50kk iterations) Activator.CreateInstance is up to 4 times slower (can get higher).

I know that's nothing for l2 but i wanna get as much horsepower as possible so i will be replacing Activator with compiled lambda expressions.

  • 2 weeks later...
Posted

Added the basic implementation of a Plugin API.

 

Simply create a class library on .NET Framework 4.6, extend the Plugin class and override whichever method you want.

Then drop the dll in the plugins folder and thats it.

 

3segxli.png

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




  • Posts

    • L2JMobius C1 System C1 + bonus textures C3 for C1 https://www.mediafire.com/folder/6oh7l7hf34xr9/C1
    • https://prnt.sc/Bkkc0ShGXv9m https://prnt.sc/-JFLvZXsn27A
    • Hello guys want to sell adena in L2 Reborn Signature x1  Stock =14kk good price 
    • Hi guys, I have the following problem, I want to set up two servers on the same dedicated server and I can't.   L2jacis 409 Linux Server. The first gameserver has the following configuration: # ================================================================ # Gameserver setting # ================================================================ # This is transmitted to the clients, so it has to be an IP or resolvable hostname. If this ip is resolvable by Login just leave * Hostname = 190.25.103.103 # Bind ip of the gameserver, use * to bind on all available IPs. GameserverHostname = * GameserverPort = 7777 # The Loginserver host and port. LoginHost = 127.0.0.1 LoginPort = 9014 # This is the server id that the gameserver will request. RequestServerID = 1 # If set to true, the login will give an other id to the server (if the requested id is already reserved). AcceptAlternateID = True UseBlowfishCipher = True # ================================================================ # Database informations # ================================================================ URL = jdbc:mariadb://localhost/server1 Login = server1 Password = server1 I configured the second gameserver like this:   # ================================================================ # Gameserver setting # ================================================================ # This is transmitted to the clients, so it has to be an IP or resolvable hostname. If this ip is resolvable by Login just leave * Hostname = 0.0.0.0 # Bind ip of the gameserver, use * to bind on all available IPs. GameserverHostname = * GameserverPort = 7788 # The Loginserver host and port. LoginHost = 127.0.0.1 LoginPort = 9014 # This is the server id that the gameserver will request. RequestServerID = 2 # If set to true, the login will give an other id to the server (if the requested id is already reserved). AcceptAlternateID = True UseBlowfishCipher = True # ================================================================ # Database informations # ================================================================ URL = jdbc:mariadb://localhost/server2 Login = server2 Password = server2 apart from having tested 0.0.0.0 on the second gameserver I also tried 127.0.0.1 In both cases I see the two servers in the login when I log in, but I try to enter the one with the lowest ping and it kicks me out. The other server always appears with ping 9999 and I try to enter but it doesn't do anything and it freezes the login so I have to log in again. The hexids are in their respective folders. For server 1, it has its hexid inside the gameserver config folder, and I checked that the hexid id is the same id, for example id 1 in the gameserver is also id1 for server 1, and hexid 2 has its hexid 2 for server 2. The server ports are open and listening when I turn on both gameservers. I really don't know what could be wrong. If you could give me some help I would appreciate it. Excuse my English.
  • Topics

×
×
  • Create New...