You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Mark Thomas <ma...@apache.org> on 2010/09/12 18:45:55 UTC
Async refactoring
Digging into the root causes of [1] it appears that there are a number
of threading / timing issues with the current AsyncContextImpl. Running
the provided test case with ab -n 50 -c 20 triggers the error every
couple of runs. The error appears to occur when the thread where
complete() is called finishes before the thread where startAsync() is
called.
There were a number of places / ways this could happen:
- the checks if current state are not thread safe
- the state changes are atomic but the actions that are part of that
state were not atomic
- the spec requirement the complete() and dispatch() must wait until the
thread where startAsync() is called completes are not met
- socket level processing is handled by the executor so there is no
guarantee of processing order
I had a couple of false starts trying to fix this but my current attempt
[2] is showing some promise. The test case from [1] runs without error
with ab -n 5000 -c 400 with or without -k.
At the moment [2] is in a very rough and ready state and only handles
startAsync() and complete() for the BIO HTTP connector. I wanted to give
folks early sight of this patch so I could incorporate any early feedback.
I plan to expand the patch to cover dispatch(), timeouts, the other
connectors, passing our test cases and passing the TCK before
committing. I'm not sure how long that will take. I hope to get this
done this week.
Mark
[1] https://issues.apache.org/bugzilla/show_bug.cgi?id=49884
[2]
http://people.apache.org/~markt/patches/2010-09-12-async-refactoring.patch
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: Async refactoring
Posted by Mark Thomas <ma...@apache.org>.
On 12/09/2010 17:45, Mark Thomas wrote:
> Digging into the root causes of [1] it appears that there are a number
> of threading / timing issues with the current AsyncContextImpl. Running
> the provided test case with ab -n 50 -c 20 triggers the error every
> couple of runs. The error appears to occur when the thread where
> complete() is called finishes before the thread where startAsync() is
> called.
<snip/>
> At the moment [2] is in a very rough and ready state and only handles
> startAsync() and complete() for the BIO HTTP connector. I wanted to give
> folks early sight of this patch so I could incorporate any early feedback.
>
> I plan to expand the patch to cover dispatch(), timeouts, the other
> connectors, passing our test cases and passing the TCK before
> committing. I'm not sure how long that will take. I hope to get this
> done this week.
>
> [1] https://issues.apache.org/bugzilla/show_bug.cgi?id=49884
> [2]
> http://people.apache.org/~markt/patches/2010-09-12-async-refactoring.patch
Just to keep folks in the loop. The latest patch [3] is now available
for you to take a look at. It now handles timeouts and passes all our
tests cases. It even does pretty well with the TCK.
In further testing of [1] I came across an edge case that required
adding a lock to the SocketWrapper. Without this requests could get lost
and end up timing out when they should have been processed.
Performance-wise this doesn't appear to add any noticeable cost.
My plan is still to get this fully working for BIO HTTP before extending
it to the other connectors. Still on the to do list for BIO HTTP are:
- checking dispatches work (need to add some test cases for this)
- fixing timeouts (I know these are broken)
- error handling (largely commented out at the moment)
I don't want to commit this incrementally since that will just trigger a
deluge of failed test reports from Gump and buildbot. If folks would
prefer a more incremental approach and can live with the nags for a few
weeks, I'm happy to commit rather than provide patches for review.
Mark
[3]
http://people.apache.org/~markt/patches/2010-09-15-async-refactoring.patch
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org