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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • Posts

    • Hello! I am new to l2 server creation and i need your help please!!! I want to make my own l2 interlude c6 server with custom thing in it.  I need help with where to start. What source pack to pick to start and what to do. Please if you can help me i would appreciate it very much !!!
    • Need Discord with rare badge? VISIT US AND SHOP WITH US! NEW STOCK   Aged, Early Supporter Discord Accounts I sell HQ Aged and Early, Discord Accounts that are inactive and not flagged by discord at cheap prices   If you want to contact me, you can add me on discord: worldcoldwar Features: Format - age : email : pass : token Not flagged and undetected by discord HQ % With OGE Emails, password etc can be changed Unverified Early Supporter 24M Boost Badge HypeSquad Events Early Verified Bot Developer Early Supporters SHOP LINK: disvault1.mypaylix.gg/ For PayPal payments, please open a ticket. If you experience any problems with cryptocurrency payments, please open a ticket as well.
    • Tired of frantically switching between windows trying to find that specific Warlock who should be casting saves? Forgot which server you left your Warsmith on? This mod solves these problems! What it does: Turns the boring window title into an information panel: Server Name - Character Name [Class] Real-life examples: - ServerName - HardcoreFarm [Spoilerr] (who's been spoiling for 3 months already) - ServerName - ClericHelper [Buffer] (eternal buffer on standby) - ServerName - MainChar [Gladiator] (main character who's always AFK) Why you need this: For multiboxers - to avoid confusing where the DD is and where the healer is For the forgetful - if your memory is like a goldfish For streamers - viewers immediately see who's on screen For adults - when playing at work and need to quickly hide the window DLL only - no Interface files needed Installation (more complicated than making tea): 1. Download the DLL 2. Drop it into the System folder 3. Launch the client 4. Be amazed how you lived without this before!   Purchase Conditions: Price: 100$ Payment Method: USDT. How to Buy: Contact me on Telegram: @kiselevwv for a quick response. I will answer all your questions and provide additional information if needed. I guarantee functionality at the moment of sale and prompt assistance with setup after purchase.    
    • Hello Everyone   Wts adena  L2 REBORN C5 FRANZ x1 50kk stock 😉   Contact Discord :  topseller4081  
    • tratando de crear un GvE tengo problemas con el scripts como no se mucho de esto me estoy ayudando con IA pero no puedo salir de este bache      [06:19:43]  WARN Quest GvE_AI not found! [06:19:45]  WARN Quest GvE_AI not found! [06:19:50]  WARN Quest GvE_AI not found! [06:25:51]  WARN Quest GvE_AI not found!
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..