trafficserver icon indicating copy to clipboard operation
trafficserver copied to clipboard

Http2Stream may not be used across threads

Open maskit opened this issue 4 years ago • 3 comments

The code below implies Http2Stream's event handler can be called from multiple threads, but I'm not sure if it really happens. https://github.com/apache/trafficserver/blob/aa1d73b07fdb43f7e77f1fb72630f91a7086c366/proxy/http2/Http2Stream.cc#L143-L149

@masaori335 says switching threads is necessary for global server session pool, but we have UnixNetVConnection::migrateToCurrentThread and I think it ensures a server session is always on the same thread as the client session.

If Http2Stream is used always on the same thread we should be able to remove the logic, and it would improve performance.

maskit avatar Jul 06 '21 00:07 maskit

Right, the switch threads should not happen. Could maybe change this check to an assert. The switching logic was added earlier as we were debugging some threading problems.

The migration from the global pool should only happen for Http1.x. And that migration should be done before the session is assigned to the state machine

shinrich avatar Jul 12 '21 23:07 shinrich

Talked at the weekly meeting, we should start by logging (or stats) to see how often the thread jumping occurs and why. If we observe nothing, we can just get rid of the code with confidence.

masaori335 avatar Mar 29 '22 00:03 masaori335

I added a metric for thread switching count and monitored it on production, and the switching didn't happen at all. I'm pretty sure we can get rid of the code.

maskit avatar Jul 22 '22 00:07 maskit

This issue has been automatically marked as stale because it has not had recent activity. Marking it stale to flag it for further consideration by the community.

github-actions[bot] avatar Jul 22 '23 01:07 github-actions[bot]