tmds / Tmds.LinuxAsync

MIT License
25 stars 3 forks source link

Operation is not valid due to the current state of the object #44

Closed adamsitnik closed 4 years ago

adamsitnik commented 4 years ago

@tmds this is what I get when I am trying to use the io_uring mode:

--path "/json" --arg "-e=iouring" --arg "-t=4" --arg "-s=false" --arg "-r=false" --arg "-c=false" --arg "-a=true" --arg "-w=false" --connections 256 
[STDERR] Process terminated. System.InvalidOperationException: Operation is not valid due to the current state of the object.
[STDERR]    at Tmds.LinuxAsync.ThrowHelper.ThrowInvalidOperationException() in /tmp/benchmarks-agent/benchmarks-server-6/vpq1s2p2.pom/Tmds.LinuxAsync/src/Tmds.LinuxAsync/ThrowHelper.cs:line 11
[STDERR]    at Tmds.LinuxAsync.AsyncOperationResult.get_Value() in /tmp/benchmarks-agent/benchmarks-server-6/vpq1s2p2.pom/Tmds.LinuxAsync/src/Tmds.LinuxAsync/AsyncExecutionQueue.cs:line 49
[STDERR]    at Tmds.LinuxAsync.IOUringAsyncEngine.IOUringThread.<>c.<AddReadFromEventFd>b__31_0(AsyncOperationResult asyncResult, Object state, Int32 data) in /tmp/benchmarks-agent/benchmarks-server-6/vpq1s2p2.pom/Tmds.LinuxAsync/src/Tmds.LinuxAsync/IOUringAsyncEngine.IOUringThread.cs:line 227
[STDERR]    at Tmds.LinuxAsync.IOUringAsyncEngine.IOUringExecutionQueue.ExecuteCompletions() in /tmp/benchmarks-agent/benchmarks-server-6/vpq1s2p2.pom/Tmds.LinuxAsync/src/Tmds.LinuxAsync/IOUringAsyncEngine.IOUringExecutionQueue.cs:line 275
[STDERR]    at Tmds.LinuxAsync.IOUringAsyncEngine.IOUringThread.EventLoop() in /tmp/benchmarks-agent/benchmarks-server-6/vpq1s2p2.pom/Tmds.LinuxAsync/src/Tmds.LinuxAsync/IOUringAsyncEngine.IOUringThread.cs:line 78
[STDERR]    at System.Environment.FailFast(System.String)
[STDERR]    at Tmds.LinuxAsync.IOUringAsyncEngine+IOUringThread.EventLoop()
[STDERR]    at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
[STDERR]    at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
[STDERR]    at System.Threading.ThreadHelper.ThreadStart()
tmds commented 4 years ago

This doesn't reproduce for me:

dotnet run -c Release -- -t 1 -s false -r false -c false -a true -w false
$ ./wrk http://localhost:5000/plaintext
Running 10s test @ http://localhost:5000/plaintext
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   677.70us    2.63ms  66.36ms   94.92%
    Req/Sec    35.44k     6.40k   48.70k    84.00%
  705655 requests in 10.02s, 88.83MB read
Requests/sec:  70436.42
Transfer/sec:      8.87MB

From the exception it seems AsyncOperationResult asyncResult doesn't have a result: https://github.com/tmds/Tmds.LinuxAsync/blob/0162f496f4222f84152a5c9c18923f8f7f7c1576/src/Tmds.LinuxAsync/IOUringAsyncEngine.IOUringThread.cs#L224-L227

I'll try to find out when that can happen. I won't get to that today.