logoalt Hacker News

irdctoday at 5:40 PM4 repliesview on HN

This is why system programming still matters.

Looks like they're missing the obvious optimisation of putting the record data right after the CacheEntry members instead of allocating memory separately though. But that might just be me as a C-programmer talking and not be all that easy in Rust.


Replies

mkeetertoday at 5:51 PM

For the curious, this is technically possible in Rust using a dynamically sized type [1], but in practice is difficult and doesn't really play nice with the rest of the language. The nomicon entry concludes with "Yes, custom DSTs are a largely half-baked feature for now." [2]

[1] https://doc.rust-lang.org/reference/dynamically-sized-types....

[2] https://doc.rust-lang.org/nomicon/exotic-sizes.html

listeriatoday at 6:53 PM

Depends on how the CacheEntry is stored, it's probably stored in a slice of &[CacheEntry] which precludes storing the record data alongside it as the size of each entry must be fixed.

sdcfgytoday at 6:21 PM

System programming always matters. Things are cheap until they aren't one day.

show 1 reply
cobalttoday at 5:57 PM

less ergonomic, but still totally doable