Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Worked around a generational GC issue
Instead of directly modifying the 'TimeoutQueue' in e.g. 'registerTimeout' we keep a list of edits to perform and have the I/O manager thread perform the edits later. This exist to address the following GC problem: Since e.g. 'registerTimeout' doesn't force the evaluation of the thunks inside the 'emTimeouts' IORef a number of thunks build up inside the IORef. If the I/O manager thread doesn't evaluate these thunks soon enough they'll get promoted to the old generation and become roots for all subsequent minor GCs. When the thunks eventually get evaluated they will each create a new intermediate 'TimeoutQueue' that immediately becomes garbage. Since the thunks serve as roots until the next major GC these intermediate 'TimeoutQueue's will get copied unnecesarily in the next minor GC, increasing GC time. This problem is known as "floating garbage". Keeping a list of edits doesn't stop this from happening but makes the amount of data that gets copied smaller. The run-time of "thread-delay -n 20000" goes down by 34%. The measurement was done by taking the median run-time of five runs.
- Loading branch information
Showing
1 changed file
with
66 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters