Tags: galpt/cake-stats
Tags
fix: detect MIPS endianness correctly in install script Linux's uname -m always reports 'mips' for all MIPS variants regardless of endianness, causing the installer to download the big-endian binary for little-endian MIPS routers like the JCG Q20 (MT7621 SoC). Add a detect_mips_endianness() function that probes: 1. /etc/openwrt_release DISTRIB_ARCH field (covers OpenWrt) 2. /proc/cpuinfo byte order field (generic Linux) 3. readelf ELF header inspection (authoritative fallback) 4. Big-endian as the default fallback (historical convention) This ensures JCG Q20 and other little-endian MIPS routers get the correct linux-mipsle / linux-mips64le binary. Signed-off-by: Galih Tama <galpt@v.recipes>
refactor: achieve near-zero-allocation parsing and eliminate dead code Replace the parser's allocation-heavy text processing with a zero-allocation approach: - Introduce LineScanner: iterates over lines in a raw []byte slice without allocating per-line strings (replaces strings.Split/SplitLines) - Introduce FieldTokenizer: tokenises a string into fields using a pre-allocated [64]string buffer on the stack (replaces strings.Fields) - Replace map-based tier table storage with fixed-size arrays + linear scan, eliminating hash-map allocations during parsing - Replace fmt.Sprintf with formatUint64 writing into a stack buffer - Replace strings.Split with manual comma scanning in parseSentLine - Hand-roll ParseUint64 to avoid strconv.ParseUint error-interface escape, making it truly zero-allocation (0 B/op, 19 ns/op) - Remove dead utility functions: SplitLines, Fields, Split, SplitN - Remove unused util.SplitLines from split.go - Update README design notes to reflect the new parser architecture - Add allocation benchmarks to pkg/parser to prevent regression Results (2-interface CAKE setup): Before: 124 allocs/op, 21,232 B/op, 20,545 ns/op After: 3 allocs/op, 3,072 B/op, 9,576 ns/op 97.6% fewer allocations, 85.5% less memory, 53% faster Signed-off-by: Galih Tama <galpt@v.recipes>
refactor: remove dead code, fix documentation, and improve code quality - Remove 7 unused functions and their associated imports and vars: supportsJSON, parseJSON, AfterSlash, StringToBytes, TrimPrefix, TrimRight, getUint - Remove dead test TestParseJSONMinimal - Fix contradictory package doc comment in parser.go to match the text-only tc parsing strategy - Remove duplicate comment in parser_test.go, stale migration artifact in parser.go, and misleading reference in types.go - Update README: bump Go version to 1.26, remove stale rtnetlink claims - Use SplitLines instead of Split for text parsing, reanimating the existing utility function - Add named constant for SSE retry interval - Simplify dead ternary in interface count display - Harden parseMemoryLine with parts[1] == "of" guard - Bump go.mod and CI Go version to 1.26 Signed-off-by: Galih Tama <galpt@v.recipes>
PreviousNext