Interim release: documentation updates and rate limiting improvements

- Add applesauce library reference documentation
- Add rate limiting test report for Badger
- Add memory monitoring for rate limiter (platform-specific implementations)
- Enhance PID-controlled adaptive rate limiting
- Update Neo4j and Badger monitors with improved load metrics
- Add docker-compose configuration
- Update README and configuration options

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit was merged in pull request #3.
This commit is contained in:
2025-12-12 08:47:25 +01:00
parent ba84e12ea9
commit f16ab3077f
20 changed files with 1581 additions and 75 deletions

View File

@@ -0,0 +1,62 @@
//go:build linux && !(js && wasm)
package ratelimit
import (
"bufio"
"os"
"strconv"
"strings"
)
// ReadProcessMemoryStats reads memory statistics from /proc/self/status.
// This provides accurate RSS (Resident Set Size) information on Linux,
// including the breakdown between shared and anonymous memory.
func ReadProcessMemoryStats() ProcessMemoryStats {
stats := ProcessMemoryStats{}
file, err := os.Open("/proc/self/status")
if err != nil {
// Fallback to runtime stats if /proc is not available
return readProcessMemoryStatsFallback()
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
fields := strings.Fields(line)
if len(fields) < 2 {
continue
}
key := strings.TrimSuffix(fields[0], ":")
valueStr := fields[1]
value, err := strconv.ParseUint(valueStr, 10, 64)
if err != nil {
continue
}
// Values in /proc/self/status are in kB
valueBytes := value * 1024
switch key {
case "VmRSS":
stats.VmRSS = valueBytes
case "RssShmem":
stats.RssShmem = valueBytes
case "RssAnon":
stats.RssAnon = valueBytes
case "VmHWM":
stats.VmHWM = valueBytes
}
}
// If we didn't get VmRSS, fall back to runtime stats
if stats.VmRSS == 0 {
return readProcessMemoryStatsFallback()
}
return stats
}