Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-809 Copyless stack
  3. JGRP-816

TP: avoid copying when receiving data

    XMLWordPrintable

Details

    • Sub-task
    • Resolution: Duplicate
    • Major
    • 4.0
    • None
    • None

    Description

      Currently, we receive data into a byte[] buffer, e.g. from DatagramSocket.receive(), but then have to COPY buffer when passing it to a worker from the thread pool. The copy is needed because the next DatargamSocket.receive() will overwrite the contents of buffer, and if the worker thread is still unmarshalling the data from the buffer, it might read corrupt contents.

      To overcome this, investigate the following:

      • Every worker thread has it own buffer
      • When the thread has been idle for N seconds and is removed from the pool, that buffer will be discarded
      • We create DatagramChannels from the socket(s) (DatagramSocket, MulticastSocket or Socket)
      • A selector is called when new data is available on the socket
      • The key returned by the selector points to the right channel
      • We pass the channel to a thread pool worker thread and continue with the select() loop
      • The worker then reads the data into its own buffer, unmarshalls it and passed it up the stack

      ==> No copy of the buffer is required as the thread's buffer is available until the message has been processed (usually until message unmarshalling)

      Attachments

        Issue Links

          Activity

            People

              rhn-engineering-bban Bela Ban
              rhn-engineering-bban Bela Ban
              Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: