14#include <XrdCl/XrdClFile.hh>
15#include <XrdCl/XrdClFileSystem.hh>
16#include <XrdCl/XrdClURL.hh>
17#include <XrdCl/XrdClXRootDResponses.hh>
18#include <condition_variable>
33constexpr size_t kDefaultVectorChunk = 2097136;
34constexpr size_t kDefaultVectorChunks = 1024;
35constexpr size_t kMaxPlainRead = 8 * 1024 * 1024;
42 explicit Completion(
size_t pending) : mPending(pending) {}
46 std::lock_guard lock{mMutex};
47 if (!
error.empty() && mError.empty()) {
48 mError = std::move(
error);
50 if (--mPending == 0) {
59 std::unique_lock lock{mMutex};
60 mDone.wait(lock, [
this] {
return mPending == 0; });
66 std::condition_variable mDone;
72class Reply :
public XrdCl::ResponseHandler
75 Reply(Completion& completion,
size_t expected) : mCompletion(completion), mExpected(
expected) {}
77 void HandleResponse(XrdCl::XRootDStatus* status, XrdCl::AnyObject* response)
override
80 if (!status->IsOK()) {
81 error = status->ToString();
82 }
else if (
auto got =
received(response); got != mExpected) {
87 mCompletion.done(std::move(
error));
92 static size_t received(XrdCl::AnyObject* response)
97 XrdCl::ChunkInfo* chunk =
nullptr;
100 return chunk->length;
102 XrdCl::VectorReadInfo*
vector =
nullptr;
103 response->Get(vector);
107 Completion& mCompletion;
120void queryVectorLimits(XrdCl::File&
file,
size_t& chunkMax,
size_t& chunksMax)
123 if (!
file.GetProperty(
"DataServer", server) || server.empty()) {
126 XrdCl::FileSystem fs{XrdCl::URL{server}};
128 arg.FromString(
"readv_ior_max readv_iov_max");
129 XrdCl::Buffer* response =
nullptr;
130 auto status = fs.Query(XrdCl::QueryCode::Config, arg, response);
131 if (!status.IsOK() || !response) {
135 std::istringstream lines{response->ToString()};
137 std::string ior, iov;
138 if (!std::getline(lines, ior) || !std::getline(lines, iov)) {
143 if (
auto v = std::stoull(ior);
v > 0) {
144 chunkMax = std::min<size_t>(
v, kDefaultVectorChunk);
146 if (
auto v = std::stoull(iov);
v > 0) {
147 chunksMax = std::min<size_t>(
v, kDefaultVectorChunks);
149 }
catch (std::exception
const&) {
155 : mName(
url.substr(0,
url.find(
'?'))),
156 mFile(
std::make_unique<
XrdCl::File>()),
157 mVectorChunkMax(kDefaultVectorChunk),
158 mVectorChunksMax(kDefaultVectorChunks),
159 mInFlightMax(options.remoteInFlightBytes)
161 auto status = mFile->Open(
url, XrdCl::OpenFlags::Read);
162 if (!status.IsOK()) {
163 throw IoError(mName, status.ToString());
165 XrdCl::StatInfo* info =
nullptr;
166 status = mFile->Stat(
false, info);
167 if (!status.IsOK() || !info) {
169 throw IoError(mName,
"stat failed: " + status.ToString());
171 mSize = info->GetSize();
173 queryVectorLimits(*mFile, mVectorChunkMax, mVectorChunksMax);
178 if (mFile->IsOpen()) {
179 [[maybe_unused]]
auto status = mFile->Close();
183void XRootDByteSource::checkRange(
uint64_t off,
size_t len)
const
185 if (off > mSize ||
len > mSize - off) {
201 size_t window = mInFlightMax > 0 ? mInFlightMax : SIZE_MAX;
202 std::vector<Request> out;
205 auto flushVector = [&] {
206 if (!vector.chunks.empty()) {
207 out.push_back(std::move(vector));
211 for (
auto const&
r : requests) {
212 checkRange(
r.offset,
r.length);
217 if (
r.length > mVectorChunkMax) {
218 for (
size_t done = 0;
done <
r.length;
done += kMaxPlainRead) {
219 auto n = std::min(kMaxPlainRead,
r.length -
done);
223 out.push_back(std::move(plain));
227 if (vector.chunks.size() == mVectorChunksMax || (!vector.chunks.empty() && vector.bytes +
r.length > window)) {
230 vector.chunks.emplace_back(
r.offset, (
uint32_t)
r.length,
r.dst);
231 vector.bytes +=
r.length;
241 while (last < out.size() && (last ==
first ||
bytes + out[last].bytes <= window)) {
242 bytes += out[last++].bytes;
244 Completion completion{last -
first};
245 for (
size_t i =
first;
i < last; ++
i) {
246 auto& request = out[
i];
247 auto* reply =
new Reply(completion, request.bytes);
248 XrdCl::XRootDStatus status;
249 if (request.chunks.size() == 1) {
250 auto&
c = request.chunks.front();
251 status = mFile->Read(
c.offset,
c.length,
c.buffer, reply);
253 status = mFile->VectorRead(request.chunks,
nullptr, reply);
255 if (!status.IsOK()) {
257 completion.done(status.ToString());
260 auto error = completion.wait();
261 if (!
error.empty()) {
264 calls += last -
first;
267 mReadCalls.fetch_add(calls, std::memory_order_relaxed);
268 mBytesRead.fetch_add(total, std::memory_order_relaxed);
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font Renderer for event Frontend to use for event ROOT macros used as track filter Console script file
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
char error[CURL_ERROR_SIZE]
~XRootDByteSource() override
std::string url() const override
Without the query, which may hold an access token.
void readvInto(std::span< ReadRequest > requests) override
XRootDByteSource(std::string url, Options const &options)
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.
GLenum GLenum GLsizei len
std::vector< T, fair::mq::pmr::polymorphic_allocator< T > > vector
std::string to_string(gsl::span< T, Size > span)
Failure of the underlying transport.
std::map< std::string, ID > expected