The issue, I’d say, is that the docs for map.Clear() and presumably also map.Values() don’t mention that the running time is proportional to how large the map has ever been, instead of being proportional to how large the map currently is. Precise running time is an implementation detail that’s liable to change across versions, but asymptotic running time is important to document because programmers rely on it (in this case, incorrectly).
Hidden memory use by container like objects is such a perennial source of performance problems. I remember a recentish article about Rust vectors that were shrunk resulting in a lot of overhead because the underlying allocation was kept around. And for substrings, Java used to return a reference to the underlying string to avoid copying, but reversed course because it was too common for you to have a 5 character string retaining a multi-kilobyte blob of XML.
Not sure if this is the Rust Vec issue you’re remembering but it was a wake-up call for me given how surprising the buffer reuse was. I was overcorrecting with into_boxed_slice() quite a bit afterwards. https://lobste.rs/s/ys62zs/identifying_rust_s_collect_vec_memory
The first result in a Google search for stan gen-z meaning told me that stan is a combination of stalker and fan. Didn’t feel right that the author is stalking Go maps.
After reading the post, I think what he means is that he supports clearing maps. No cap?
The issue, I’d say, is that the docs for
map.Clear()
and presumably alsomap.Values()
don’t mention that the running time is proportional to how large the map has ever been, instead of being proportional to how large the map currently is. Precise running time is an implementation detail that’s liable to change across versions, but asymptotic running time is important to document because programmers rely on it (in this case, incorrectly).Hidden memory use by container like objects is such a perennial source of performance problems. I remember a recentish article about Rust vectors that were shrunk resulting in a lot of overhead because the underlying allocation was kept around. And for substrings, Java used to return a reference to the underlying string to avoid copying, but reversed course because it was too common for you to have a 5 character string retaining a multi-kilobyte blob of XML.
Not sure if this is the Rust Vec issue you’re remembering but it was a wake-up call for me given how surprising the buffer reuse was. I was overcorrecting with
into_boxed_slice()
quite a bit afterwards. https://lobste.rs/s/ys62zs/identifying_rust_s_collect_vec_memoryOn god, I didn’t know about the new-ish
clear
builtin. https://tip.golang.org/doc/go1.21#languageAny custom helpers I’ve written for this will get yeeted into the sun.
The title is indeed tortuous!
The first result in a Google search for stan gen-z meaning told me that stan is a combination of stalker and fan. Didn’t feel right that the author is stalking Go maps.
After reading the post, I think what he means is that he supports clearing maps. No cap?
“stan” isn’t gen Z slang, it’s millennial. It’s from an Eminem song.
Nice. Didn’t know that!
No cap.
Oh I was trying to use
nocap
with low confidence.:[ I have failed you.