Skip to content

Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦

C

fix(colibri.c): add Windows fallbacks for now_s and rss_gb

4ny3ld8abaae6809c
diff --git a/c/colibri.c b/c/colibri.c
index 656fdc64..5245410b 100644
--- a/c/colibri.c
+++ b/c/colibri.c
@@ -349,13 +349,30 @@ static int parse_cuda_devices(const char *list, int *out){
return n;
}
#endif
-static double now_s(void){ struct timespec t; clock_gettime(CLOCK_MONOTONIC,&t); return t.tv_sec+t.tv_nsec*1e-9; }
-static double rss_gb(void){ struct rusage r; getrusage(RUSAGE_SELF,&r);
+static double now_s(void){
+#ifdef _WIN32
+ LARGE_INTEGER freq, count;
+ QueryPerformanceFrequency(&freq);
+ QueryPerformanceCounter(&count);
+ return (double)count.QuadPart / (double)freq.QuadPart;
+#else
+ struct timespec t; clock_gettime(CLOCK_MONOTONIC,&t); return t.tv_sec+t.tv_nsec*1e-9;
+#endif
+}
+static double rss_gb(void){
+#ifdef _WIN32
+ PROCESS_MEMORY_COUNTERS_EX pmc = {0}; pmc.cb = sizeof(pmc);
+ if(GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc)))
+ return pmc.WorkingSetSize / (1024.0 * 1024.0 * 1024.0);
+ return 0;
+#else
+ struct rusage r; getrusage(RUSAGE_SELF,&r);
#ifdef __APPLE__
return r.ru_maxrss/(1024.0*1024.0*1024.0); /* macOS: ru_maxrss in BYTE */
#else
return r.ru_maxrss/(1024.0*1024.0); /* Linux: in KB */
#endif
+#endif
}
/* ---- PROF=1: opt-in performance profile ----------------------------------
* Records per-forward decode latency and expert-file bytes fetched, then