Skip to content

Commit

Permalink
istream/file: reorderd to improve struct packing
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Jan 20, 2025
1 parent 5fb3513 commit e83d508
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions src/istream/FileIstream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@
static constexpr Event::Duration file_retry_timeout = std::chrono::milliseconds(100);

class FileIstream final : public Istream {
UniqueFileDescriptor fd;

/**
* A timer to retry reading after EAGAIN.
*/
FineTimerEvent retry_event;

SliceFifoBuffer buffer;
const char *path;

off_t offset;

const off_t end_offset;

SliceFifoBuffer buffer;
const char *path;
UniqueFileDescriptor fd;

bool direct = false;

Expand All @@ -53,10 +53,10 @@ class FileIstream final : public Istream {
off_t _start_offset, off_t _end_offset,
const char *_path) noexcept
:Istream(p),
fd(std::move(_fd)),
retry_event(event_loop, BIND_THIS_METHOD(EventCallback)),
path(_path),
offset(_start_offset), end_offset(_end_offset),
path(_path) {}
fd(std::move(_fd)) {}

private:
void EofDetected() noexcept {
Expand Down
20 changes: 10 additions & 10 deletions src/istream/UringIstream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class CanceledUringIstream final : public Uring::Operation {
class UringIstream final : public Istream, Uring::Operation {
Uring::Queue ů

UniqueFileDescriptor fd;

/**
* Passed to the io_uring read operation.
*
Expand All @@ -54,6 +52,13 @@ class UringIstream final : public Istream, Uring::Operation {
*/
std::unique_ptr<struct iovec> iov = std::make_unique<struct iovec>();

SliceFifoBuffer buffer;

/**
* The path name. Only used for error messages.
*/
const char *const path;

/**
* The file offset of the next/pending read operation. If
* there is data in the #buffer, it precedes this offset.
Expand All @@ -66,12 +71,7 @@ class UringIstream final : public Istream, Uring::Operation {
*/
const off_t end_offset;

SliceFifoBuffer buffer;

/**
* The path name. Only used for error messages.
*/
const char *const path;
UniqueFileDescriptor fd;

bool direct = false;

Expand All @@ -80,9 +80,9 @@ class UringIstream final : public Istream, Uring::Operation {
const char *_path, UniqueFileDescriptor &&_fd,
off_t _start_offset, off_t _end_offset) noexcept
:Istream(p), uring(_uring),
fd(std::move(_fd)),
path(_path),
offset(_start_offset), end_offset(_end_offset),
path(_path)
fd(std::move(_fd))
{
}

Expand Down
14 changes: 7 additions & 7 deletions src/istream/UringSpliceIstream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class UringSpliceIstream final : public Istream, Uring::Operation {
*/
const char *const path;

/**
* The actual file.
*/
UniqueFileDescriptor fd;

PipeLease pipe;

/**
Expand All @@ -61,6 +56,11 @@ class UringSpliceIstream final : public Istream, Uring::Operation {
*/
const off_t end_offset;

/**
* The actual file.
*/
UniqueFileDescriptor fd;

#ifndef NDEBUG
bool direct = false;
#endif
Expand All @@ -73,9 +73,9 @@ class UringSpliceIstream final : public Istream, Uring::Operation {
:Istream(p), uring(_uring),
defer_start(event_loop, BIND_THIS_METHOD(OnDeferredStart)),
path(_path),
fd(std::move(_fd)),
pipe(_pipe_stock),
offset(_start_offset), end_offset(_end_offset)
offset(_start_offset), end_offset(_end_offset),
fd(std::move(_fd))
{
}

Expand Down

0 comments on commit e83d508

Please sign in to comment.