6 ms·
Blog author here! Thanks to HN for warning me about sscanf at exactly the right time – within a day of me trying to load some ASCII STLs and noticing it was sl
by mkeeter 6y ago
Blog author here! Thanks to HN for warning me about sscanf at exactly the right time – within a day of me trying to load some ASCII STLs and noticing it was slow...
Linked deep in the Twitter replies [1], there's an open glibc issue about this, dating back to 2014:
https://sourceware.org/bugzilla/show_bug.cgi?id=17577 https://sourceware.org/bugzilla/show_bug.cgi?id=17577
C doesn't have any requirements on the complexity of sscanf, so it might not be a bug per se, but it's certainly... a pitfall.
[1] https://twitter.com/impraxical/status/1367194430835425283 https://twitter.com/impraxical/status/1367194430835425283
- rkagerer 6y agoHey, Matt, neat to see you here and congrats on making the front page! Recognize you from the Formlabs forums & conferences. Love that notion of professional empathy underscoring your message in the blog post.
- mkeeter 6y agoHey RK! Thanks for the kind words – hopefully I'll see you again, once we're back to holding in-person events!
- koalahedron 6y agoI know Matt too, primarily from him rejecting my Libfive PRs for being "too 1337". But seriously, Matt, I might have a project for an in-person event regarding printing robots. Stay tuned--to what channel I don't know.
- BenFrantzDale 6y agoIMO the lack of a complexity requirement is a bug in the C standard. And really it’s a bug in the implementation(s?) too. If it can be done on O(1), shame on library authors for doing it in O(n). If you want programmers to trust library authors, don’t do this to us. Maybe std::from_chars FTW?
- ironmagma 6y agoShouldn’t we just come clean and admit to ourselves that there is no such thing as the C standard? There is a collection of loosely related languages that look similar and that collectively we call C, but really they’re all completely different and share almost no interoperability or common characteristics. And those standards that do exist provide almost no ability to reason about your code including things like ordering of statements.
- loeg 6y agoNo, that's complete nonsense. Here's the latest revision of the standard: https://www.iso.org/standard/74528.html https://www.iso.org/standard/74528.html C has had a well-defined memory model since C11, I believe (re: "ordering of statements").
- ironmagma 6y ago> ISO-C11 specifies 203 circumstances that cause undefined behaviors. 203 is enough to make almost every line of code questionable. The result of this is that looking at a simple 3 line C program and being asked whether the program terminates is undecidable without knowing which compiler was used. Null dereference for example is undefined behavior, and could cause a termination or not, depending on the implementation, even if it is known to be standards conforming to C11. [1] https://resources.tasking.com/p/undefined-behaviors-iso-c-their-effect-your-embedded-software-part-1 https://resources.tasking.com/p/undefined-behaviors-iso-c-th...
- Waterluvian 6y agoI love the format of this blog post. Perfect length. Perfect detail. You don't waste words. A good number of images.
- lambda_obrien 6y agoAnd it works without javascript!
- icemelt8 6y agoall blogs work without javascript.
- ignoramous 6y agoI like this blog post but I also happen to quite like long forms like these, too: https://mango.pdf.zone/finding-former-australian-prime-minister-tony-abbotts-passport-number-on-instagram https://mango.pdf.zone/finding-former-australian-prime-minis... / https://apenwarr.ca/log/20201227 https://apenwarr.ca/log/20201227
- komodo009 6y agoThe mango blog post was incredibly entertaining. Thanks for sharing.
- fermienrico 6y agoLove the post, except for the title. It is too click-baity.
- echlebek 6y agoThanks for the great blog post, and congrats on finding that long dormant bug!
- gnyman 6y agoThank you for introducing me to the concept/term Ascetic programming. Not sure how widely used it is, but I find it more fitting for what I try to do than minimalistic or KISS. Also, it is great to see someone write > I noticed that ASCII STL loading was really quite slow. > From startup to showing the window, it took over 1.8 seconds! I always find pleasure seeing projects which highlight just how fast modern computers really are.
- gnyman 6y agoRe-read my comment and to be clear, the quote and the last paragraph are not related. The last sentence was meant to refer to the Erizo project as a nice single purpose high performing tool, not as a comment to the bug that made it slow.
- chromanoid 6y agoWhen looking at loading performance of STLs, you may want to look at this: https://papas-best.com/stlviewer_en https://papas-best.com/stlviewer_en
- froh 6y agoprintf and scanf match nicely with their format specifiers, so the serialization and deserialization can be maintained nicely in lockstep. to avoid the quadratic overheating sttlen you can simply use fmemopen(3), which makes the temporary sscanf FILE object explicit and persistent for the whole parse, and needs just one strlen call. https://news.ycombinator.com/item?id=26343149 https://news.ycombinator.com/item?id=26343149