-
Notifications
You must be signed in to change notification settings - Fork 174
feat(flow): implement adaptive throttler #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
… throughput control
- Fix gocritic issues (elseif, ifElseChain) - Fix gosec G115 integer overflow - Fix revive unused parameter issues - Fix unconvert unnecessary conversions - Fix line length violations (>120 chars) - Rename CPUUsageModeRusage → CPUUsageModeReal - Move goroutineHeuristicSampler to dedicated file - Update gopsutil from v4.25.10 → v4.24.6 for Go 1.21 compatibility
…mmented-out configuration examples
- Rename CPUUsageModeReal to CPUUsageModeMeasured for clarity - Add clarifying comment to setSystemMemoryReader function The new name better reflects that even gopsutil measurements are approximations rather than absolute 'real' values.
…ed environments - Add cgroup v2/v1 auto-detection for accurate memory stats in containers - Normalize CPU usage sampling by core count for better accuracy - Support custom memory readers in ResourceMonitor for flexible deployments - Add comprehensive system_memory tests with mock file systems - Improve test reliability with polling-based waiting instead of fixed sleeps
fix(flow): emit partial sliding window on early close (reugn#192)
- Implement a demo application showcasing the adaptive throttler in action
Co-authored-by: Eugene R. <reugpro@gmail.com>
Co-authored-by: Eugene R. <reugpro@gmail.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #196 +/- ##
===========================================
- Coverage 99.53% 89.07% -10.47%
===========================================
Files 13 20 +7
Lines 651 1227 +576
===========================================
+ Hits 648 1093 +445
- Misses 2 95 +93
- Partials 1 39 +38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…/sysmonitor package Refactor CPU and memory monitoring code from the flow package into a dedicated internal/sysmonitor package. This improves code organization, testability, and platform-specific implementation support. Key changes: - Move CPU sampling logic to internal/sysmonitor with platform-specific implementations for Darwin, Linux, Windows, and fallback - Move system memory monitoring to internal/sysmonitor with support for: - Linux: /proc/meminfo, cgroup v1, and cgroup v2 detection - Darwin: Mach kernel APIs with CGO - Windows: GlobalMemoryStatusEx API - Fallback: Error handling for unsupported platforms - Move heuristic CPU sampler from flow/cpu_sampler_heuristic.go to internal/sysmonitor/heuristic.go - Update adaptive_throttler and resource_monitor to use new package - Remove flow/cpu_sampler.go, flow/system_memory.go
Updated the getProcessCPUTimes function to use GetCurrentProcess for the current process, enhancing reliability and eliminating the need to open a process handle. This change simplifies the code and improves performance when retrieving CPU times.
|
@reugn Changes applied. Ready for re-review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve test coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve test coverage.
…at errors - Implemented a safety check to ensure the number of CPUs is at least 1 in both Darwin and Linux CPU sampling functions. - Updated memory reading functions to handle potential errors gracefully, defaulting to 0 for unavailable stats.
…ed cpuTimesStat struct
…sCPUTimes function
…rottling process Co-authored-by: Eugene R. <reugpro@gmail.com>
…/go-streams into feature/adaptive-throttler
Co-authored-by: Eugene R. <reugpro@gmail.com>
…quirement Co-authored-by: Eugene R. <reugpro@gmail.com>
Co-authored-by: Eugene R. <reugpro@gmail.com>
…ource statistics collection Co-authored-by: Eugene R. <reugpro@gmail.com>
…its functionality Co-authored-by: Eugene R. <reugpro@gmail.com>
…ctions to resource_monitor.go
…in NewAdaptiveThrottler calls
…Pointer for improved type safety
…cessary mutex locking
…hod on AdaptiveThrottlerConfig
… documentation and improve code clarity
…tor registry with reference counting - Replace singleton ResourceMonitor with shared registry pattern for efficient resource sharing - Add dynamic interval updates and improved CPU mode switching - Enhance memory sampling with better fallback handling - Add InDelta assertion helper for precise float comparisons - Comprehensive test refactoring with improved mocking and coverage - Update adaptive throttler tests to use new resource monitor architecture
16077b7 to
6e24e80
Compare
|
@reugn Can you please re-run workflows (codecov, golangci-lint)? |
Motivation
Modifications
ResourceMonitorwith pluggablecpuUsageSampler(heuristic & measured modes) andmemoryReader(cgroup v1/v2 & host support).AdaptiveThrottlerConfigfor tuning thresholds, adaptation steps, and sampling intervals.Verify change