scalyr / scalyr-agent-2

The source code for Scalyr Agent 2, the daemon process Scalyr customers run on their servers to collect metrics and logs.
Apache License 2.0
70 stars 59 forks source link

Syslog monitor memory leak fix #1248

Closed alesnovak-s1 closed 5 months ago

alesnovak-s1 commented 7 months ago

After several attempts to make syslog monitor threading robust and memory efficient, I decided to implement a simple solution of bounded ThreadingMixin. A better candidate might seem to be a ThreadPoolExecutor, but it proved to be very memory hungry.

The reason for using threads in the first place is:

The ideal solution would be to get right of our rigid in-house implementation based on BaseServer and etither

github-actions[bot] commented 7 months ago

Test Results

     20 files  ±0       20 suites  ±0   30m 23s :stopwatch: - 2m 52s 1 486 tests +1  1 466 :heavy_check_mark: +1    20 :zzz: ±0  0 :x: ±0  7 101 runs  +5  6 874 :heavy_check_mark: +3  227 :zzz: +2  0 :x: ±0 

Results for commit bdaa12e8. ± Comparison against base commit 47390e30.

:recycle: This comment has been updated with latest results.

codecov[bot] commented 7 months ago

Codecov Report

Attention: Patch coverage is 87.80488% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 78.31%. Comparing base (b514d71) to head (568b57d). Report is 5 commits behind head on master.

:exclamation: Current head 568b57d differs from pull request most recent head bdaa12e. Consider uploading reports for the commit bdaa12e to get more accurate results

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/scalyr/scalyr-agent-2/pull/1248/graphs/tree.svg?width=650&height=150&src=pr&token=KrvyP8n7be&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scalyr)](https://app.codecov.io/gh/scalyr/scalyr-agent-2/pull/1248?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scalyr) ```diff @@ Coverage Diff @@ ## master #1248 +/- ## =========================================== + Coverage 54.83% 78.31% +23.48% =========================================== Files 51 176 +125 Lines 18666 42929 +24263 Branches 3294 4775 +1481 =========================================== + Hits 10235 33617 +23382 - Misses 7232 8237 +1005 + Partials 1199 1075 -124 ``` | [Files](https://app.codecov.io/gh/scalyr/scalyr-agent-2/pull/1248?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scalyr) | Coverage Δ | | |---|---|---| | [scalyr\_agent/builtin\_monitors/thread\_pool\_dummy.py](https://app.codecov.io/gh/scalyr/scalyr-agent-2/pull/1248?src=pr&el=tree&filepath=scalyr_agent%2Fbuiltin_monitors%2Fthread_pool_dummy.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scalyr#diff-c2NhbHlyX2FnZW50L2J1aWx0aW5fbW9uaXRvcnMvdGhyZWFkX3Bvb2xfZHVtbXkucHk=) | `0.00% <ø> (ø)` | | | [tests/unit/builtin\_monitors/syslog\_monitor\_test.py](https://app.codecov.io/gh/scalyr/scalyr-agent-2/pull/1248?src=pr&el=tree&filepath=tests%2Funit%2Fbuiltin_monitors%2Fsyslog_monitor_test.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scalyr#diff-dGVzdHMvdW5pdC9idWlsdGluX21vbml0b3JzL3N5c2xvZ19tb25pdG9yX3Rlc3QucHk=) | `98.31% <100.00%> (ø)` | | | [scalyr\_agent/builtin\_monitors/syslog\_monitor.py](https://app.codecov.io/gh/scalyr/scalyr-agent-2/pull/1248?src=pr&el=tree&filepath=scalyr_agent%2Fbuiltin_monitors%2Fsyslog_monitor.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scalyr#diff-c2NhbHlyX2FnZW50L2J1aWx0aW5fbW9uaXRvcnMvc3lzbG9nX21vbml0b3IucHk=) | `68.59% <83.33%> (+16.31%)` | :arrow_up: | | [scalyr\_agent/builtin\_monitors/thread\_pool.py](https://app.codecov.io/gh/scalyr/scalyr-agent-2/pull/1248?src=pr&el=tree&filepath=scalyr_agent%2Fbuiltin_monitors%2Fthread_pool.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scalyr#diff-c2NhbHlyX2FnZW50L2J1aWx0aW5fbW9uaXRvcnMvdGhyZWFkX3Bvb2wucHk=) | `85.19% <83.33%> (+3.19%)` | :arrow_up: | ... and [165 files with indirect coverage changes](https://app.codecov.io/gh/scalyr/scalyr-agent-2/pull/1248/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scalyr)