4 ms·
A company I was at created huge arrays of data structures, many of which contained nested arrays of data structures, which were eventually serialized and rpc'd
by dustmop 17y ago
A company I was at created huge arrays of data structures, many of which contained nested arrays of data structures, which were eventually serialized and rpc'd to another server. Since this was written in C, and they felt malloc was too hard to do correctly, every structure was stack allocated, using a MAX_SIZE number of elements per array, all memset'd to zero.
It didn't take long til everything started crashing from buffer overflows, so they just increased each MAX_SIZE definition to some ridiculously huge value. This made some of the top level data structures hundreds of megabytes. Developers complained that memset would take multiple seconds to run, and so they suggested just removing the memset calls to make the code "more efficient". Another developer suggested replacing all calls to "abs" with "if (n < 0) { n = -n }" because it would also be faster. I quit soon after that.