Delphi-Cross-Socket icon indicating copy to clipboard operation
Delphi-Cross-Socket copied to clipboard

epoll rewrite

Open ghost opened this issue 6 years ago • 9 comments

hello,

imho your code is well written, especially the IOCOMP windows code, however let me express doubts about the scalability and reliability of EPOLL linux wrapper, using a single thread with global locking queue, you should avoid this

best regards Roberto

ghost avatar Jan 15 '19 10:01 ghost

another hint I see you use extensively TList and .ToArray method, then using a for iteration for lookup, as example I see this in WebsocketServer (O2 complexity) you should avoid global locking as TMonitor if possible, make use of TCriticalSection, but I suggest to make a right use of generic.collections as TDictionary<Type> to obtain O1 lookup time; this will be useful with high number of users

ghost avatar Jan 15 '19 11:01 ghost

also consider that a static class function is very faster against a interfaces one

ghost avatar Jan 15 '19 11:01 ghost

(...) or you can bind directly the callback within every connection (instead of interface), then avoid/erase to iterate an array obtained from a global list everytime a message is received (guess a chat with thousand users...). So use a direct pointer, or a dictionary if you want keep a global list with interfaces.

ghost avatar Jan 15 '19 11:01 ghost

Thank you very much for your suggestion, perhaps you can help me improve the code, then do a comparison test, thank you again.

winddriver avatar Jan 16 '19 01:01 winddriver

Thank you for this great library. Now I don't have time to modify it, later I can try to provide some changes, then we can use a profiler to check the timing of the routines (maybe using SleuthQA of Per Larsen, now sold by Nexus Quality Suite). Anyway the most important thing you can do is avoid to use iteration/copy of lists on the common used functions, instead use a lookup as tdictionary (hash table) or avoid it completely, redesign the flow (eg. put the function/callback/smart pointer inside every class avoiding the use of a global container). See you soon I wish. Best regards.

ghost avatar Jan 16 '19 15:01 ghost

估计这老兄看上你的项目了,可能要找你合作!

pony5551 avatar Jan 19 '19 22:01 pony5551

another hint: use const keyword when you pass the parameter in a function const don't copy the string, or use var if you need manage it and return it I suggest use TBytes and setlength one shot, then use TEncoding.ASCII.GetBytes etc. avoid copymem most possible use scatter/gather buffering zerocopy methods avoid global locking semaphores, use interlocked API ...

ghost avatar Jan 19 '19 23:01 ghost

hi Roberto

It is recommended that you modify part of the code on the branch for reference!

pony5551 avatar Jan 20 '19 01:01 pony5551

hello,

imho your code is well written, especially the IOCOMP windows code, however let me express doubts about the scalability and reliability of EPOLL linux wrapper, using a single thread with global locking queue, you should avoid this

best regards Roberto

Can you point out the problem code, modify some of the code, and test the effect!

pony5551 avatar Feb 18 '19 08:02 pony5551