Async/await latency spikes under concurrent requests in Vala
0 reputation · 06 Jul 2025, 06:45 UTC
The goal is to pinpoint the source of latency spikes that appear only when several Vala async functions are invoked concurrently. The application uses GLib 2.64, POSIX threads, and the async/await pattern compiled to GTask and GMainContext. The issue manifests as unpredictable delays, but no single error is logged.
Possible contributors include lock contention inside GMainContext, contention in GLib's memory allocator when many threads allocate, and GObject signal emission overhead when multiple objects emit signals simultaneously.
Because the latency is only observable under concurrent load, the root cause may be subtle, and existing benchmarks for Vala concurrency are sparse.
What specific aspects of GMainContext lock contention could be responsible for the observed delays? Does GLib's allocator create contention when multiple threads perform frequent allocations? To what extent do concurrent GObject signal emissions add to the latency?