timescaledb-docker icon indicating copy to clipboard operation
timescaledb-docker copied to clipboard

timescaledb-tune wrapper CPU heuristic off in GKE/k8s

Open remingtonc opened this issue 3 years ago • 0 comments

The heuristic in 001_timescaledb_tune.sh does not tune according to k8s limits (at least in GKE (Google Kubernetes Engine)). With CPU resource limits as requesting 1.5 and limit 3 we can see that /sys/fs/cgroup/cpuset/cpuset.effective_cpus returns the node potential, which yields tuning greater than limits.

# tune heuristic
$ cat /sys/fs/cgroup/cpuset/cpuset.effective_cpus
0-7
$ cat /sys/fs/cgroup/cpuset/cpuset.cpus
0-7
# resource request
$ cat /sys/fs/cgroup/cpu/cpu.shares
1536
# resource limits
$ cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us
300000
$ cat /sys/fs/cgroup/cpu/cpu.cfs_period_us
100000
$ cat /sys/fs/cgroup/cpu/cpu.stat
nr_periods 295975
nr_throttled 23928
throttled_time 2144160036200

It seems like the tune should derive from /sys/fs/cgroup/cpu/cpu.cfs_quota_us and /sys/fs/cgroup/cpu/cpu.cfs_period_us rather than the cpuset if more constrained than the cpuset.

This is easily fixed by specifying the TS_TUNE environment variables to be the same as the limits, which is pretty simple, but could be more automatic. :)

remingtonc avatar Jul 09 '21 16:07 remingtonc