Repository navigation
v2.1: Packing Cows 🐮
The StringTape crate now also provides "Cows" classes for large arrays of references pointing into parent Copy-On-Write objects, allowing for the handling of larger datasets. Why? In addition to storing 3 pointers for every String instance, you often need another 2-4 pointers per entry in your heap. Assuming most English words are under 8 bytes long, storing an extra 6 pointers on a 64-bit machine results in a 7x memory usage amplification. So choose your data structures wisely!
let doc = fs::read_to_string("enwik9.txt")?; // 1.0 GB
let words = doc.split_whitespace(); // ~ 160 M words
let buffers = words.map(str::as_bytes);
let _ = Vec::<String>::from_iter(words); // + 7.1 GB copied ❌
let _ = CharsTapeAuto::from_iter(words); // + 1.3 GB copied ✅
let _ = Vec::<&[u8]>::from_iter(buffers); // + 1.9 GB copy-less ⚠️
let _ = BytesCowsAuto::from_iter_and_data( // + 0.7 GB copy-less ✅
buffers,
Cow::Borrowed(doc.as_bytes()),
);Minor
- Add: Slice classes (3666059)