metal : reduce rset heartbeat from 500ms -> 5ms (#24074)
This commit is contained in:
@@ -547,6 +547,8 @@ struct ggml_metal_rsets {
|
|||||||
// number of seconds since the last graph computation
|
// number of seconds since the last graph computation
|
||||||
// keep the residency sets wired for that amount of time to avoid being collected by the OS
|
// keep the residency sets wired for that amount of time to avoid being collected by the OS
|
||||||
int keep_alive_s;
|
int keep_alive_s;
|
||||||
|
int loops_per_s;
|
||||||
|
int time_per_loop_ms;
|
||||||
|
|
||||||
// background heartbeat thread to keep the residency sets alive
|
// background heartbeat thread to keep the residency sets alive
|
||||||
atomic_bool d_stop;
|
atomic_bool d_stop;
|
||||||
@@ -573,10 +575,13 @@ ggml_metal_rsets_t ggml_metal_rsets_init(void) {
|
|||||||
res->keep_alive_s = 3*60;
|
res->keep_alive_s = 3*60;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res->time_per_loop_ms = 5;
|
||||||
|
res->loops_per_s = 1000/res->time_per_loop_ms;
|
||||||
|
|
||||||
GGML_LOG_INFO("%s: creating a residency set collection (keep_alive = %d s)\n", __func__, res->keep_alive_s);
|
GGML_LOG_INFO("%s: creating a residency set collection (keep_alive = %d s)\n", __func__, res->keep_alive_s);
|
||||||
|
|
||||||
atomic_store_explicit(&res->d_stop, false, memory_order_relaxed);
|
atomic_store_explicit(&res->d_stop, false, memory_order_relaxed);
|
||||||
atomic_store_explicit(&res->d_loop, 2*res->keep_alive_s, memory_order_relaxed);
|
atomic_store_explicit(&res->d_loop, res->loops_per_s*res->keep_alive_s, memory_order_relaxed);
|
||||||
|
|
||||||
res->d_group = dispatch_group_create();
|
res->d_group = dispatch_group_create();
|
||||||
|
|
||||||
@@ -599,8 +604,7 @@ ggml_metal_rsets_t ggml_metal_rsets_init(void) {
|
|||||||
[res->lock unlock];
|
[res->lock unlock];
|
||||||
}
|
}
|
||||||
|
|
||||||
// half a second
|
usleep(res->time_per_loop_ms * 1000);
|
||||||
usleep(500 * 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -979,7 +983,7 @@ void ggml_metal_device_rsets_keep_alive(ggml_metal_device_t dev) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_store_explicit(&dev->rsets->d_loop, 2*dev->rsets->keep_alive_s, memory_order_relaxed);
|
atomic_store_explicit(&dev->rsets->d_loop, dev->rsets->loops_per_s*dev->rsets->keep_alive_s, memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ggml_metal_event {
|
struct ggml_metal_event {
|
||||||
|
|||||||
Reference in New Issue
Block a user