diff options
author | Thireus ☠ <Thireus@users.noreply.github.com> | 2025-07-17 07:50:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-17 08:50:26 +0200 |
commit | 6950c82c302dd6afc838f4a405d86d323f35126d (patch) | |
tree | f531465ac3d42690bf68fca338c39e4be6c6d67f | |
parent | c4fbced37db712dd222d8a0e0d6986e94811d214 (diff) |
Bump Windows max open files from 512 to 2048 (#620)
* Bump windows max open files from 512 to 2048
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio?view=msvc-160
* Make _GGML_STDIO_TARGET dependent of GGML_MAX_CONTEXTS for Windows
-rw-r--r-- | src/llama.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/llama.cpp b/src/llama.cpp index 58812fc8..0d29f24a 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -4245,6 +4245,24 @@ struct llama_model_loader { trace = atoi(getenv("LLAMA_TRACE")); } + #ifdef _WIN32 + // Only bump maxstdio if the user really wants large contexts: + #if defined(GGML_MAX_CONTEXTS) && (GGML_MAX_CONTEXTS > 512) + // Cap at MSVC's hard limit of 8192 - https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio?view=msvc-160 + #if (GGML_MAX_CONTEXTS > 8192) + #define _GGML_STDIO_TARGET 8192 + #else + #define _GGML_STDIO_TARGET GGML_MAX_CONTEXTS + #endif + int _setmaxstdio_ret = _setmaxstdio(_GGML_STDIO_TARGET); + if (_setmaxstdio_ret == -1) { + LLAMA_LOG_INFO("%s: failed to set max stdio to %d. (setmaxstdio returned -1)\n", __func__, _GGML_STDIO_TARGET); + } else { + LLAMA_LOG_INFO("%s: max stdio successfully set to %d\n", __func__, _setmaxstdio_ret); + } + #endif // GGML_MAX_CONTEXTS > 512 + #endif // _WIN32 + if (param_overrides_p != nullptr) { for (const struct llama_model_kv_override * p = param_overrides_p; p->key[0] != 0; p++) { kv_overrides.insert({std::string(p->key), *p}); |