> The skipto method is a single x86 machine instruction. That’s not always a good thing, especially on modern hardware. And obviously, the “single instruction” doesn’t mean it’ll take bounded time to execute…
Tangentially to your point, here's something I haven't thought about much: when these instructions get an interrupt, I imagine they've updated (r|e)si and (r|e)di, (r|e)cx etc. to reflect where they are in their copy or scan loop. So if you get a page fault in the middle, then the kernel does enormous amounts of work in response to it, then resumes that single instruction, it resumes in the middle of the loop, not th…
New Grad vs. Senior Dev
161–170 of 392 posts
Re: New Grad vs. Senior Dev
#162Imagine that the intern didn't dare to ask such questions. a - he could've gone out thinking that performance doesn't matter. but it certainly does in a piece of code being used daily by thousands of devs. b - he could've thought that the simple implementation is faster but missed the fact that skip is implemented in assembly. c - he could've realized both but missed the why. and these failure scenarios are likely to…
It’s not; the compiler is just fairly decent at transforming string manipulation routines.
Re: New Grad vs. Senior Dev
#163Earlier quoted context omitted.
The open source intrusion detection system Suricata [1] used aho-corasick until intel released hyperscan [2] in open source. Hyperscan is apparently more performant than aho-corasick. If your language can handle the C libraries, have you considered trying hyperscan to see how it compares? [1] https://suricata-ids.org/ [2] https://www.hyperscan.io/
Based on their use of past tense, I’d assume they aren’t interning there anymore.
Re: New Grad vs. Senior Dev
#164Re: New Grad vs. Senior Dev
#165Shockingly, InStr( , "docum") = 0 I'm a dev with some grey hair who feels it would have been useful for all that fantastic domain knowledge from Paterson to get documented in a code comment. I'd love to hear if either of them ever went back and did that?
Re: New Grad vs. Senior Dev
#166I see these senior vs non-senior engineer contrasts pop up a lot. I’m not a huge fan of them. It seems that there is a spectrum of skills an engineer could excel at: programming, infrastructure, managing, planning, etc. I’ve known senior engineers who only excel at a particular skill. I’ve also known senior engineers who are moderately good at many but not particularly good at one. In my experience the only differenc…
Re: New Grad vs. Senior Dev
#167Earlier quoted context omitted.
Thanks for the context. The example you describe supports the meme better. Sorry for being harsh, I got triggered by that code inside the printer, because I've dealt with a lot of dumb "I don't know how SQL joins work, so I'll use my ORM to do it and filter the data in code" cases early in my career, and I have sort of an allergy to that now.
I see this so much in Rails codebases that at this point the two are nearly synonymous in my mind. But maybe I’ve been cursed to work only on bad Rails projects or something and there’s a universe of them out there that aren’t full of that sort of thing.
Re: New Grad vs. Senior Dev
#168Earlier quoted context omitted.
It could be faster than some alternatives under some circumstances. A loop would probably be more code (== icache pressure) and would consume at least a register and a BTB entry.
It's certainly been a while since I last optimized for the original Pentium architecture. Still faintly remember U & V pipes, unexplained causes for stalls, etc. As even nowadays, it would likely depend on the particular algorithm and data set. I'd be surprised if you can't do better than 4 cycles per char for sufficiently long strings. Most likely for short strings, REP SCASB wins due to setup costs. (Actually that…
Or with real vector style with vectorized instructions?
Re: New Grad vs. Senior Dev
#169Most FAANG job interviews would fail you if you did the brute force solution, it seems.
Re: New Grad vs. Senior Dev
#170Earlier quoted context omitted.
It's certainly been a while since I last optimized for the original Pentium architecture. Still faintly remember U & V pipes, unexplained causes for stalls, etc. As even nowadays, it would likely depend on the particular algorithm and data set. I'd be surprised if you can't do better than 4 cycles per char for sufficiently long strings. Most likely for short strings, REP SCASB wins due to setup costs. (Actually that…
> The hypothetical faster-than-rep solution would need to process data in 32-bit chunks, faux vector style. Or with real vector style with vectorized instructions?