Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2154

FRAG3: create full message up front

    Details

    • Type: Feature Request
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 4.0
    • Labels:

      Description

      In FRAG2, a full message to be passed up the stack is created when all fragments have been received. Say we send a 30K message and frag_size is 8000 bytes. On the sender side, FRAG2 will create the following fragments: 1:8000 2:8000 3:8000 4:6000.

      When fragment 1 is received, it is added to a fragment list. When all 4 fragments have been received, a full message of 30K is created and the 4 fragments' buffers are copied into the full message's buffer.

      FRAG2's memory allocation is therefore:

      • T1: 8000 // fragment 1 has been received
      • T2: 16000 // fragment 2 has been received
      • T3: 24000 // fragment 3 has been received
      • T4: 30000 // fragment 4 has been received
      • T4: 30000 + 30000 // full message is created and all 4 fragments are still in the list
      • T4: 30000 // full message is being delivered up the stack, and fragments have been removed
      • T5: 0 // full message has been delivered and can be garbage collected

      In FRAG3, the full message of 30K is created on reception of the first fragment. Fragments are not stored in a fragment list, but directly copied into the full message as soon as they have been received. Each fragment carries its offset and length, and the size of the full message, so the full message can be created on reception of the first fragment.

      The advantage is that the fragment list does not need to be maintained and fragments can be discarded as soon as they've been copied into the full message.

      Also, instead of allocating 60K of memory, only 30K are allocated.

      The disadvantage is that the full message is created up front, and remains in memory until the last segment has been received and the message has been delivered to the application.

      FRAG3's memory allocation looks as follows:

      • T1: 30000 // the full message is created on reception of fragment 1, frag is copied into the full message
      • T2: 30000 // fragment 2 has been received, copied into the full message and discarded
      • T3: 30000 // fragment 3 has been received, copied into the full message and discarded
      • T4: 30000 // fragment 4 has been received, copied into the full message and discarded
      • T4: 30000 // full message is being delivered up the stack, and fragments have been removed
      • T5: 0 // full message has been delivered and can be garbage collected

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                belaban Bela Ban
                Reporter:
                belaban Bela Ban
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: