News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

the James Ladd's FASt Server - Win32 Socket Library

Started by six_L, December 07, 2007, 03:49:49 AM

Previous topic - Next topic

James Ladd

six_l

Im not sure what you mean by
Quotenone is interesting at my question.

However, here are some comments on making a server fast:

1. The fastest way to do anything is not to have to do it.
    So don't block, don't context switch and don't consume more resources than you absolutely need to.

2. Synchronization hurts, so avoid it.
    Try not to have points in your app that require you to wait, like a mutex or semaphore (locks).
    Luckily we are using assembler and there are algos out there that use CPU atomic compare,
    test and swap so you can do away with locks.

3. Look at the through put of the system and who needs to be responsive.
    If you get a Windows event because some data has arrived, it may prove better to put this into a queue
    for handling than try and handle it then and there, since you are starving the system of resources.
    For example, with IO Completion, take the completion and put it onto your queue, releasing the
    system resource.

4. You can make do with two threads per CPU but you should also have a few extras for house keeping.
    For example, scavenging stale accept sockets etc.

5. Avoid copying data as much as possible.
    You may be very surprised to find out how many times data is copied from buffer to buffer from the network card to your
    program code.

6. The protocol you are implementing can also have a substantial impact on performance when
    you measure through-put.
    Detecting and setting packet sizes and other transmission characteristics will help.




six_L

Hello,James Ladd
as had seen your post, i'v got new knowledge.
pursuing the balance is better than pursuing the speed. this is the problem of local efficient and Global efficient.

Thank you very much.
regards