3 ms·
Considered as a naieve problem, inescapably you want to perform a series of multiply and addition phases. For short strings, "just do it" might be slower than "
by ggm 3y ago
Considered as a naieve problem, inescapably you want to perform a series of multiply and addition phases. For short strings, "just do it" might be slower than "look it up in a table". For longer strings, divide-and-conquer would be to chop it into short strings and do the table lookup.
I don't know this is faster than simply doing the "mutiply by ten and add" sequence. I'd have to understand modern ALU behaviour, parallelism, shortcuts, chip cache dynamics you-name-it.
It would all have been so much simpler if we'd made decimal be hex instead. Octal doesn't work as well for me, no idea why. That said, it's much easier to ignore thumbs and count on 4 fingers of each hand than grow another 6
(I read the article. It descended into arcanum of instruction sets and assumptions which post date my DEC-10 ISA lessons, although I recall Digital had BCD instruction handling and a 6 bit byte model in a 36 bit word accordingly. DEC-10 instructions could take many, many clock cycles and have 5 components of from, to, via, because, maybe attached to them)
- mattgrice 3y agoMaybe in the future don't comment on articles until you have read and understand them. And while your comments on DEC-10 and 6-bit bytes might be interesting, there are very few people still working in CS who have seen a DEC-10 outside a museum. I find it always interesting to learn about computers that were obsolete before I wrote my first program, but their performance characteristics were vastly different than what we have today. And current college grads have always lived in a world with 64-bit SIMD machines that can do a scalar multiply in 3-4 cycles. [Edit to add] I don't know why I'm salty about this, but Doug Lemire is real good and doesn't deserve to be blown off, especially not by someone referencing a computer that was obsolete before today's retirement-age CS people were in high school. VAX obsoleted the DEC-10 in 1977.
- jzwinck 3y agoI agree but it's Daniel not Doug.
- mattgrice 3y agoyou are correct, sir. Sorry to Daniel.
- benj111 3y agoI agree with the parent, but from a different angle. If you need to parse integers so quickly, why are you storing them as decimal strings? If you're dealing with a massive CSV why not just compile to a more easily parsable format ahead of time?
- anonymoushn 3y agoBecause we receive them over the wire as decimal strings.
- benj111 3y agoDefine over the wire here then. The article mentions 0.8gb/s to 1.8gb/s throughput. If youre downloading something off the internet, the bottleneck isn't going to be converting the strings to ints. Further if you're downloading that much data, it suggests even more that you should be using a more space efficient representation.
- anonymoushn 3y agoFor trading we focus on latency rather than throughput. We cannot really accomplish much by telling a bunch of other companies to change the format they use to send data to all of their customers.
- benj111 3y agoAh ok, the post didn't mention trading, and that use case didn't occur to me.