11 #include <string_view>
12 #include <type_traits>
14 #include <kvikio/shim/utils.hpp>
16 namespace KVIKIO_EXPORT
kvikio {
21 using Clock = std::chrono::steady_clock;
43 std::chrono::system_clock::time_point wall{};
66 [[nodiscard]] std::chrono::system_clock::time_point to_wall_clock(
TimePoint time) const noexcept
71 static_assert(std::is_integral_v<TimePoint::rep>);
72 static_assert(std::is_integral_v<std::chrono::system_clock::rep>);
73 return wall + std::chrono::duration_cast<std::chrono::system_clock::duration>(time - steady);
91 constexpr std::size_t
num_io_backends =
static_cast<std::size_t
>(IoBackend::REMOTE_HDFS) + 1;
159 std::size_t offset{};
164 std::size_t bytes_transferred{};
169 char const* http_method{
nullptr};
173 std::string_view source{};
193 return end > start ? end - start : Duration::zero();
206 auto const seconds = std::chrono::duration<double>{duration()}.count();
207 return seconds > 0.0 ?
static_cast<double>(bytes_transferred) / seconds : 0.0;
Watches operations, from the moment they start until they finish.
virtual void on_finish(Observation const &observation) noexcept=0
An operation has completed.
virtual void on_start(Observation const &observation) noexcept=0
An operation has started.
ObservationKind
What layer an observation describes.
@ LOGICAL
One user-facing call, such as one FileHandle::pread().
std::chrono::nanoseconds Duration
A length of time, in nanoseconds.
std::chrono::steady_clock Clock
The clock KvikIO timestamps observations with.
IoBackend
The I/O backend that carried out an operation.
@ POSIX
POSIX pread/pwrite, including the compatibility-mode path.
@ MMAP
Memory-mapped file access.
@ REMOTE_HTTP
Remote I/O over HTTP(S), including S3.
@ GDS
cuFile / GPUDirect Storage.
@ REMOTE_HDFS
Remote I/O over WebHDFS.
std::string_view to_string(IoBackend backend) noexcept
Human-readable name of an I/O backend.
constexpr std::size_t num_io_backends
Number of IoBackend values.
TransferDirection
The direction of an I/O operation.
MemoryKind
The kind of memory the caller's buffer lives in.
@ DEVICE
Device (GPU) memory.
void unregister_monitor(std::uint64_t id)
Unregister a monitor.
Clock::time_point TimePoint
A point in time on Clock.
std::uint64_t register_monitor(Monitor *monitor, ObservationKind kind=ObservationKind::LOGICAL)
Register a monitor, which begins receiving both notifications.
A reading of Clock and of the wall clock, taken together.
static ClockAnchor now() noexcept
Read both clocks, one immediately after the other.
One I/O operation, as observed by KvikIO.
double bytes_per_sec() const noexcept
Throughput of this single operation.
Duration duration() const noexcept
How long the operation took.