#include <ReadRepacker.h>
Public Member Functions | |
IOSize | bufferUsed () const |
IOSize | extraBytes () const |
std::vector< IOPosBuffer > & | iov () |
int | pack (long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size) |
IOSize | realBytesProcessed () const |
void | unpack (char *buf) |
Static Public Attributes | |
static const IOSize | BIG_READ_SIZE = 256 * 1024 |
static const IOSize | READ_COALESCE_SIZE = 32 * 1024 |
static const IOSize | TEMPORARY_BUFFER_SIZE = 256 * 1024 |
Private Member Functions | |
int | packInternal (long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size) |
void | reset (unsigned int nbuf) |
Private Attributes | |
IOSize | m_buffer_used |
IOSize | m_extra_bytes |
std::vector< int > | m_idx_to_iopb |
std::vector< int > | m_idx_to_iopb_offset |
std::vector< IOPosBuffer > | m_iov |
edm::propagate_const< int * > | m_len |
std::vector< char > | m_spare_buffer |
Repack a set of read requests from the ROOT layer to be optimized for the storage layer.
The basic technique employed is to coalesce nearby, but not adjacent reads into one larger read in the request to the storage system. We will be purposely over-reading from storage.
The read-coalescing is done because the vector reads are typically unrolled server-side in a "dumb" fashion, with OS read-ahead disabled. The coalescing actually decreases the number of requests sent to disk; important, as ROOT I/O is typically latency bound.
The complexity here is in the fact that we must have buffer space to hold the extra bytes from the storage system, even through they're going to be discarded.
The approach is to reuse the ROOT buffer as temporary holding space, plus a small, fixed-size "spare buffer". So, in the worst-case, we will use about 256KB of extra buffer space. The read-coalesce algorithm is greedy, so we can't provide an a-priori estimate on how many extra I/O transactions will be sent to the storage (compared to vector-reads with no coalescing). Tests currently indicate that this approach usually causes zero to one additional I/O transaction to occur.
Definition at line 33 of file ReadRepacker.h.
|
inline |
Definition at line 47 of file ReadRepacker.h.
References m_buffer_used.
Referenced by TStorageFactoryFile::ReadBuffersSync().
|
inline |
|
inline |
Definition at line 45 of file ReadRepacker.h.
References m_iov.
Referenced by TStorageFactoryFile::ReadBuffersSync().
int ReadRepacker::pack | ( | long long int * | pos, |
int * | len, | ||
int | nbuf, | ||
char * | buf, | ||
IOSize | buffer_size | ||
) |
Given a list of offsets and positions, pack them into a vector of IOPosBuffer (an "IO Vector"). This function will coalesce reads that are within READ_COALESCE_SIZE into a IOPosBuffer. This function will not create an IO vector whose summed buffer size is larger than TEMPORARY_BUFFER_SIZE. The IOPosBuffer in iov all point to a location inside buf.
pos | An array of file offsets, nbuf long. |
len | An array of offset length, nbuf long. |
nbuf | Number of buffers to pack. |
buf | Location of temporary buffer for the results of the storage request. |
buffer_size | Size of the temporary buffer. |
Returns the number of entries of the original array packed into iov.
Definition at line 21 of file ReadRepacker.cc.
References m_len, m_spare_buffer, packInternal(), reset(), and TEMPORARY_BUFFER_SIZE.
Referenced by TStorageFactoryFile::ReadBuffersSync().
|
private |
Definition at line 58 of file ReadRepacker.cc.
References BIG_READ_SIZE, training_settings::idx, m_buffer_used, m_extra_bytes, m_idx_to_iopb, m_idx_to_iopb_offset, m_iov, IOPosBuffer::offset(), READ_COALESCE_SIZE, IOPosBuffer::set_data(), IOPosBuffer::set_offset(), IOPosBuffer::set_size(), and IOPosBuffer::size().
Referenced by pack().
|
inline |
Definition at line 52 of file ReadRepacker.h.
References m_buffer_used, and m_extra_bytes.
Referenced by TStorageFactoryFile::ReadBuffersSync().
|
private |
Definition at line 141 of file ReadRepacker.cc.
References m_buffer_used, m_extra_bytes, m_idx_to_iopb, m_idx_to_iopb_offset, and m_iov.
Referenced by pack().
void ReadRepacker::unpack | ( | char * | buf | ) |
Unpack the optimized set of reads from the storage system and copy the results in the order ROOT requested.
Definition at line 125 of file ReadRepacker.cc.
References IOPosBuffer::data(), training_settings::idx, m_idx_to_iopb, m_idx_to_iopb_offset, m_iov, and m_len.
Referenced by TStorageFactoryFile::ReadBuffersSync().
|
static |
Definition at line 64 of file ReadRepacker.h.
Referenced by packInternal().
|
private |
Definition at line 81 of file ReadRepacker.h.
Referenced by bufferUsed(), packInternal(), realBytesProcessed(), and reset().
|
private |
Definition at line 82 of file ReadRepacker.h.
Referenced by extraBytes(), packInternal(), realBytesProcessed(), and reset().
|
private |
Definition at line 76 of file ReadRepacker.h.
Referenced by packInternal(), reset(), and unpack().
|
private |
Definition at line 78 of file ReadRepacker.h.
Referenced by packInternal(), reset(), and unpack().
|
private |
Definition at line 79 of file ReadRepacker.h.
Referenced by iov(), packInternal(), reset(), and unpack().
|
private |
Definition at line 80 of file ReadRepacker.h.
|
private |
Definition at line 83 of file ReadRepacker.h.
Referenced by pack().
|
static |
Definition at line 61 of file ReadRepacker.h.
Referenced by packInternal().
|
static |
Definition at line 58 of file ReadRepacker.h.
Referenced by pack().