mirror of https://github.com/ollama/ollama
win: revert CPU discovery logic to 0.12.3 (#12969)
The behavior change in 0.12.4 is the most likely the root cause of hangs some users are seeing. This reverts to the 0.12.3 code, with some added trace logging.
This commit is contained in:
parent
8bbc7395db
commit
97e05d2a6b
|
|
@ -5,6 +5,8 @@ import (
|
|||
"log/slog"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/ollama/ollama/logutil"
|
||||
)
|
||||
|
||||
type MEMORYSTATUSEX struct {
|
||||
|
|
@ -99,22 +101,29 @@ func (pkg *winPackage) IsMember(target *GROUP_AFFINITY) bool {
|
|||
}
|
||||
|
||||
func getLogicalProcessorInformationEx() ([]byte, error) {
|
||||
buf := make([]byte, 1024)
|
||||
buf := make([]byte, 1)
|
||||
bufSize := len(buf)
|
||||
var err error
|
||||
for range 3 {
|
||||
var ret uintptr
|
||||
ret, _, err := GetLogicalProcessorInformationEx.Call(
|
||||
uintptr(RelationAll),
|
||||
uintptr(unsafe.Pointer(&buf[0])),
|
||||
uintptr(unsafe.Pointer(&bufSize)),
|
||||
)
|
||||
if ret != 0 {
|
||||
logutil.Trace("failed to retrieve CPU payload size", "ret", ret, "size", bufSize, "error", err)
|
||||
return nil, fmt.Errorf("failed to determine size info ret:%d %w", ret, err)
|
||||
}
|
||||
|
||||
buf = make([]byte, bufSize)
|
||||
ret, _, err = GetLogicalProcessorInformationEx.Call(
|
||||
uintptr(RelationAll),
|
||||
uintptr(unsafe.Pointer(&buf[0])),
|
||||
uintptr(unsafe.Pointer(&bufSize)),
|
||||
)
|
||||
if ret == 1 && bufSize <= len(buf) {
|
||||
if ret == 0 {
|
||||
logutil.Trace("failed to retrieve CPU information", "ret", ret, "size", len(buf), "new_size", bufSize, "error", err)
|
||||
return nil, fmt.Errorf("failed to gather processor information ret:%d buflen:%d %w", ret, bufSize, err)
|
||||
}
|
||||
return buf, nil
|
||||
}
|
||||
buf = make([]byte, bufSize)
|
||||
}
|
||||
return nil, fmt.Errorf("unable to determine CPU details: %w", err)
|
||||
}
|
||||
|
||||
func processSystemLogicalProcessorInforationList(buf []byte) []*winPackage {
|
||||
|
|
|
|||
Loading…
Reference in New Issue