News for hackers. Stuff that matters.
Re:Talc – A fast and flexible allocator for no_std and WebAs... by tekacs on Wednesday February 28, 2024 @09:41PM (#39545958)
I've been using this recently in WASM, in particular for the counters feature. It's really great and it makes it super easy to track and follow the evolution of your app's memory!

In my console, I have something akin to this:

  TRACE client_wasm::plugins::allocation: Memory stats counters=Counters { allocation_count: 165454, total_allocation_count: 18756119, allocated_bytes: 34654828, total_allocated_bytes: 3185258585, available_bytes: 82802636, fragment_count: 5026, heap_count: 1, total_heap_count: 1, claimed_bytes: 118423552, total_claimed_bytes: 118423552 }
I haven't carefully benchmarked dlmalloc (Rust's default WASM allocator, https://github.com/alexcrichton/dlmalloc-rs), but it's nothing special (to my knowledge). The swap to Talc is pretty trivial and it's clear that the author is paying attention to its performance.
Re:Talc – A fast and flexible allocator for no_std and WebAs... by josephg on Thursday February 29, 2024 @01:57AM (#39546998)
Thats a pretty big heap size for a wasm bundle! What are you doing in wasm that allocates so much and so often?
Re:Talc – A fast and flexible allocator for no_std and WebAs... by IshKebab on Thursday February 29, 2024 @02:25AM (#39547120)
34 MB? Doesn't seem that big to me.
Re:Talc – A fast and flexible allocator for no_std and WebAs... by flohofwoe on Thursday February 29, 2024 @03:01AM (#39547310)
At least I was also confused too because I was looking at total_allocated_bytes, but I guess that includes allocations that have been freed.
Re:Talc – A fast and flexible allocator for no_std and WebAs... by sfbea on Thursday February 29, 2024 @03:09AM (#39547351)
[Author of talc] Glad this feature is proving useful. Seeing this makes me think I should implement a better-looking Display implementation than the default Debug impl though. Something for the next update ^-^