Verified Commit d0eb08b0 authored by Marc Vef's avatar Marc Vef
Browse files

Working MSGPack version. Flush at destroy

parent 4e7d301c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -133,6 +133,9 @@ public:
    void
    init_logging();

    void
    init_metrics();

    void
    mountdir(const std::string& path);

+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ namespace gkfs::env {
std::string
get_var(const std::string& name, const std::string& default_value = "");

bool
var_is_set(const std::string& name);

} // namespace gkfs::env

#endif // GKFS_COMMON_ENV_UTIL_HPP
+22 −7
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@
#include <chrono>
#include <csignal>
#include <thread>

#include <mutex>

namespace gkfs::messagepack {

@@ -44,6 +44,7 @@ enum class client_metric_type { write, read };
class ClientMetrics {

public:
    std::mutex mtx_{};
    //    std::thread thread_{};

    std::chrono::time_point<std::chrono::system_clock> init_t_;
@@ -59,25 +60,39 @@ public:
    uint64_t total_bytes_{};
    int total_iops_{0};

    bool is_enabled_{false};
    std::string path_{};

    // public:
    ClientMetrics();

    ~ClientMetrics() = default;

    template <class T>
    void
    pack(T& pack) {
        pack(init_t_, hostname_, pid_, start_t_, end_t_, avg_, total_iops_,
             total_bytes_);
    }

    void
    add_event(size_t size,
              std::chrono::time_point<std::chrono::system_clock> start);

    void
    flush_msgpack(std::string path);
    flush_msgpack();

    template <class T>
    void
    pack(T& pack) {
        pack(init_t_, hostname_, pid_, start_t_, end_t_, avg_, total_iops_,
             total_bytes_);
    }
    enable();

    void
    disable();

    [[nodiscard]] const std::string&
    path() const;

    void
    path(const std::string& path, const std::string& prefix = "");
};

} // namespace gkfs::messagepack
+5 −0
Original line number Diff line number Diff line
@@ -41,7 +41,12 @@ namespace gkfs::config {
constexpr auto hostfile_path = "./gkfs_hosts.txt";
// We do not default this, ENV variable always required.
constexpr auto forwarding_file_path = "";

namespace metrics {
// Default directory where client metrics are stored. Can be set via
// LIBGKFS_METRICS_PATH. Filename consists of starting time, pid, and hostname
constexpr auto client_metrics_path = "/tmp/gkfs_client_metrics";
} // namespace metrics

namespace io {
/*
+3 −2
Original line number Diff line number Diff line
@@ -959,8 +959,9 @@ gkfs_write_ws(gkfs::filemap::OpenFile& file, const char* buf, size_t count, off6
    auto written = gkfs_do_write(file, buf, count, offset, update_pos);
    CTX->write_metrics().add_event(written, start_t);
    return written;
#endif
#else
    return gkfs_do_write(file, buf, count, offset, update_pos);
#endif
}

/**
@@ -1122,7 +1123,7 @@ gkfs_read_ws(const gkfs::filemap::OpenFile& file, char* buf, size_t count, off64
    auto start_t = std::chrono::high_resolution_clock::now();
    auto read = gkfs_do_read(file, buf, count, offset);
    CTX->read_metrics().add_event(read, start_t);
    return written;
    return read;
#else
    return gkfs_do_read(file, buf, count, offset);
#endif
Loading