212 points · by goranmoomin · 6y ago · 53 comments
BSD-license, and they accept contributions. I wonder if they accept any flags that would allow optimization on AMD processors.
[1]: http://intel.github.io/hyperscan/dev-reference/api_constants...
The mechanism is trivial to control IIRC and would not be difficult to patch. It is, after all and unlike MKL, open source.
> https://github.blog/2018-10-17-behind-the-scenes-of-github-t...
Honnestly, once you understood (some of...) the math/automata details, this is by far one of the best big codebase ever written.
So clean, beautiful, powerful. I've learned a lot from this codebase.
Does anyone know more codebases as well written as Hyperscan ?
Can you disclose how/why you were reading Hyperscan source for work? Just curious, no agenda.
It was for a (now failed) startup selling IPS appliances. What really helped us in the end was that we could run the runtime in C (C++ was not possible); however the compiler/tooling we used was fairly old (...) so I had to dig into the codebase details to make it work.
As a side note, if I had to say something bad about Hyperscan, it would be the lack of high level documentation. I don't know now, but back then only a couple of blog articles available... I always had been curious : was it something intended to prevent copycats ? Lack of time ? Why not try to explain more the high level math/automata details ?
If the high level documentation were to be improved, I'm pretty sure the number of companies integrating Hyperscan would increase, hence Intel sales would increase (since it has been bought by Intel ;)
Later: well, there is a Hyperscan paper and there may be more material coming out later.
Also, not to be a jerk, but a lot of people claim that they will read/understand/use this kind of documentation and my experience was that only a fraction actually do, and of those fraction, most of them don't behave in a way that's actually useful enough to justify having made all those docs. One is more likely to wind up with people kibitzing and making inane tweaking suggestions ("use more NFAs! no, use more DFAs"); less likely is meaningful OSS contributions or using the software when they might not have before.
https://intel.github.io/hyperscan/dev-reference/compilation....
I use FLRE: https://github.com/BeRo1985/flre
That is also an impressive project, with multiple subengines from which it chooses the fastest one. All written by one guy. Basically no documentation though
I wonder how the performance compares
The major headache is the prospect of loops that are bigger than 1 character position - these aren't as trivial to express (I have ideas, naturally).
I don't know how well this fits in with Tensorflow - it may be too finegrained? But of course, getting onto custom hardware can yield massive speedups.
Also, the limitations of Hyperscan might be quite noticeable. It doesn't support all pcre facilities (e.g. capturing and arbitrary lookaround). It has a considerable compile time - I wouldn't want to use Hyperscan to grep short files! Justin Viiret (another ex-Hyperscan team guy) has a blog post about this comparing our relatively heavyweight optimization strategy with RE2 (which gets down to the business of scanning a lot quicker than we do). You can find it here: https://01.org/hyperscan/blogs/jpviiret/2017/regex-set-scann...
(sorry about the giant 01.org "dickbar", we couldn't control that)
The upshot is that most people looking for big collections of regexen in huge amounts of data aren't really running 'grep' type tools. If someone wanted to do that, like I said, it would be a good project.
It would be an interesting project to add Hyperscan support to it. You would get all the extra goop you mention for free. I would be happy to give guidance on that if anyone's interested.
30 regex and 1 meg of data for example.
I'm somewhat curious as I have a couple of scraping things I do where I can compile the regex once and keep it hanging around (or save to/load from disk if that's feasible) for 3 to 5 minutes at a time.
However, the compile times of HS for 30 regexes might be not entirely trivial (maybe a second, probably less). A megabyte you'd probably see benefits but I think the benefits might not be drastic.
Probably the best way to find out would be to fire up hsbench (a tool that comes with Hyperscan now), figure out the slightly weird corpus format (sorry) and get some numbers for yourself on your own workload.
For context, see slides 5 and 6 about the history of Hyperscan and Sensory Networks Inc.: https://openisf.files.wordpress.com/2015/11/oisf-keynote-201...
Here is a real history https://twitter.com/joeerl/status/1115990630793207808
I think FPGA could do a great job of achieving worst-case performance by simulating NFAs in a very straightforward fashion (beating s/w). However, no-one does this as the headline numbers are terrible.
The thread you posted contains an assertion by someone who built an FPGA parser with no performance numbers to back it up; the performance comparison may well reflect relative skills with software and hardware as opposed to the limits of software. Interestingly, one of the first responses refers to another project of mine. :-) (simdjson). Unfortunately, given the subsequent posts on the thread, it does not look like the author can provide further details on the system, which is sad.
It often can, because it can clock 50x higher.
And if you want a fair comparison, customize both to the job.
But if you ever need it FPGA instance it is not so expensive as you think https://aws.amazon.com/ec2/instance-types/f1/
Make custom ASIC with non universal algorithm is too expensive.