Commit 7a20ec0
committed
use
Currently as noted in the comment of `putRunner`, there's no attempt
being made to limit the size of the runner pooling - this can result in
the pool containing a lot of runners that were once created in a spur
but will likely not be used anymore. Instead of trying to do gc within
this code, move the pooling to `sync.Pool` which will deallocated objects
in idle and therefore keep the size of the pool as small as possible.
The pool is on a per-regexp scope, this means certain properties can be
re-used for optimal performance.
The motivation for this change is that I'm seeing a lot of memory (~300MiB) being
hold by these runners until the Go program is restarted which feels like
an unoptimal usage of memory, with this change after a spur of these
runners have been created in a small amount of time they are gracefully
deallocated over time and no longer hold memory indefinitely.sync.Pool for runner pooling1 parent 5f3687a commit 7a20ec0
2 files changed
+10
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
| 50 | + | |
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
| |||
76 | 75 | | |
77 | 76 | | |
78 | 77 | | |
79 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1583 | 1583 | | |
1584 | 1584 | | |
1585 | 1585 | | |
1586 | | - | |
1587 | | - | |
1588 | | - | |
1589 | | - | |
1590 | | - | |
1591 | | - | |
1592 | | - | |
1593 | | - | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
1597 | | - | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
1598 | 1589 | | |
1599 | 1590 | | |
1600 | 1591 | | |
| |||
1603 | 1594 | | |
1604 | 1595 | | |
1605 | 1596 | | |
1606 | | - | |
1607 | 1597 | | |
1608 | 1598 | | |
1609 | 1599 | | |
1610 | 1600 | | |
1611 | | - | |
1612 | | - | |
| 1601 | + | |
1613 | 1602 | | |
0 commit comments