Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

dsv41 Windows: 1 ms timer resolution while the engine runs; DS4_TIMER_MS=0 leaves it

Niko1221611c1701d3e1
diff --git a/src/dsv41/ds4_main.cpp b/src/dsv41/ds4_main.cpp
index e614e6cb1..cd6e3a35b 100644
--- a/src/dsv41/ds4_main.cpp
+++ b/src/dsv41/ds4_main.cpp
@@ -13,6 +13,7 @@
// that prompt's end; anything else starts over. `GENI <max_new> [keys] <file> <ids>` carries the prompt's pictures
// (the file: see read_pics); the state is shared only where the same picture sits at the same place.
#include "ds4_model.hpp"
+#include "ds4_os.hpp"
#include "ds4_packinfo.hpp"
#include <algorithm>
@@ -740,6 +741,7 @@ int spec_eval(strata::ds4::Model& m, const std::string& ids_path, int n, int win
#endif
int main(int argc, char** argv) {
+ strata::ds4::os::fine_timer();
strata::ds4::Options o;
std::string ids_s, dump, eos = "1";
int n = 0, window = 0; // (0: the model's feed unit - a whole prompt on the chunked path; 16 for the scoring runs)
diff --git a/src/dsv41/ds4_os.hpp b/src/dsv41/ds4_os.hpp
index 50f6ee5af..1901f064b 100644
--- a/src/dsv41/ds4_os.hpp
+++ b/src/dsv41/ds4_os.hpp
@@ -22,6 +22,10 @@
#endif
#include <windows.h>
#include <psapi.h> // (K32QueryWorkingSetEx: kernel32's, no psapi.lib)
+#include <timeapi.h>
+#ifdef _MSC_VER
+#pragma comment(lib, "winmm.lib")
+#endif
#else
#include <fcntl.h>
#include <pthread.h>
@@ -34,6 +38,17 @@
namespace strata::ds4::os {
+/// Windows sleeps in 15.6 ms ticks unless a process asks for finer ones: the CPU lane's service thread naps (sleep_for 20 us)
+/// between tokens, and the device's first wait of the next token then waits out the tick. 1 ms for the process's life
+/// (Project Maya #358); DS4_TIMER_MS=0 leaves the system's resolution alone. Elsewhere nothing.
+inline void fine_timer() {
+#if defined(_WIN32)
+ const char* v = std::getenv("DS4_TIMER_MS");
+ const int ms = v != nullptr ? std::atoi(v) : 1;
+ if (ms > 0) timeBeginPeriod((UINT) ms);
+#endif
+}
+
using fd_t = intptr_t;
constexpr fd_t kBadFd = -1;