MCPcopy Create free account
hub / github.com/Niko1221/Strata / recheck_unbuffered

Method recheck_unbuffered

engine/src/core/expert_source.cpp:2886–2927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2884}
2885
2886bool FileExpertSource::recheck_unbuffered(std::string& why) {
2887#if defined(_WIN32) || defined(__linux__)
2888 if (const char* env = std::getenv("STRATA_UNBUFFERED_LOAD"); env != nullptr && env[0] != '\0') {
2889 why = std::string("STRATA_UNBUFFERED_LOAD=") + env;
2890 return !direct_.empty();
2891 }
2892 if (base_ == nullptr || paths_.empty()) {
2893 why = "no expert files open";
2894 return false;
2895 }
2896 // #577: the RAM copy is built (and already out of the available RAM), so what the file cache would have to keep
2897 // is exactly the experts outside it - the GPU cache's (refilled after a prompt borrowed their slots) and the
2898 // ones neither holds
2899 const uint64_t experts = expert_bytes();
2900 const uint64_t read = experts > complement_bytes_ ? experts - complement_bytes_ : 0;
2901 std::string w;
2902 const bool ub = file_tier_unbuffered(paths_, 0, read, w);
2903 char head[96];
2904 std::snprintf(head, sizeof head, "re-checked with the RAM copy built (%.2f GiB): ",
2905 (double) complement_bytes_ / 1073741824.0);
2906 why = head + w;
2907 if (ub == !direct_.empty()) return ub;
2908 if (ub) return open_direct(why);
2909#if defined(_WIN32)
2910 // If drop_mapping_verified closed the view early so startup fills ran at unmapped NVMe speed, remap before closing direct_.
2911 if (unmapped_) {
2912 std::string remap_why;
2913 if (!map_view(remap_why)) {
2914 why += " (stays unbuffered: " + remap_why + ")";
2915 return true;
2916 }
2917 }
2918#endif
2919 // through the file cache after all: the mapped reads take over (staged() stays true for the GGUF in place)
2920 for (void* d : direct_) close_direct(d);
2921 direct_.clear();
2922 return false;
2923#else
2924 why = "through the file cache (no unbuffered reads on this platform)";
2925 return false;
2926#endif
2927}
2928
2929bool FileExpertSource::drop_mapping(std::string& why) {
2930#if defined(_WIN32)

Callers

nothing calls this directly

Calls 5

file_tier_unbufferedFunction · 0.70
close_directFunction · 0.70
stringFunction · 0.50
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected