atproto relay implementation in zig zlay.waow.tech
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

revert mallinfo2 — zig cross-compile links bundled glibc

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

zzstoatzz 89f34ce3 1c9e9b57

+3 -17
+3 -17
src/broadcaster.zig
··· 628 628 return fbs.getWritten(); 629 629 } 630 630 631 - // glibc mallinfo2 (available since 2.33) — declared manually because zig's 632 - // bundled cross-compile headers may not include it, but the runtime glibc does. 633 - // uses usize fields (no 2 GiB overflow like mallinfo's int fields). 634 - const Mallinfo2 = extern struct { 635 - arena: usize, // bytes claimed from OS (non-mmap) 636 - ordblks: usize, 637 - smblks: usize, 638 - hblks: usize, 639 - hblkhd: usize, // bytes in mmap regions 640 - usmblks: usize, 641 - fsmblks: usize, 642 - uordblks: usize, // bytes in use (allocated) 643 - fordblks: usize, // free bytes in arena (fragmentation) 644 - keepcost: usize, 645 - }; 646 - extern "c" fn mallinfo2() Mallinfo2; 631 + const malloc_h = @cImport(@cInclude("malloc.h")); 647 632 648 633 fn appendProcMetrics(w: anytype) void { 649 634 // RSS from /proc/self/statm (field[1] * page_size) ··· 698 683 } else |_| {} 699 684 700 685 // glibc malloc arena stats — distinguishes in-use heap from fragmentation 701 - const mi = mallinfo2(); 686 + // mallinfo uses int fields (cap at 2 GiB) but sufficient for trend analysis 687 + const mi = malloc_h.mallinfo(); 702 688 std.fmt.format(w, 703 689 \\# TYPE relay_malloc_arena_bytes gauge 704 690 \\# HELP relay_malloc_arena_bytes total bytes claimed from OS by malloc