CMS 3D CMS Logo

ReadRepacker.h
Go to the documentation of this file.
1 
28 #include <vector>
29 
32 
33 class ReadRepacker {
34 public:
35  // Returns the number of input buffers it was able to pack into the IO operation.
36  int pack(long long int *pos, // An array of file offsets to read.
37  int *len, // An array of lengths to read.
38  int nbuf, // Size of the pos and len array.
39  char *buf, // Temporary buffer to hold I/O result.
40  IOSize buffer_size); // Size of the temporary buffer.
41 
42  void unpack(
43  char *buf); // Buffer to unpack the I/O results into. Not the temporayr buffer and result buffer may overlap.
44 
45  std::vector<IOPosBuffer> &iov() { return m_iov; } // Returns the IO vector, optimized for storage.
46 
47  IOSize bufferUsed() const { return m_buffer_used; } // Returns the total amount of space in the temp buffer used.
48  IOSize extraBytes() const {
49  return m_extra_bytes;
50  } // Returns the number of extra bytes to be issued to the I/O system
51  // Note that (buffer_used - extra_bytes) should equal the number of "real" bytes serviced.
54  } // Return the number of bytes of the input request that would be processed by the IO vector
55 
56  // Two reads distanced by less than READ_COALESCE_SIZE will turn into one
57  // large read.
58  static const IOSize TEMPORARY_BUFFER_SIZE = 256 * 1024;
59 
60  // A read larger than BIG_READ_SIZE will not be coalesced.
61  static const IOSize READ_COALESCE_SIZE = 32 * 1024;
62 
63  // The size of the temporary holding buffer for read-coalescing.
64  static const IOSize BIG_READ_SIZE = 256 * 1024;
65 
66 private:
67  int packInternal(long long int *pos,
68  int *len,
69  int nbuf,
70  char *buf,
71  IOSize buffer_size); // Heart of the implementation of Pack; because we pack up to 2 buffers,
72  // its easier to break the method into two.
73 
74  void reset(unsigned int nbuf); // Reset all the internal counters and arrays. Resize arrays to be about nbuf long.
75 
76  std::vector<int> m_idx_to_iopb; // Mapping from idx in the input array to the iopb in the IO vector
77  std::vector<int>
78  m_idx_to_iopb_offset; // Mapping from idx in the input array to the data offset in the results of the iopb.
79  std::vector<IOPosBuffer> m_iov; // Vector of IO for the storage system to perform.
80  edm::propagate_const<int *> m_len; // Pointed to the array of read sizes.
81  IOSize m_buffer_used; // Bytes in the temporary buffer used.
82  IOSize m_extra_bytes; // Number of bytes read from storage that will be discarded.
83  std::vector<char> m_spare_buffer; // The spare buffer; allocated if we cannot fit the I/O results into the ROOT buffer.
84 };
ReadRepacker::packInternal
int packInternal(long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size)
Definition: ReadRepacker.cc:58
propagate_const.h
pos
Definition: PixelAliasList.h:18
ReadRepacker::m_spare_buffer
std::vector< char > m_spare_buffer
Definition: ReadRepacker.h:83
edm::propagate_const< int * >
ReadRepacker::m_iov
std::vector< IOPosBuffer > m_iov
Definition: ReadRepacker.h:79
ReadRepacker::pack
int pack(long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size)
Definition: ReadRepacker.cc:21
ReadRepacker::extraBytes
IOSize extraBytes() const
Definition: ReadRepacker.h:48
ReadRepacker::m_extra_bytes
IOSize m_extra_bytes
Definition: ReadRepacker.h:82
ReadRepacker::reset
void reset(unsigned int nbuf)
Definition: ReadRepacker.cc:141
ReadRepacker::TEMPORARY_BUFFER_SIZE
static const IOSize TEMPORARY_BUFFER_SIZE
Definition: ReadRepacker.h:58
ReadRepacker::BIG_READ_SIZE
static const IOSize BIG_READ_SIZE
Definition: ReadRepacker.h:64
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
ReadRepacker::m_len
edm::propagate_const< int * > m_len
Definition: ReadRepacker.h:80
ReadRepacker::READ_COALESCE_SIZE
static const IOSize READ_COALESCE_SIZE
Definition: ReadRepacker.h:61
ReadRepacker::m_buffer_used
IOSize m_buffer_used
Definition: ReadRepacker.h:81
ReadRepacker::m_idx_to_iopb
std::vector< int > m_idx_to_iopb
Definition: ReadRepacker.h:76
ReadRepacker::unpack
void unpack(char *buf)
Definition: ReadRepacker.cc:125
IOPosBuffer.h
ReadRepacker
Definition: ReadRepacker.h:33
ReadRepacker::m_idx_to_iopb_offset
std::vector< int > m_idx_to_iopb_offset
Definition: ReadRepacker.h:78
ReadRepacker::iov
std::vector< IOPosBuffer > & iov()
Definition: ReadRepacker.h:45
IOSize
size_t IOSize
Definition: IOTypes.h:14
ReadRepacker::bufferUsed
IOSize bufferUsed() const
Definition: ReadRepacker.h:47
ReadRepacker::realBytesProcessed
IOSize realBytesProcessed() const
Definition: ReadRepacker.h:52