]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
server : replace sleep with condition variables (#4673)
authorJustine Tunney <redacted>
Fri, 29 Dec 2023 14:24:12 +0000 (06:24 -0800)
committerGitHub <redacted>
Fri, 29 Dec 2023 14:24:12 +0000 (16:24 +0200)
commitdb49ff8ed7f0bb201176703441cc02911b08ef2a
treea872e058513f73931d582a3fba20bac012520ad9
parent60f55e888c29cbd87c4238dd19e85d0eef87245d
server : replace sleep with condition variables (#4673)

The server currently schedules tasks using a sleep(5ms) busy loop. This
adds unnecessary latency since most sleep implementations do a round up
to the system scheduling quantum (usually 10ms). Other libc sleep impls
spin for smaller time intervals which results in the server's busy loop
consuming all available cpu. Having the explicit notify() / wait() code
also helps aid in the readability of the server code.

See mozilla-Ocho/llamafile@711344b
examples/server/server.cpp