Commit Graph

33 Commits

Author SHA1 Message Date
Marten Seemann 60d0a53755
run debug.FreeOSMemory when forcing GC (#16) 2021-12-13 12:19:07 +00:00
Marten Seemann bee183a29f
register a callback that is called when watchdog forces GC (#15) 2021-12-12 15:25:34 +00:00
Marten Seemann 4f154e81e0
add a RegisterNotifee function to register notifees, deprecate NotifyGC (#13) 2021-11-26 13:15:13 +00:00
raulk c1e393b2ba
Merge pull request #10 from raulk/feat/adjustments
small adjustments.
2021-01-20 17:51:13 +00:00
Raúl Kripalani 267fadcda5 small adjustments.
* minimum GOGC on heap watchdog to prevent GC overscheduling.
* write heap _profiles_ instead of heap _dumps_.
* minor logging adjustments.
2021-01-20 15:53:18 +00:00
raulk 802277301d
Merge pull request #9 from raulk/feat/recover
recover from panics + test.
2021-01-20 11:14:22 +00:00
raulk b4c33f71a6
Merge pull request #8 from raulk/feat/heapdumps
implement automatic heapdumps when usage is above threshold.
2021-01-20 10:43:59 +00:00
Raúl Kripalani 07b4c6d751 fix sed replace that overreached. 2021-01-20 10:41:55 +00:00
Raúl Kripalani 4b2e62c6e3 recover from panics + test. 2021-01-19 20:34:28 +00:00
Raúl Kripalani 31d951f370 implement automatic heapdumps when usage is above threshold.
A heapdump will be captured when the usage trespasses the threshold.
Staying above the threshold won't trigger another heapdump.
If the usage goes down, then back up, that is considered another
"episode" to be captured in a heapdump.

This feature is driven by three parameters:

* HeapdumpDir: the directory where the watchdog will write the heapdump.
  It will be created if it doesn't exist upon initialization. An error when
  creating the dir will not prevent heapdog initialization; it will just
  disable the heapdump capture feature.

  If zero-valued, the feature is disabled. Heapdumps will be written to path:
  <HeapdumpDir>/<RFC3339Nano formatted timestamp>.heap.

* HeapdumpMaxCaptures: sets the maximum amount of heapdumps a process will
  generate. This limits the amount of episodes that will be captured, in case
  the utilization climbs repeatedly over the threshold. By default, it is 10.

* HeapdumpThreshold: sets the utilization threshold that will trigger a
  heap dump to be taken automatically. A zero value disables this feature.
  By default, it is disabled.
2021-01-19 20:02:16 +00:00
raulk 13cc66ee4c
Merge pull request #6 from raulk/cgroups-driven 2021-01-18 22:33:53 +00:00
Raúl Kripalani f631fb2ee4 skip tests that don't work in CircleCI due to unwritable cgroup. 2021-01-18 22:15:47 +00:00
Raúl Kripalani cf7bf56a2b adjust TestCgroupsDriven_Docker_Isolated. 2021-01-18 21:40:17 +00:00
Raúl Kripalani ac4c29506c tests: skip TestCgroupsDriven_Create_Isolated. 2021-01-18 21:36:54 +00:00
Raúl Kripalani 4f8de94bb9 circleci: run build on bare linux. 2021-01-18 21:33:52 +00:00
Raúl Kripalani 8676adea5c introduce cgroup-driven watchdog; refactor.
This commit introduces the cgroup-driven watchdog. It can be
initialized by calling watchdog.CgroupDriven().

This watchdog infers the limit from the process' cgroup, which
is either derived from /proc/self/cgroup, or from the root
cgroup if the PID == 1 (running in a container).

Tests have been added/refactored to accommodate running locally
and in a Docker container.

Certain test cases now must be isolated from one another, to
prevent side-effects from dirty go runtimes. A Makefile has been
introduced to run all tests.
2021-01-18 21:24:31 +00:00
Raúl Kripalani 903e001223 fix build on linux. 2020-12-09 16:27:19 +00:00
Raúl Kripalani 5cd257c2b4
README: fix CircleCI badge link. 2020-12-09 16:26:53 +00:00
Raúl Kripalani a99678239d
Merge pull request #4 from raulk/refactor 2020-12-09 16:23:37 +00:00
Raúl Kripalani f862f34a05
README: add CircleCI badge. 2020-12-09 16:22:56 +00:00
Raúl Kripalani da833d93a7
Add .circleci/config.yml (#5) 2020-12-09 16:21:16 +00:00
Raúl Kripalani 1df6596e03 recycle timer. 2020-12-09 16:13:27 +00:00
Raúl Kripalani 5f00469e3a remove 'immediate' flag in policies. 2020-12-09 15:35:29 +00:00
Raúl Kripalani 12a1d3f053 demote log to debug. 2020-12-09 14:58:17 +00:00
Raúl Kripalani a4d30cafdc add log warning. 2020-12-09 14:56:03 +00:00
Raúl Kripalani fcf668bfe2 nit fixing. 2020-12-09 14:54:56 +00:00
Raúl Kripalani b35cdf0c7d replace atomic state guarding with lock. 2020-12-09 14:54:09 +00:00
Raúl Kripalani 4558d98653 major rewrite of go-watchdog.
This commit introduces a major rewrite of go-watchdog.

* HeapDriven and SystemDriven are now distinct run modes.
* WIP ProcessDriven that uses cgroups.
* Policies are now stateless, pure and greatly simplified.
* Policies now return the next utilization at which GC
  should run. The watchdog enforces that value differently
  depending on the run mode.
* The heap-driven run mode adjusts GOGC dynamically. This
  places the responsibility on the Go runtime to honour the
  trigger point, and results in more robust logic that is not
  vulnerable to very quick bursts within sampling periods.
* The heap-driven run mode is no longer polling (interval-driven).
  Instead, it relies entirely on GC signals.
* The Silence and Emergency features of the watermark policy
  have been removed. If utilization is above the last watermark,
  the policy will request immediate GC.
* Races removed.
2020-12-08 14:19:04 +00:00
Raúl Kripalani ffbfd5e37a improve logging. 2020-12-02 16:33:00 +00:00
Raúl Kripalani 2181a740fb add godocs link to README. 2020-12-02 00:14:25 +00:00
Raúl Kripalani a23c2f6944 fix README link. 2020-12-02 00:12:08 +00:00
Raúl Kripalani 0edb313e96 misc fixes to docs; import path. 2020-12-02 00:10:21 +00:00
Raúl Kripalani e2e9d96ec7 initial commit. 2020-12-02 00:03:20 +00:00