204 points · by vgt · 10y ago · 77 comments
Note that this sort [in 2012] was 500 times larger than the
GraySort large-scale requirement and twice as fast in
throughput as the **current 2015** official GraySort winner.
(emphasis mine)Also, part of the point of a Google style interview is to keep pushing you to the point where your ability fails, then push in another direction to the point your ability fails. That way, they get an idea of the dimensions of your skillset. The vast majority of the people I recommended hiring didn't answer the questions perfectly.
Or, someone could not quite put enough thought into the integer encoding for Protocol Buffers. The encoding actually used is that the first bit of every byte is a flag for if there's a next byte, for a maximum of 10 bytes. The only advantage to this over encoding the length of the integer as the number of leading ones in the first byte (like UTF-8) is if they want the option to have the option later of a forward-compatible encoding for longer integer types, without just supporting multi-precision integers as byte arrays. If you slide all of those flag bits to the first byte, you don't have any more or any fewer flag bits, so it takes as much space, but you can use a jump table and the ability to use native 8-byte and 4-byte simple loads instead of many more masking operations and conditional branches. Giving up on anything longer than int64_t means that the maximum encoding length becomes 9 bytes instead of 10.
One day, the speed of the indexing system just dropped in half. It turns out that someone wrote a job that used machine learning to generate a bunch of regexes for some signal. They were recompiling the regexes for every page in the index. Google really needs most of their engineers that will naturally spot this kind of thing in code reviews, because if every engineer on the indexing team made a mistake like that once a year, the indexing system would always run at half speed, sometimes even 1/3 or 1/4 speed.
The indexing system uses as much electricity as a small town. The tiniest of improvements can mean thousands of dollars per year in savings.
Yes, but this has almost zero bearing on the actual interview. Being able to avoid this in real life means that you measure twice and cut once, you pay attention, and you ask for help and training. Being able to do something similar with dynamic programming or tree riddles in an interview has absolutely nothing to do with those longer-view skills.
> Google really needs most of their engineers that will naturally spot this kind of thing in code reviews, because if every engineer on the indexing team made a mistake like that once a year, the indexing system would always run at half speed, sometimes even 1/3 or 1/4 speed.
Again, this has nothing to do with puzzle interviews. In this case, you could hire smart people almost independently of whether they had encountered certain data structures before, and certainly without much concern about how fast they could spot things like this in an interview setting. And instead, hire for general aptitude, and then invest in training someone to be able to spot these things to the necessary degree.
Even though you can provide impressive-seeming examples of problems where minor tweaks in complexity or subtle implementation-specific points about data structures can result in huge problems, it's still not supportive of whiteboard-hazing style interviews that test more for interview aptitude than anything else.
After all, whoever it was that wrote the ML regex job, that person passed the interviews (and that person may have rightfully passed the interviews and deserved to work for Google, even after this later evidence that they weren't careful enough in one case).
I mean, heck, something like this? They interview multiple magnitudes of people necessary for this kind of job. I respect it as a hedge, but it probably also takes people out of the industry who could do more vital work someplace else.
I can't even begin to tell you how valuable I consider this approach to be...pushing (or leading) a candidate in every conceivable direction until failure is reached or limits are exposed...
HR professionals in almost any profession would benefit from implementing this technique to the extent that their resources allow...most don't have the luxury of time...
Example: As a member of a non-profit board I was once tasked with performing screening interviews for 5 candidates who were applying for a Camp Ranger position at one of the organization's youth camps...
I was not an HR expert then (or now), so I jotted down a few interview questions and scheduled interviews with the candidates...each one to begin at 8:00am at the site, and to last as long as it took...one per day...
I simply walked around the site, visited with the candidates, asked about their experience, and did everything I could to encourage them to "reveal" themselves...
I eliminated 2 candidates by around 10:00am, 2 more around 11:00am, and ended up driving to town for a burger lunch with the 5th...I later recommended the fifth...
He was hired, and ended up doing an incredible job...
I ended up giving other board members the impression that I knew what I was doing...at the time I most certainly did not...but I filed that lesson away...
I am convinced that a commitment to open-ended interview time, combined with "soft" skills probing, are critical if you want to properly evaluate candidates...
Fun facts: those are commonly known as "vbytes." They are the slowest kind of variable width integer encoding. The simplest (naive, and generally considered "wrong") implementations of variable-width-by-continuation-bits uses 10 bytes maximum. A proper implementation uses 9 bytes maximum.
There's actually no reason to ever use 10 bytes in this encoding. If you use 10 bytes, that means your last byte only holds one bit of actual user data. That's not very cool. But, your next-to-last byte holds seven bits of user data and one bit of metadata. We can easily say "if we're at the next to last byte, don't use metadata, just use all the bits we need." All you have to do is say "if we are currently at 9 bytes, don't use a 10th byte, just use this 9th byte directly." bam. Your 9th byte now has 8 bits of user data and you don't roll over a useless 10th byte with one bit of data.
The "slide all continuation bits into the first byte" sounds like a trick, but it's really using a TLV encoding where the first byte just holds a number between 1 and 8, so the entire integer+metadata is now [1 type byte][1 to 8 user data] = 2 to 9 bytes total. Using this scheme also kills any "1 byte, standalone, variable width integer" capability (unless you're storing partial values in the first T/L byte, but then that limits you to a much lower max value for one byte).
0xxxxxxS : 1 byte, 7 bits of data, -64 to 63
10xxxxxx xxxxxxxS : 2 bytes, 14 bits of data, -8192 to 8191
110xxxxx xxxxxxxx xxxxxxxS : 3 bytes, 21 bits of data, -(2^20) to 2^20 -1
1110xxxx xxxxxxxx xxxxxxxx xxxxxxxS : 4 bytes, 28 bits of data, -2^27 to 2^27-1
... and so on.
int64_t zigzag_decode(uint64_t in) {
/* Signed right-shift is implementation-defined behavior in C */
COMPILE_TIME_ASSERT( (1LL << 63) >> 63 == -1, compiler_uses_signed_arith_shift );
return (int64_t) ((((int64_t) in << 63 ) >> 63 ) ^ (in >> 1));
}
You can actually get slightly more dense packing using an encoding that doesn't have any non-canonical encodings by adding a length-dependent constant before the zigzag decoding step, but that's a bit more complicated to explain, and allows some 9 byte encoding values that won't fit in an int64_t.You can get the best of both worlds. The way to do it is: separate continuation bits (1's) from data bits with a 0. This gives identical encoding-length characteristics as what you are calling "vbytes" (1 byte can encode 0-127, 2 bytes can encode 128-16383, etc) while still front-loading the continuation bits.
But, it's largely guestimates anyway. It's hard to come up with good metrics of employee performance that correlate well to company performance and even harder to come up with interview questions that have good predictive power for those metrics.
Ideally, they'd relax the hiring criteria and all employees would start as 1-year or 2-year contractors. On-job performance is the best indicator of on-job performance.
I mention this instance largely because my friends at the big G tell me such a question is generally frowned upon, and not part of standard practice, (So I don't feel bad speaking openly about it) but more importantly it gives me a way to see how people can get a skewed perspective on a company given a... unique interview question when the overall guidance within the corp wouldn't align to asking that.
"Within the last 10 years" covers several generations of refinement to the interview process. I'd suggest forgetting about anything more than a couple of years old.
The major thing to keep in mind is that these days, your recruiter will ask you up front what subject areas you are strongest in, and you should expect to get interviews about those things.
There is a (surprising?) latitude given to interviewers to ask their own questions however, and the best advice I could give to interviewers and interviewees is that the question should really just be a seed to a good technical discussion.
Implementing a well known data structure is pretty far removed from `deep algorithms' and `high theory'.
Apache Spark completed a 1PB sort on 190 EC2 (i2.8xlarge) instances in 234 mins. Google did their 2011 1PB sort on 8000 computers in 33 minutes.
Moore's law is at work here and the results aren't very comparable but it would be interesting to see a head-to-head test on similarly speced clusters.
[1] https://databricks.com/blog/2014/10/10/spark-petabyte-sort.h...
Fun ways in which internal Google tech makes its way to Google Cloud services.
We haven’t found a single use case for the problem as stated.
Impressive nonetheless.References
1. "Playing a Trick on Uncertainty" by Thomas Bruss, page 7 of http://www.emis.de/newsletter/newsletter50.pdf
2. "Tom Cover’s Number Guessing Game" by Robert Snapp, http://www.ibrarian.net/navon/paper/Tom_Cover_s_Number_Guess...
3. "Who discovered this number-guessing paradox?", https://math.stackexchange.com/questions/709984/who-discover...
Do anyone has a real world use case of global sorting other than top-k?
http://www.lanl.gov/projects/trinity/specifications.php
They're claiming 87.0 TB/min on an 80PB filesystem, relative to Google's 36.2 TB/min.
Even if it isn't, it's unreasonable to expect the world to stop spinning in the interim.
If a superintelligent AGI is born tomorrow, it might just establish itself as a singleton, prohibit other AGIs from exisiting, and then take an indefinite vacation. If that happens, we'll continue to work on seemingly mundane, non-important problems (such as this one) for humanity's foreseeable future.
Don't forget that Google owns DeepMind. If there was a way to divine who's closest to AGI at the present time, the answer would probably be them (even if arrival is ultimately far off).
So is working on antigravity, free energy, and backwards time travel, but people don't do that because they are no reasonable approaches we can try.
Glorifying "AI AI AI" is silly because — there are no approaches we can try. Sure, we can identify ten million images per second, but none of that involves the least bit of "thinking."
Get back to us when you have an algorithm for love and art and petrichor.