23 std::lock_guard lock{mMutex};
24 auto best = mFree.end();
25 for (
auto it = mFree.begin(); it != mFree.end(); ++it) {
26 if (it->capacity >=
size && (best == mFree.end() || it->capacity < best->capacity)) {
30 if (best != mFree.end()) {
31 auto buffer = std::move(*best);
39 auto capacity = std::max<size_t>(
size +
size / 8, 1);
40 void* p = mmap(
nullptr, capacity, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
41 if (p == MAP_FAILED) {
42 throw std::bad_alloc();
44 return {std::unique_ptr<uint8_t[], Unmap>((
uint8_t*)p,
Unmap{capacity}), capacity};
54 std::lock_guard lock{mMutex};
55 mFree.push_back(std::move(
buffer));
56 if (mMaxFreeBytes == 0 && mFree.size() > kMaxFree) {
59 auto freeBytes = [
this] {
61 for (
auto const&
b : mFree) {
68 while (mMaxFreeBytes > 0 && !mFree.empty() && freeBytes() > mMaxFreeBytes + mMaxFreeBytes / 8) {
80 for (
auto&
buffer : mBuffers) {
81 mPool->put(std::move(
buffer));
91 std::lock_guard lock{mMutex};
97 for (
auto const& branch :
tree.branches) {
98 for (
auto const& basket : branch.baskets) {
99 if (!basket.embedded) {
100 add(basket.seek, basket.nbytes);
109 for (
auto const& branch :
tree.branches) {
110 for (
auto const& basket : branch.baskets) {
111 if (!basket.embedded) {
112 total += basket.nbytes;
121 auto it = std::upper_bound(mChunks.begin(), mChunks.end(),
offset, [](
uint64_t off, Chunk
const&
c) { return off < c.offset; });
122 if (it == mChunks.begin()) {
132void ReadPlan::fetchPending()
134 std::ranges::sort(mPending);
135 std::vector<Chunk> fetched;
141 if (!fetched.empty()) {
142 auto&
last = fetched.back();
143 auto lastEnd =
last.offset +
last.size;
144 auto next = std::lower_bound(mChunks.begin(), mChunks.end(), lastEnd, [](Chunk
const&
c,
uint64_t off) { return c.offset < off; });
145 bool bridgesFetched = next != mChunks.end() && next->offset <
offset;
146 if (
offset <= lastEnd + mCoalesceGap && !bridgesFetched) {
156 if (fetched.empty()) {
162 for (
auto& chunk : fetched) {
165 auto buffer = mPool->get(total);
166 std::vector<ReadRequest> requests;
167 auto* at =
buffer.data.get();
168 for (
auto& chunk : fetched) {
171 requests.push_back({chunk.offset, chunk.size, chunk.data});
173 mBuffers.push_back(std::move(
buffer));
174 mSource->readvInto(requests);
175 mChunks.insert(mChunks.end(), fetched.begin(), fetched.end());
176 std::ranges::sort(mChunks, {}, &Chunk::offset);
181 std::lock_guard lock{mMutex};
183 if (
bytes.empty() && !mPending.empty()) {
192 std::lock_guard lock{mMutex};
193 if (!mPending.empty()) {
200 std::lock_guard lock{mMutex};
202 for (
auto const& chunk : mChunks) {
215 auto bytes = mSource->tryMap(off,
len);
223 mSource->readInto(off,
len,
dst);
231 mSource->readvInto(requests);
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
void readInto(uint64_t off, size_t len, void *dst) override
Throws IoError, or CorruptData when the range is past the end of the file.
void readvInto(std::span< ReadRequest > requests) override
PlannedByteSource(std::shared_ptr< ByteSource > source, std::shared_ptr< ReadPlan > plan)
std::span< const uint8_t > tryMap(uint64_t off, size_t len) override
A view of the bytes without copying them, if the backend can provide it.
Buffer get(size_t size)
The smallest free buffer of at least size bytes, or a new one.
void fetch()
Fetches the pending ranges now, rather than on the first find().
static uint64_t bytesOf(TreeInfo const &tree)
The bytes add(tree) registers.
std::span< const uint8_t > find(uint64_t offset, size_t length)
ReadPlan(std::shared_ptr< ByteSource > source, Options const &options, std::shared_ptr< ReadBufferPool > pool=nullptr)
Without a pool, the plan allocates its own buffers.
void add(uint64_t offset, size_t length)
GLboolean GLboolean GLboolean b
GLsizei GLsizei GLchar * source
GLuint GLsizei GLsizei * length
GLenum GLenum GLsizei len
void operator()(uint8_t *p) const
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))