tmds / Tmds.LinuxAsync

MIT License
25 stars 3 forks source link

Refactor: split AsyncOperation.TryExecute #77

Closed tmds closed 4 years ago

tmds commented 4 years ago

This splits AsyncOperation.TryExecute to make it more easy to understand what it does.

It is replaced with 3 methods: TryExecuteSync: synchronously attempts to execute the operation TryExecuteAsync: asynchronously attempts to execute the operation, called on io thread When TryExecuteAsync uses the AsyncExecutionQueue (that is: AIO/io_uring), then HandleAsyncResultAndContinue needs to be called from callback to handle the result.

cc @antonfirsov @adamsitnik

tmds commented 4 years ago

This shouldn't reduce performance. It may even help a bit because there is less control flow.

To be sure, @adamsitnik @antonfirsov do you want to run a benchmark to check master vs PR?

--path "/json" --arg "-e=epoll" --arg "-t=ProcessorCount" --arg "-s=false" --arg "-r=false" --arg "-c=false" --arg "-a=true" --arg "-w=false" --arg "-i=true" --arg "-o=inline" --connections 512
adamsitnik commented 4 years ago
--branch master --path "/json" --arg "-e=epoll" --arg "-t=28" --arg "-s=false" --arg "-r=false" --arg "-c=false" --arg "-a=true" --arg "-w=false" --arg "-i=true" --arg "-o=inline" --connections 512
RequestsPerSecond:           1,061,663
Max CPU (%):                 100
WorkingSet (MB):             435
Avg. Latency (ms):           0.48
Startup (ms):                1
First Request (ms):          56.92
Latency (ms):                0.11
Total Requests:              16,030,177
Duration: (ms)               15,100
Socket Errors:               0
Bad Responses:               0
Build Time (ms):             5,502
Published Size (KB):         101,009
SDK:                         5.0.100-preview.3.20174.1
Runtime:                     5.0.0-preview.3.20173.5
ASP.NET Core:                5.0.0-preview.3.20173.4
--branch refactor_split_tryexecute --path "/json" --arg "-e=epoll" --arg "-t=28" --arg "-s=false" --arg "-r=false" --arg "-c=false" --arg "-a=true" --arg "-w=false" --arg "-i=true" --arg "-o=inline" --connections 512
RequestsPerSecond:           1,065,755
Max CPU (%):                 100
WorkingSet (MB):             491
Avg. Latency (ms):           0.48
Startup (ms):                1
First Request (ms):          55.66
Latency (ms):                0.11
Total Requests:              16,092,616
Duration: (ms)               15,100
Socket Errors:               0
Bad Responses:               0
Build Time (ms):             4,001
Published Size (KB):         101,010
SDK:                         5.0.100-preview.3.20174.1
Runtime:                     5.0.0-preview.3.20173.5
ASP.NET Core:                5.0.0-preview.3.20173.4
adamsitnik commented 4 years ago

:shipit:

tmds commented 4 years ago

Thanks Adam!