←back to thread

698 points jgrahamc | 3 comments | | HN request time: 0.672s | source
Show context
lkoolma ◴[] No.20424229[source]
Might be late, but has anyone in CloudFlare tried to switch away from regex to something more efficient and powerful? Tools like re2c can convert 100s of regexs and CFG into a single optimized state machine (which includes no back tracking, as far as I remember). It should easily handle 10s of millions transactions per second per core if the complete state machine fits into the CPU level 3 cache (or lower), with a bit of optimization.
replies(2): >>20425025 #>>20426568 #
1. edwintorok ◴[] No.20425025[source]
There is also Ragel [0], but I think that in this context deploying regexes as strings is safer than generating code and deploying that code (unless Ragel could generate webassembly).

[0]: http://www.colm.net/open-source/ragel/

replies(2): >>20461012 #>>20461038 #
2. thurston ◴[] No.20461012[source]
Ragel has the advantage that CPU blowups happen at compile time, rather than run-time. Other risks aside, they would have avoided this problem had they been using ragel or something similar to pre-compile their patterns into deterministic machines.
3. thurston ◴[] No.20461038[source]
Sorry I didn't see the parent you were responding too, so my point is actually the same as you already made. Thanks.