Live data from Hacker News

Searching 20 GB/sec: Systems Engineering Before Algorithms

blog.scalyr.com

61–70 of 87 posts

Re: Searching 20 GB/sec: Systems Engineering Before Algorithms

#61
post #3

This comes up in my work modestly frequently, generally with a slightly different scenario for the tradeoff between "complicated and considered" versus "cheap and dirty but gets the job done." e.g. We could spend 3 weeks using feature vectors and backtesting against prior data to figure out what signals accounts which are likely to churn send (for the purpose of proactively identifying them and attempting to derisk t…

I will always pick the cheap and dirty option until the project is at a stage where you have a lot of breathing room. Simple code trumps fancy code in reality where you don't have a large team, and you don't have a lot of time and you need something that works even if it's only half as efficient a solution.

this is the point where I say you won't get breathing room if your code is all quick and dirty. There is a balance between quick and dirty and well-formed and not needing tending every few weeks.

Just do high quality code that will remain maintainable into the future. If the business feels that has too much of a financial or time penalty the business needs to find money to pay for more high quality (slower) developers, or to find a different you.

Don't take someone else's problem / role on as your own to solve - it won't help you or them.

Re: Searching 20 GB/sec: Systems Engineering Before Algorithms

#62

Earlier quoted context omitted.

> The problem with grep was that opening and scanning lots of small files apparently wasn't something that Windows was optimized for. It's something hard disk drives were not optimized for.

Windows is (or at least was) a dog when it comes to this even if the files are in the cache. Like barrkel said, the number I quoted was for the case when the OS doesn't hit the drive.

Random rant time!

You have to code for Windows just so. Dear POSIX people in general, there is more to cross platform coding than being able to build it with cygwin.

Every grep I've used on Windows handles wildcards, so it must be doing the expansion itself. The right way to do this sort of thing on Windows is to call FindFirstFile/FindNextFile, which is a cross between readdir and stat in that each call returns not only the name of one directory entry that matches the pattern (as per readdir+fnmatch) but also its metadata (as per stat). So, if you were going to call readdir (to get the names) and then stat each name (to get the metadata), you should really be doing all of it in just this one loop so that each bit of data is retrieved just the once.

But this is exactly what POSIX programmers would seemingly never, ever do. Probably because doing it that way would involve calling a Win32 function. Well, more fool them, because getting this data from FindFirstFile/FindNextFile seems pretty quick, and getting it any other way seems comparatively slow.

I cobbled together a native Win32 port of the_silver_searcher a while ago and it was about twice as fast as the stock EXE thanks to retrieving all the file data in one pass. In this case the readdir wrapper just needed to fill in the file type in the dirent struct; luckily it seems that some POSIX-style systems do this, so there was already code to handle this and it just needed the right #define adding. (I have absolutely no idea why MingW32 doesn't do this already.)

Prior to switching to the_silver_searcher, I used to use grep; the grep I usually used is the GNU-Win32 one (http://gnuwin32.sourceforge.net/packages/grep.htm), and it looks to call readdir to get the names, and then stat to get each name's details. I checked that just now, and after all those years I can finally imagine why it's so slow.

GNU-Win32 find is really slow, too.

Re: Searching 20 GB/sec: Systems Engineering Before Algorithms

#63
I've implemented a brute-force search with an exponential algorithm, in a context where the user would want instant results. Basically, I implemented a bipartite graph producing algorithm that took the "obvious, low hanging fruit" first, and only worked for a set amount of time. This produced a "sloppy matching" tool that did most of the user's busy work for matching natural gas coming from "upstream" and going to points "downstream." Then the user could eyeball a few optimizations and put those in by hand.

I've also implemented a "web search" that was just a complete scan through a text file. But this was back in 1997, and the amount of data we had didn't justify anything more complicated.

Re: Searching 20 GB/sec: Systems Engineering Before Algorithms

#64
post #42

Earlier quoted context omitted.

Amazing how much work 'simple' is :-) I am reminded of John Carmack's comment on Oculus - he was amazed that the hardware had the power but the headsets performed badly - then he looked at the code and saw seas of abstractions on abstractions. Good luck stripping out the layers guys !

Has he written anything (or talked) about this experience or was it just a brief comment? I'd love to read it if he did.

I remember reading "Latency Mitigation Strategies", by Carmack. It doesn't mention the Oculus except in an acknowledgment at the end, but it might be about the same thing lifeisstillgood is talking about:

http://www.altdevblogaday.com/2013/02/22/latency-mitigation-...

HN discussion: https://news.ycombinator.com/item?id=5265513

Re: Searching 20 GB/sec: Systems Engineering Before Algorithms

#65
The article’s title is: “Searching 20 GB/sec: Systems Engineering Before Algorithms”.

Current title on Hacker News is misleading as the “simple code” is not compared against any “fancy algorithms”. This is about not spending time devising fancy algorithms when the simple O(n) approach is good enough.

Re: Searching 20 GB/sec: Systems Engineering Before Algorithms

#66
post #3

This comes up in my work modestly frequently, generally with a slightly different scenario for the tradeoff between "complicated and considered" versus "cheap and dirty but gets the job done." e.g. We could spend 3 weeks using feature vectors and backtesting against prior data to figure out what signals accounts which are likely to churn send (for the purpose of proactively identifying them and attempting to derisk t…

I think it depends on the context. Machine Learning and statistics isn't magic, and you definitely don't want to use it for the wrong reasons if you can figure it out with domain knowledge.

I would just like to throw in here if you are going to be featurizing users to do churn prediction, I would highly recommend doing a whole data pipeline and do profit curves.

A data driven approach is only as good as the algorithms used.

If you used profit curves to augment churn prediction (churn prediction is a pre req), you can figure out how much a user is actually worth bringing back. This also allows you to figure out an optimal budget to profit ratio on a cost of a user.

That being said, use it only if you have enough data to be accurate. And also only use it for the right reasons. Done routinely, I believe it can be a great investment.

Re: Searching 20 GB/sec: Systems Engineering Before Algorithms

#67
post #65

The article’s title is: “Searching 20 GB/sec: Systems Engineering Before Algorithms”. Current title on Hacker News is misleading as the “simple code” is not compared against any “fancy algorithms”. This is about not spending time devising fancy algorithms when the simple O(n) approach is good enough.

Thanks. We missed that one.

Submitters: It's against the guidelines to rewrite titles to put your own editorial spin on things. Please don't.

Re: Searching 20 GB/sec: Systems Engineering Before Algorithms

#68
post #3

This comes up in my work modestly frequently, generally with a slightly different scenario for the tradeoff between "complicated and considered" versus "cheap and dirty but gets the job done." e.g. We could spend 3 weeks using feature vectors and backtesting against prior data to figure out what signals accounts which are likely to churn send (for the purpose of proactively identifying them and attempting to derisk t…

I get the feeling this is more "era-defining" than that... What hit me was the "Processors are so fast now we can Brute force grep over 100GB in a second". We are entering a world where 20TB on a magnetic disk is viable, but randomly accessing that data could take months to extract. So how we store data on disks will become vitally important to how we use the data - not unlike tape drives of pre-1980s era where rewin…

When analyzing big data algorithms, the amount of computation by the CPU is often irrelevant. It's ignored. What matters is disk reads and disk access patterns. If you can make a scanning algorithm that start at byte 0, and reads everything once in a sequential manner, you can make O(n^4) computation with it. The CPU will be long finished with the inefficient computation by the time the next set of data is retrieved from the (spinning) disk.

And on using Java. It's actually pretty fast, and certainly fast enough for a prototype. Once you have the stack build, you can benchmark and optimize the bits that needs to be optimized, usually this means C or handcrafted ASM.

Re: Searching 20 GB/sec: Systems Engineering Before Algorithms

#69

I wrote a simple code search tool a number of years ago that had the ability to run arbitrary regex queries on a codebase, much like a recursive grep. I was working on a medium sized codebase and our primary platform was Windows. The problem with grep was that opening and scanning lots of small files apparently wasn't something that Windows was optimized for. If the file cache was cold, a simple search could turn int…

It's not unlike how we do free text search at my work. We collect all aggregate information for an item, concatenate it and store it in one table. Searching is amazingly fast. So fast in fact that we've had several clients open a ticket claiming that the search is broken. "There is no way you can search for a random text string in our million documents database this fast".

Re: Searching 20 GB/sec: Systems Engineering Before Algorithms

#70
Reminds of the way LMAX achieve high throughput and low latency on their trading exchange. One of the key points is that they use parallelism but not concurrency. Keep your threads busy doing one thing only and avoid synchronising with other threads. No blocking, no queues and they achieve >100K messages/s.

Where they do need pass messages between threads they use the famous LMAX Disruptor which keeps data copying and blocking to a minimum.

Post reply on HN