CMS 3D CMS Logo

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