Skip to content

Commit e6837dd

Browse files
committed
chore(proctree): lower thread default cache size
Adjust the default the process cache size to 16,384, setting a 2:1 ratio between thread and process caches. With GOGC=5 and both caches stressed, was observed an average heap usage of 77MB.
1 parent 4a5bb5d commit e6837dd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/docs/advanced/data-sources/builtin/process-tree.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The underlying structure is populated using the core `sched_process_fork`, `sche
1414

1515
> Introducing this secondary event source is strategic: it reduces interference with actively traced events, leading to more accurate and granular updates in the process tree.
1616
17-
The number of processes retained in the tree hinges on cache size. We have two separate caches at play: one for processes and another for threads. Both default to a size of 32K, supporting tracking for up to 32,768 processes and the same number of threads. It's worth noting that these are LRU caches: once full, they'll evict the least recently accessed entries to accommodate fresh ones.
17+
The number of processes retained in the tree hinges on cache size. We have two separate caches at play: one for processes and another for threads. The default cache size for processes is 16K, supporting tracking for up to 16,384 processes, while the thread cache is 32K, supporting tracking for up to 32,768 threads. On average, a configuration ratio of 2:1 (thread:cache) is defined, as one thread is created for every process. It's worth noting that these are LRU caches: once full, they'll evict the least recently accessed entries to accommodate fresh ones.
1818

1919
The process tree query the procfs upon initialization and during runtime to fill missing data:
2020
* During initialization, it runs over all procfs to fill all existing processes and threads
@@ -34,7 +34,7 @@ Example:
3434
signals | process tree is built from signals.
3535
both | process tree is built from both events and signals.
3636
--proctree process-cache=8192 | will cache up to 8192 processes in the tree (LRU cache).
37-
--proctree thread-cache=4096 | will cache up to 4096 threads in the tree (LRU cache).
37+
--proctree thread-cache=16384 | will cache up to 16384 threads in the tree (LRU cache).
3838
--proctree process-cache-ttl=60 | will set the process cache element TTL to 60 seconds.
3939
--proctree thread-cache-ttl=60 | will set the thread cache element TTL to 60 seconds.
4040
--proctree disable-procfs-query | Will disable procfs quering during runtime

pkg/proctree/proctree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
//
3636

3737
const (
38-
DefaultProcessCacheSize = 32768
38+
DefaultProcessCacheSize = 16384
3939
DefaultThreadCacheSize = 32768
4040
DefaultProcessCacheTTL = time.Second * 120
4141
DefaultThreadCacheTTL = time.Second * 120

0 commit comments

Comments
 (0)