Linux: read ahead of the mapped loads at start
On Linux every load phase read its files one page fault (one 128 KB readahead) at a time, so a cold start spent most of its time waiting on the drive at queue depth ~2. A new platform::advise_willneed asks the kernel for a range in 128 KiB steps (WILLNEED reads at most one readahead window per call), and is called before the weight load, the native dense upload, the profile fill (256 pairs ahead, STRATA_FILL_AHEAD), the peer tier's fill (--peer-device), the resident RAM copy and the MTP draft files. STRATA_READ_AHEAD=0 turns it off. Each phase logs its time. Gen3 NVMe, RTX 5090, 32 GB, Q2_0 resident at 262K: ready in 70 s, was ~920 s.
This commit is contained in:
1 parent
2de94bca5e
commit
cb33c0bac5
10 files changed
+137
-10
No files matched your search
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "strata/core/native_head.hpp"
|
||||
#include "strata/core/peer_experts.hpp"
|
||||
#include "strata/platform/memory.hpp"
|
||||
#include "strata/kernels/bf16_gemv.hpp"
|
||||
#include "strata/kernels/cpu/expert.hpp"
|
||||
#include "strata/kernels/elementwise.hpp"
|
||||
@@ -101,6 +102,9 @@ bool read_file(const std::string& path, std::vector<uint8_t>& out) {
|
||||
if (STRATA_FILE_SEEK64(f, 0, SEEK_END) != 0) return false;
|
||||
const long long n = (long long) STRATA_FILE_TELL64(f);
|
||||
if (n < 0 || STRATA_FILE_SEEK64(f, 0, SEEK_SET) != 0) return false;
|
||||
#if !defined(_WIN32)
|
||||
strata::platform::advise_willneed(fileno(f), 0, (uint64_t) n);
|
||||
#endif
|
||||
out.resize((size_t) n);
|
||||
return n == 0 || std::fread(out.data(), 1, (size_t) n, f) == (size_t) n;
|
||||
}
|
||||
@@ -212,6 +216,9 @@ bool MtpDrafter::load(const std::string& rt_dir, const ModelGeometry& g, Session
|
||||
~Closer() { if (f != nullptr) std::fclose(f); }
|
||||
} closer{f};
|
||||
if (cudaMalloc((void**) &experts_, bytes) != cudaSuccess) { err = "mtp: the 512 experts do not fit in VRAM"; return false; }
|
||||
#if !defined(_WIN32)
|
||||
strata::platform::advise_willneed(fileno(f), 0, bytes);
|
||||
#endif
|
||||
std::vector<uint8_t> chunk(64u << 20);
|
||||
for (uint64_t off = 0; off < bytes;) {
|
||||
const uint64_t n = std::min<uint64_t>(chunk.size(), bytes - off);
|
||||
|
||||
Reference in new issue
Block a user