You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. aho-corasick
  2. ==
  3. Aho-Corasick parallel string search, using interleaved arrays.
  4. Mischa Sandberg mischasan@gmail.com
  5. ACISM is an implementation of Aho-Corasick parallel string search,
  6. using an Interleaved State-transition Matrix.
  7. It combines the fastest possible Aho-Corasick implementation,
  8. with the smallest possible data structure (!).
  9. FEATURES
  10. --------
  11. * Fast. No hashing, no tree traversal; just a straight look-up equivalent to
  12. matrix[state, input-byte] per input character.
  13. * Tiny. On average, the whole data structure (mostly the array) takes about 2-3 bytes per
  14. input pattern byte. The original set of pattern strings can be reverse-generated from the machine.
  15. * Shareable. The state machine contains no pointers, so it can be compiled once,
  16. then memory-mapped by many processes.
  17. * Searches byte vectors, not null-terminated strings.
  18. Suitable for searching machine code as much as searching text.
  19. * DOS-proof. Well, that's an attribute of Aho-Corasick,
  20. so no real points for that.
  21. * Stream-ready. The state can be saved between calls to search data.
  22. DOCUMENTATION
  23. -------------
  24. The GoogleDocs description is at http://goo.gl/lE6zG
  25. I originally called it "psearch", but found that name was overused by other authors.
  26. LICENSE
  27. -------
  28. Though I've had strong suggestions to go with BSD license, I'm going with GPL2 until I figure out
  29. how to keep in touch with people who download and use the code. Hence the "CONTACT ME IF..." line in the license.
  30. GETTING STARTED
  31. ---------------
  32. Download the source, type "gmake".
  33. "gmake install" exports lib/libacism.a, include/acism.h and bin/acism_x.
  34. "acism_x.c" is a good example of calling acism_create and acism_scan/acism_more.
  35. (If you're interested in the GNUmakefile and rules.mk,
  36. check my blog posts on non-recursive make, at mischasan.wordpress.com.)
  37. HISTORY
  38. -------
  39. The interleaved-array approach was tried and discarded in the late 70's, because the compile time was O(n^2).
  40. acism_create beats the problem with a "hint" array that tracks the restart points for searches.
  41. That, plus discarding the original idea of how to get maximal density, resulted in the tiny-fast win-win.
  42. ACKNOWLEDGEMENTS
  43. ----------------
  44. I'd like to thank Mike Shannon, who wanted to see a machine built to make best use of L1/L2 cache.
  45. The change to do that doubled performance on hardware with a much larger cache than the matrix.
  46. Go figure.