You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is needed to allow logarithmic buffer indexing time as opposed to linear that is available currently. LibUDPard traverses the fragment tree once, during the transfer finalization, to build the linked list of fragments:
// This is the single-frame transfer optimization suggested by Scott: we free the first fragment handle
// early by moving the contents into the rx_transfer structure by value.
// No need to free the payload buffer because it has been transferred to the transfer.
memFree(memory.fragment, sizeof(RxFragment), eject_ctx.head); // May be empty.
}
else// The transfer turned out to be invalid. We have to free the fragments. Can't use the tree anymore.
{
rxFragmentDestroyList(eject_ctx.head, memory);
}
returnresult;
}
In the process it discards the fragment metadata; the discarded metadata includes the fragment tree linking where the fragments are ordered by the frame index (from zero up to the transfer fragment count):
/// This is designed to be convertible to/from UdpardFragment, so that the application could be
/// given a linked list of these objects represented as a list of UdpardFragment.
typedefstructRxFragment
{
structUdpardFragmentbase;
RxFragmentTreeNodetree;
uint32_tframe_index;
} RxFragment;
The discardment is done by slicing off the metadata fields. We could enhance the publicly visible struct UdpardFragment with the tree-related fields to allow the user to choose whether the fragments should be indexed linearly as a linked list or logarithmically through the tree. Now, in order to implement the latter the tree should be indexed by offset rather than the frame index (the client doesn't care about the frame index, it's a very low-level trait); however, a tree ordered by frame index is obviously identical to a tree ordered by the offset (formal proof anyone?). LibUDPard will only need to initialize the offset fields while building the linked list -- it is also done in the same single pass.
New offset_bytes param will be used to find (in the exposed tree as described above by @pavel-kirienko) proper start fragment which contains first required byte of data.
New optional (could be null) hint param could be used as a "hint" for subsequent accesses. If not null then on return it will be filled with address of the last fragment node (according to offset_bytes + destination_size_bytes position) encountered. This will allow to make subsequent/continuous forward only accesses faster b/c there will be no need to find starting fragment on a next udpardGather call. We will fallback to normal (O(log(N)) tree search if hint is not provided or out of sync with offset_bytes.
Extend struct UdpardFragment with extra fields so that in addition to current linear list there will be also the tree node exposed.
Currently existing more simple udpardGather will stay as is: always starting from zero offset, and using single linked list of nodes to progress from the head up to destination_size_bytes copied).
This is needed to allow logarithmic buffer indexing time as opposed to linear that is available currently. LibUDPard traverses the fragment tree once, during the transfer finalization, to build the linked list of fragments:
libudpard/libudpard/udpard.c
Lines 1044 to 1097 in 6c7c12e
In the process it discards the fragment metadata; the discarded metadata includes the fragment tree linking where the fragments are ordered by the frame index (from zero up to the transfer fragment count):
libudpard/libudpard/udpard.c
Lines 808 to 815 in 6c7c12e
The discardment is done by slicing off the metadata fields. We could enhance the publicly visible
struct UdpardFragment
with the tree-related fields to allow the user to choose whether the fragments should be indexed linearly as a linked list or logarithmically through the tree. Now, in order to implement the latter the tree should be indexed by offset rather than the frame index (the client doesn't care about the frame index, it's a very low-level trait); however, a tree ordered by frame index is obviously identical to a tree ordered by the offset (formal proof anyone?). LibUDPard will only need to initialize the offset fields while building the linked list -- it is also done in the same single pass.@serges147 FYI
The text was updated successfully, but these errors were encountered: