loader: read the expert arena in bulk instead of std::ifstream
On MSVC, std::ifstream::read does not issue one fread per call: basic_filebuf::xsgetn loops over fread(_Ptr, 1, 4095, _Myfile) (__msvc_filebuf.hpp, _Read_size = 4095). A 44.7 GB expert arena therefore costs ~11.4 million 4095-byte reads instead of a few thousand bulk reads, and the load is dominated by per-call overhead. Read the arena with fopen/fread, an explicit 64-bit seek (_fseeki64) and a short-read check that fails the load (LoadStats.ok/error) instead of silently returning partial data. Behaviour on Linux/glibc is unchanged in substance: same bytes, same call sites.
This commit is contained in:
1 parent
bcd62942f1
commit
edeb92848c
5 files changed
+100
-10
No files matched your search
@@ -65,7 +65,10 @@ int main(int argc, char** argv) {
|
||||
|
||||
const strata::core::LoadStats st =
|
||||
strata::core::load_experts(path, dst, blob_bytes, blobs_per_layer, layers, threads, chunk);
|
||||
if (st.seconds < 0) return 1;
|
||||
if (!st.ok) {
|
||||
std::fprintf(stderr, "loading the experts failed: %s\n", st.error.empty() ? "unknown" : st.error.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::printf("loaded %.3f GiB in %.3f s with %d threads and %llu MiB chunks -> %.2f GiB/s\n",
|
||||
(double) st.bytes / (1024.0 * 1024 * 1024), st.seconds, threads,
|
||||
|
||||
Reference in new issue
Block a user