grizzly
  1. grizzly
  2. GRIZZLY-999

Faban benchmark is not using keep alive when benchmarking character echos with the ByteBufferManager

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.1
    • Component/s: http
    • Labels:
      None

      Description

      Alexey found that faban would throw address in use exceptions when trying running the character version of the http-echo benchmark.

      It turned out that I left some code for testing a fix in the EchoServer that put the ByteBufferManager in use instead of the default HeapBufferManager.

      When testing locally, I noticed via netstat, that there were a lot of TIME_WAIT states on the client side. This would happen if the client was closing the connection after each request. This didn't seem right since fhb is supposed to be using keep alive.

      Using wireshark, I was able to see that fhb was indeed closing the connection after each request.

      Switching to binary mode however, showed the the connection was being reused.

      Looking at the posted data for character mode, there was an extra 4 bytes being sent with the payload even though the content length was 4. This doesn't happen with binary.

      Turns out the problem is due to OutputBuffer.updateBufferPosition() (which, incidentally, is only called by character processing).

      This method was written while using the HeapMemoryManager. The ByteBuffer exposed by the HeapMemoryManager, when passed to the character encoder will not update the position of the originating buffer. Where as the ByteBuffer implementation, any changes made to the ByteBuffer's position will be reflected by the Buffer implementation as that Buffer is simply a wrapper.

      Updating updateBufferPostition() from:

      private static void updateBufferPosition(final Buffer buffer,
      final ByteBuffer byteBuffer, final int oldByteBufferPos)

      { final int newPos = byteBuffer.position(); buffer.position(buffer.position() + newPos - oldByteBufferPos); }

      to:

      private static void updateBufferPosition(final Buffer buffer,
      final ByteBuffer byteBuffer, final int oldByteBufferPos) {
      final int newPos = byteBuffer.position();
      if (newPos == buffer.position())

      { return; }

      buffer.position(buffer.position() + newPos - oldByteBufferPos);
      }

      Resolves the issue and fhb is able to properly bm character interactions with the ByteBufferManager.

        Activity

        Hide
        Ryan Lubke added a comment -

        Project: grizzly
        Repository: hg
        Revision: 1697
        Author: rlubke
        Date: 2011-04-14 21:05:28 UTC

        Show
        Ryan Lubke added a comment - Project: grizzly Repository: hg Revision: 1697 Author: rlubke Date: 2011-04-14 21:05:28 UTC

          People

          • Assignee:
            Ryan Lubke
            Reporter:
            Ryan Lubke
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: