Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-574

Excessive lock contention in AbstractFramedChannel.queueFrame

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.3.5.Final, 1.4.0.Beta1
    • 1.3.4.Final
    • Core
    • None
    • Hide

      Open a channel, and write to it from many threads

      Show
      Open a channel, and write to it from many threads

      When multiple threads are writing to the same output channel, I'm seeing a lot of lock contention in AbstractFramedChannel.queueFrame.

      I'm wondering if it would be possible to reduce this contention within undertow. I know I can open multiple channels, but I'd like to avoid that if this problem can be solved in the underlying channel.

      This is particularly impactful because I'm trying to send the frame asynchronously to limit blocking.

      Here is the stacktrace on the frequently blocked threads:

      server-17 [BLOCKED]
      io.undertow.server.protocol.framed.AbstractFramedChannel.queueFrame(AbstractFramedStreamSinkChannel)
      io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.queueFinalFrame()
      io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.shutdownWrites()
      io.undertow.websockets.core.WebSockets.flushChannelAsync(WebSocketChannel, WebSocketCallback, StreamSinkFrameChannel, Object, long)
      io.undertow.websockets.core.WebSockets.sendInternal(ByteBuffer, WebSocketFrameType, WebSocketChannel, WebSocketCallback, long)
      io.undertow.websockets.core.WebSockets.sendBinary(ByteBuffer, WebSocketChannel, WebSocketCallback, long)
      io.undertow.websockets.jsr.WebSocketSessionRemoteEndpoint$AsyncWebSocketSessionRemoteEndpoint.sendObjectImpl(Object, WebSocketCallback)
      io.undertow.websockets.jsr.WebSocketSessionRemoteEndpoint$AsyncWebSocketSessionRemoteEndpoint.sendObject(Object, SendHandler)
      ...snip...
      

      And here is a screenshot of a thread states (via yourkit profiler) showing frequent blocking. All of the red sections are blocked at the above stacktrace.

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              philsttr_jira Phil Clay (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: