{"id":272447,"date":"2016-01-19T16:06:03","date_gmt":"2016-01-19T13:06:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=272447"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=272447","title":{"rendered":"\u041f\u043e\u0438\u0441\u043a \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Hyperscan"},"content":{"rendered":"<p>       \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043e\u043f\u044b\u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b <a href=\"https:\/\/github.com\/01org\/hyperscan\">hyperscan<\/a>. \u0422\u0430\u043a \u0432\u044b\u0448\u043b\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u043f\u0430\u043c-\u0444\u0438\u043b\u044c\u0442\u0440\u0430 <a href=\"https:\/\/rspamd.com\">rspamd<\/a> \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0445 \u043f\u0440\u0430\u0432\u0438\u043b, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f spamassassin \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u044b. \u041c\u043e\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <a href=\"https:\/\/rspamd.com\/doc\/modules\/spamassassin.html\">\u043f\u043b\u0430\u0433\u0438\u043d<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0447\u0438\u0442\u0430\u043b \u044d\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0438 \u0441\u0442\u0440\u043e\u0438\u043b \u0438\u0437 \u043d\u0438\u0445 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e. \u0417\u0430\u0442\u0435\u043c \u043d\u0430 \u044d\u0442\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0438\u0441\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u043e\u0431 \u044d\u0442\u043e\u043c \u044f \u0434\u0430\u0436\u0435 \u0434\u0435\u043b\u0430\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e <a href=\"https:\/\/highsecure.ru\/ast-rspamd.pdf\">\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>).<\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u0445\u043e\u0434\u0435 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e pcre \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0443\u0437\u043a\u0438\u043c \u043c\u0435\u0441\u0442\u043e\u043c, \u0438 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0438\u0441\u044c\u043c\u0430\u0445 \u044d\u0442\u043e\u0442 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. \u0412\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e \u043d\u0430 \u043f\u0438\u0441\u044c\u043c\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 pcre \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043e\u043a\u043e\u043b\u043e \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u0430 (!) \u0442\u0435\u043a\u0441\u0442\u0430. \u0420\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0440\u044e\u043a\u0438, \u0432\u0440\u043e\u0434\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0434\u043b\u044f \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b, \u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 pcre \u043f\u0443\u0442\u0435\u043c \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f jit fast path \u0447\u0435\u0440\u0435\u0437 <strong>pcre_jit_exec<\/strong> \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043e\u043f\u0430\u0441\u043d\u044b\u043c\u0438 \u2014 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0438 \u043e\u0442\u043a\u0440\u043e\u0432\u0435\u043d\u043d\u043e \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438 \u0438 \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c \u00ab\u0431\u0438\u0442\u044b\u0435\u00bb UTF8 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0438 \u043a \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u044b\u043c \u0431\u0430\u0433\u0430\u043c \u0441 \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0435\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 <a href=\"http:\/\/highload.ru\">highload<\/a> \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u0441\u043e \u0421\u043b\u0430\u0432\u043e\u0439 \u041e\u043b\u044c\u0445\u043e\u0432\u0447\u0435\u043d\u043a\u043e\u0432\u044b\u043c, \u0438 \u043e\u043d \u043c\u043d\u0435 \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 hyperscan. \u0414\u0430\u043b\u0435\u0435 \u044f \u043f\u0435\u0440\u0435\u0439\u0434\u0443 \u043a \u0441\u0443\u0442\u0438 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<h2>\u041a\u0440\u0430\u0442\u043a\u043e \u043e hyperscan<\/h2>\n<p>  Hyperscan \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u0438\u043d\u043d\u043e\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439, \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u043e\u043d \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430\u0436\u0438 deep packets introspection (DPI) \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u041d\u043e \u0432 \u043e\u043a\u0442\u044f\u0431\u0440\u0435 \u0443\u0436\u0435 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0433\u043e\u0434\u0430 Intel \u0440\u0435\u0448\u0438\u043b \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0435\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u0434\u0430 \u0435\u0449\u0435 \u0438 \u043f\u043e\u0434 BSD \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0435\u0439. \u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 C++ \u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c boost&#8217;\u0430, \u0447\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u0438 \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 (\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u0434\u0430\u043b\u0435\u0435). \u0412\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f hyperscan \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f non-backtracking \u0434\u0432\u0438\u0436\u043e\u043a \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 \u0431\u0430\u0437\u0435 \u043d\u0435\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0430 (NFA). \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0432\u0441\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043d\u044b\u0435 \u0434\u0432\u0438\u0436\u043a\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0443 \u0436\u0435 \u0441\u0430\u043c\u0443\u044e \u0442\u0435\u043e\u0440\u0438\u044e \u0438 \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u044f\u0441\u044c \u043e\u0442 backtracking \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e (\u0447\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u0430). \u0421\u0430\u043c\u043e\u0439 \u0432\u0430\u0436\u043d\u043e\u0439 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u00ab\u0444\u0438\u0448\u043a\u043e\u0439\u00bb hyperscan&#8217;\u0430 \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c <strong>\u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e<\/strong> \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u0430\u0434 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u043c. \u041d\u0430\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432 pcre \u2014 \u044d\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c <i>|<\/i> \u0432 \u044d\u0442\u0430\u043a\u0443\u044e \u00ab\u043a\u043e\u043b\u0431\u0430\u0441\u0443\u00bb: <\/p>\n<pre>(?:re1)|(?:re2)|...|(?:reN)<\/pre>\n<p>. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u2014 \u0432\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430\u0439\u0442\u0438 <strong>\u0432\u0441\u0435<\/strong> \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435, \u0447\u0442\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435. Hyperscan \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0436\u0435 \u043d\u0435 \u0442\u0430\u043a \u2014 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 callback \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 (\u043f\u0440\u0430\u0432\u0434\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f), \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0445\u0435\u043c\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/537\/c6c\/688\/537c6c68898cb1b6ac781eee6e4d78a7.png\"\/><\/p>\n<h2>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 hyperscan<\/h2>\n<p>  Hyperscan \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439: \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0438, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u0432\u0438\u0436\u043a\u0430. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u2014 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u043c\u0435\u0435\u0442 \u0432\u0437\u044f\u0442\u044c \u043f\u0430\u0447\u043a\u0443 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0435 NFA \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 NFA \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, AVX2. \u042d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0442\u0440\u0443\u0434\u043d\u0430\u044f \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0437\u0430\u0442\u0440\u0430\u0442\u043d\u0430\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0414\u0432\u0438\u0436\u043e\u043a \u043f\u043e\u0438\u0441\u043a\u0430 \u2014 \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0438 \u043e\u043d\u0430, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f NFA \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435. \u0414\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u0431\u043e\u0440\u044b \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <i>libhs_runtime<\/i>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 compiler+engine <i>libhs<\/i>. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0441\u043e\u0431\u0440\u0430\u0442\u044c hyperscan, \u0447\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0432\u0435\u0436\u0438\u0439 boost (\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f 1.57). \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435\u043c, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0441 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u043c\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u0438\u0433\u0430\u043d\u0442\u0441\u043a\u043e\u0439 \u2014 \u043e\u043a\u043e\u043b\u043e 200Mb \u043d\u0430 \u043c\u043e\u0435\u043c \u043c\u0430\u043a\u0431\u0443\u043a\u0435. \u0410 \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0435\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u043e\u0432 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0439\u043e\u043d\u0435 200Mb. \u0415\u0441\u043b\u0438 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043d\u0435 \u043d\u0443\u0436\u043d\u044b, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c hyperscan \u0431\u0435\u0437 \u043d\u0438\u0445, \u0443\u043a\u0430\u0437\u0430\u0432 <\/p>\n<pre>-DCMAKE_BUILD_TYPE=MinSizeRel<\/pre>\n<p> \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 cmake.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u0434<\/h2>\n<p>  \u0417\u0430\u0442\u0435\u043c \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c hyperscan \u0438 pcre, \u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u043e\u0447\u0435\u043d\u044c \u0433\u0440\u0443\u0431\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c (\u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e \u2014 \u044d\u0442\u043e \u043a\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0432\u043f\u043e\u043f\u044b\u0445\u0430\u0445 \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u044b\u0445 \u043f\u0440\u0435\u0442\u0435\u043d\u0437\u0438\u0439 \u043a \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0443).<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f pcre \u0438 hyperscan<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;fstream&gt; #include &lt;vector&gt; #include &lt;stdexcept&gt; #include &lt;algorithm&gt; #include &lt;set&gt; #include &quot;pcre.h&quot; #include &quot;hs.h&quot; #include &lt;time.h&gt; #ifdef __APPLE__ #include &lt;mach\/mach_time.h&gt; #endif  using namespace std;  double get_ticks(void) {     double res;  #if defined(__APPLE__)     res = mach_absolute_time() \/ 1000000000.; #else     struct timespec ts;     clock_gettime(CLOCK_MONOTONIC, &ts);      res = (double)ts.tv_sec + ts.tv_nsec \/ 1000000000.; #endif      return res; }  struct pcre_regexp {     pcre* re;     pcre_extra* extra;      pcre_regexp(const string& pattern)     {         const char* err;         int err_off;          re = pcre_compile(pattern.c_str(), PCRE_NEWLINE_ANYCRLF, &err, &err_off, NULL);         if (re == NULL) {             throw invalid_argument(string(&quot;cannot compile: '&quot;) + pattern + &quot;' error: &quot; + err + &quot; at offset: &quot; + to_string(err_off));         }          extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, &err);         if (extra == NULL) {             throw invalid_argument(string(&quot;cannot study: '&quot;) + pattern + &quot;' error: &quot; + err + &quot; at offset: &quot; + to_string(err_off));         }     } };  struct cb_context {     set&lt;int&gt; approx_re;     vector&lt;pcre_regexp&gt; pcre_vec; };  struct cb_data {     struct cb_context* ctx;     vector&lt;int&gt; matched;     const std::string* str; };  bool remove_uncompileable(const string& s, int id, struct cb_context* ctx) {     hs_compile_error_t* hs_errors;     hs_database_t* hs_db;      if (hs_compile(s.c_str(), HS_FLAG_ALLOWEMPTY, HS_MODE_BLOCK, NULL, &hs_db, &hs_errors) != HS_SUCCESS) {         cout &lt;&lt; &quot;pattern: '&quot; &lt;&lt; s &lt;&lt; &quot;', error: &quot; &lt;&lt; hs_errors-&gt;message &lt;&lt; endl;          if (hs_compile(s.c_str(), HS_FLAG_ALLOWEMPTY | HS_FLAG_PREFILTER, HS_MODE_BLOCK, NULL, &hs_db, &hs_errors) != HS_SUCCESS) {             cout &lt;&lt; &quot;completely bad pattern: '&quot; &lt;&lt; s &lt;&lt; &quot;', error: &quot; &lt;&lt; hs_errors-&gt;message &lt;&lt; endl;             return true;         } else {             ctx-&gt;approx_re.insert(id);         }     } else {         hs_free_database(hs_db);     }      return false; }  int match_cb(unsigned int id, unsigned long long from, unsigned long long to, unsigned int flags, void* context) {     auto cbdata = (struct cb_data*)context;     auto& matched = cbdata-&gt;matched;      if (cbdata-&gt;ctx-&gt;approx_re.find(id) != cbdata-&gt;ctx-&gt;approx_re.end()) {         int ovec[3];         auto re = cbdata-&gt;ctx-&gt;pcre_vec[id];         auto* begin = cbdata-&gt;str-&gt;data();         auto* p = begin;         auto sz = cbdata-&gt;str-&gt;size();          while (pcre_exec(re.re, re.extra, p, sz - (p - begin), 0, 0, ovec, 3) &gt; 0) {             p = p + ovec[1];             matched[id]++;         }     } else {         matched[id]++;     }      return 0; }  int main(int argc, char** argv) {     ifstream refile(argv[1]);     vector&lt;string&gt; re_vec;     double t1, t2, total_ticks = 0;     struct cb_context ctx;     int ls;      pcre_config(PCRE_CONFIG_LINK_SIZE, &ls);     cout &lt;&lt; ls &lt;&lt; endl;      for (std::string line; std::getline(refile, line);) {         re_vec.push_back(line);     }      string re_pipe;     const char** pats = new const char*[re_vec.size()];     unsigned int i = 0, *ids = new unsigned int[re_vec.size()];      \/\/re_vec.erase(remove_if(re_vec.begin(), re_vec.end(), remove_uncompileable), re_vec.end());      for (i = 0; i &lt; re_vec.size(); i++) {         const auto& r = re_vec[i];         remove_uncompileable(r, i, &ctx);         pats[i] = r.c_str();         ids[i] = i;         re_pipe = re_pipe + string(&quot;(&quot;) + r + string(&quot;)|&quot;);     }     \/\/ Last |     re_pipe.erase(re_pipe.size() - 1);      total_ticks = 0;     for (const auto& r : re_vec) {         t1 = get_ticks();         ctx.pcre_vec.emplace_back(r);         t2 = get_ticks();          total_ticks += t2 - t1;     }      cout &lt;&lt; &quot;PCRE compile time: &quot; &lt;&lt; total_ticks &lt;&lt; endl;      ifstream input(argv[2]);      std::string in_str((std::istreambuf_iterator&lt;char&gt;(input)),         std::istreambuf_iterator&lt;char&gt;());      hs_compile_error_t* hs_errors;     hs_database_t* hs_db;     hs_platform_info_t plt;     hs_populate_platform(&plt);     unsigned int* flags = new unsigned int[re_vec.size()];      for (i = 0; i &lt; re_vec.size(); i++) {         if (ctx.approx_re.find(i) != ctx.approx_re.end()) {             flags[i] = HS_FLAG_PREFILTER;         } else {             flags[i] = 0;         }     }      t1 = get_ticks();     if (hs_compile_multi(pats, flags, ids, re_vec.size(), HS_MODE_BLOCK, &plt, &hs_db, &hs_errors) != HS_SUCCESS) {         cout &lt;&lt; &quot;BAD pattern: '&quot; &lt;&lt; re_vec[hs_errors-&gt;expression] &lt;&lt; &quot;', error: &quot; &lt;&lt; hs_errors-&gt;message &lt;&lt; endl;          return -101;     }     t2 = get_ticks();      cout &lt;&lt; &quot;Hyperscan compile time: &quot; &lt;&lt; (t2 - t1) &lt;&lt; &quot;; approx re: &quot;          &lt;&lt; ctx.approx_re.size() &lt;&lt; &quot;; total re: &quot; &lt;&lt; re_vec.size() &lt;&lt; endl;      char* bytes = NULL;     size_t bytes_len;      t1 = get_ticks();     if (hs_serialize_database(hs_db, &bytes, &bytes_len) != HS_SUCCESS) {         cout &lt;&lt; &quot;BAD&quot; &lt;&lt; endl;          return -101;     }     t2 = get_ticks();     cout &lt;&lt; &quot;Hyperscan serialize time: &quot; &lt;&lt; (t2 - t1) &lt;&lt; &quot;; size: &quot; &lt;&lt; bytes_len &lt;&lt; &quot; bytes&quot; &lt;&lt; endl;      hs_database_t* hs_db1 = NULL;     t1 = get_ticks();     if (hs_deserialize_database(bytes, bytes_len, &hs_db1) != HS_SUCCESS) {         cout &lt;&lt; &quot;BAD1&quot; &lt;&lt; endl;          return -101;     }     t2 = get_ticks();     cout &lt;&lt; &quot;Hyperscan deserialize time: &quot; &lt;&lt; (t2 - t1) &lt;&lt; &quot;; size: &quot; &lt;&lt; bytes_len &lt;&lt; &quot; bytes&quot; &lt;&lt; endl;      auto matches = 0;     total_ticks = 0;      for (const auto& re : ctx.pcre_vec) {         int ovec[3];         auto* begin = in_str.data();         auto* p = begin;         auto sz = in_str.size();          t1 = get_ticks();         while (pcre_exec(re.re, re.extra, p, sz - (p - begin), 0, 0, ovec, 3) &gt; 0) {             p = p + ovec[1];             matches++;         }         t2 = get_ticks();          total_ticks += t2 - t1;     }     \/\/cout &lt;&lt; re_pipe &lt;&lt; endl;      cout &lt;&lt; &quot;Time for individual re: &quot; &lt;&lt; total_ticks &lt;&lt; &quot;; matches: &quot; &lt;&lt; matches &lt;&lt; endl;      \/\/cout &lt;&lt; &quot;Time for piped re: &quot; &lt;&lt; (t2 - t1) &lt;&lt; endl;      hs_scratch_t* scratch = NULL;     int rc;      if ((rc = hs_alloc_scratch(hs_db1, &scratch)) != HS_SUCCESS) {         cout &lt;&lt; &quot;bad scratch: &quot; &lt;&lt; rc &lt;&lt; endl;          return -102;     }      struct cb_data cbdata;     cbdata.ctx = &ctx;     cbdata.matched = vector&lt;int&gt;(re_vec.size(), 0);     cbdata.str = &in_str;      t1 = get_ticks();      if ((rc = hs_scan(hs_db1, in_str.data(), in_str.size(), 0, scratch,              match_cb, &cbdata))         != HS_SUCCESS) {         cout &lt;&lt; &quot;bad scan: &quot; &lt;&lt; rc &lt;&lt; endl;         return -103;     }      t2 = get_ticks();      matches = 0;     for_each(cbdata.matched.begin(), cbdata.matched.end(), [&matches](int elt) { matches += elt; });     cout &lt;&lt; &quot;Time for hyperscan re: &quot; &lt;&lt; (t2 - t1) &lt;&lt; &quot;; matches: &quot; &lt;&lt; matches &lt;&lt; endl;      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e-\u0442\u0430\u043a\u0438 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u044e\u0449\u0438\u043c: \u043d\u0430 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\u043d\u043e\u043c \u0441\u043f\u0430\u043c\u0435\u0440\u0441\u043a\u043e\u043c \u043f\u0438\u0441\u044c\u043c\u0435 \u0438 \u043d\u0430\u0431\u043e\u0440\u0435 \u0438\u0437 ~1000 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<pre> PCRE compile time: 0.0138553 Hyperscan compile time: 4.94309; approx re: 191; total re: 971 Hyperscan serialize time: 0.00312218; size: 5242956 bytes Hyperscan deserialize time: 0.00359501; size: 5242956 bytes Time for individual re: 0.440707; matches: 7 Time for hyperscan re: 0.0770988; matches: 7 <\/pre>\n<h2>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440<\/h2>\n<p>  \u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u044e\u0449\u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 hyperscan \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0430. \u042d\u0442\u043e\u0442 \u0440\u0435\u0436\u0438\u043c \u043f\u043e\u043b\u0435\u0437\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u043e\u0442 \u0436\u0435 backtracking. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 hyperscan \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u044f\u0432\u043b\u044f\u044e\u0449\u0435\u0435\u0441\u044f <strong>\u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c<\/strong> \u043d\u0430\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0422\u043e \u0435\u0441\u0442\u044c, \u043d\u043e\u0432\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043d\u0430 \u0432\u0441\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u0434\u0430\u0432\u0430\u044f false positive \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0434\u0432\u0438\u0436\u043a\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, pcre (\u0445\u043e\u0442\u044f \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0442\u044c \u0432\u0435\u0441\u044c \u0442\u0435\u043a\u0441\u0442, \u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f). \u041d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0445\u0435\u043c\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0c5\/043\/d63\/0c5043d63f824fb6b6b4e2ca2ff99069.png\"\/><\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/h2>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u0438\u0441\u044c \u0438 \u0434\u0432\u0430 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u2014 \u043e\u043d\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 pcre. \u0412\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0445\u043e\u0434\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438\u0445 \u0432 pre-filter \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0430\u044e\u0442. \u0421\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u00ab\u043a\u0440\u044b\u0448\u0435\u0441\u043d\u043e\u0441\u043d\u044b\u043c\u00bb \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0431\u044b\u043b\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u043e\u0435:<\/p>\n<pre> &lt;a\\s[^&gt;]{0,2048}\\bhref=(?:3D)?.?(https?:[^&gt;&quot;'\\# ]{8,29}[^&gt;&quot;'\\#:\\\/?&=])[^&gt;]{0,2048}&gt;(?:[^&lt;]{0,1024}&lt;(?!\\\/a)[^&gt;]{1,1024}&gt;){0,99}\\s{0,10}(?!\\1)https?[^\\w&lt;]{1,3}[^&lt;]{5} <\/pre>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u044f \u0441\u0434\u0435\u043b\u0430\u043b, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0435\u0439 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432\u0441\u0435 pre-filter \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u043e\u0440\u043a\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u0418 \u0435\u0441\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043e\u043b\u0433\u043e, \u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0431\u0435\u0437\u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0435, \u0442\u043e \u0435\u0441\u0442\u044c, \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f pcre. \u0422\u0430\u043a\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 4-\u0445 \u0442\u044b\u0441\u044f\u0447 \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u043e\u043a\u043e\u043b\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u0430. \u0412\u0441\u0435 \u043e\u043d\u0438 \u043f\u0440\u0438\u0448\u043b\u0438 \u0438\u0437 \u0433\u043e\u0440\u044f\u0447\u043e \u043b\u044e\u0431\u0438\u043c\u043e\u0433\u043e \u043c\u043d\u043e\u0439 spamassassin&#8217;\u0430 \u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u043c\u0438 \u0431\u043e\u043b\u0435\u0437\u043d\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u00abperl \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043c\u043e\u0437\u0433\u0430\u00bb. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430\u043c\u0438 Intel \u043e\u043d\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e, \u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 regexp \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043c\u0438\u043d\u0443\u0442\u044b, \u0447\u0442\u043e \u043d\u0435\u043f\u0440\u0438\u0435\u043c\u043b\u0438\u043c\u043e \u0434\u043b\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0446\u0435\u043b\u0435\u0439.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b hyperscan \u0442\u0430\u043a\u0436\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0443\u0436\u043d\u044b\u043c \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440\u044b \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u00ab\u043a\u043b\u0430\u0441\u0441\u044b\u00bb \u2014 \u044d\u0442\u043e \u0442\u0438\u043f \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043f\u0438\u0441\u044c\u043c\u0430 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u0442\u0435\u043b\u043e \u043f\u0438\u0441\u044c\u043c\u0430, \u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0447\u0430\u0441\u0442\u0438. \u0422\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0445\u0435\u043c\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/352\/6cc\/bfc\/3526ccbfcbba2befc0f7934e054bcbad.png\"\/><\/p>\n<p>  \u0414\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0436\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434:  <\/p>\n<ul>\n<li>\u0412 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0441\u043a\u0430\u0442\u044c, \u043d\u0435\u0442 \u043b\u0438 \u0443\u0436\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u043d\u0435\u0433\u043e.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0435\u0442 \u0438\u043b\u0438 \u0436\u0435 \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 (\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0445\u0435\u0448\u0443 \u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f), \u0442\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044f \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432.<\/li>\n<li>\u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u043a\u0435\u0448\u0435, \u0442\u043e \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c \u0441\u043a\u0430\u043d\u0435\u0440\u0430\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043a\u0430\u043d\u0435\u0440\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0441 pcre \u043d\u0430 hyperscan.<\/li>\n<\/ul>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u043e\u0447\u0442\u0443 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0430\u0440\u0442\u0430 (\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 pcre), \u0430 \u043d\u0435 \u0436\u0434\u0430\u0442\u044c \u0434\u043e\u0440\u043e\u0433\u043e\u0439 \u0438 \u0434\u043e\u043b\u0433\u043e\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 hyperscan&#8217;\u0430, \u0430 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0441 pcre \u043d\u0430 hyperscan (\u0447\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u0435 \u043e\u0442\u0445\u043e\u0434\u044f \u043e\u0442 \u043a\u0430\u0441\u0441\u044b). \u0410 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0431\u0438\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u0438 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0438\u0445 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0443\u0436\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043f\u0438\u0441\u0435\u043c.<\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>  \u0412 \u0445\u043e\u0434\u0435 \u0440\u0430\u0431\u043e\u0442\u044b rspamd+hyperscan \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<p>  \u0411\u044b\u043b\u043e:  <\/p>\n<pre> len: 610591, time: 2492.457ms real, 882.251ms virtual regexp statistics: 4095 pcre regexps scanned, 18 regexps matched, 694M bytes scanned using pcre <\/pre>\n<p>  \u0421\u0442\u0430\u043b\u043e:  <\/p>\n<pre> len: 610591, time: 654.596ms real, 309.785ms virtual regexp statistics: 34 pcre regexps scanned, 41 regexps matched, 8.41M bytes scanned using pcre,  9.56M bytes scanned total <\/pre>\n<p>  \u0411\u043e\u043b\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e regexps matched \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 hyperscan \u0432\u044b\u0437\u0432\u0430\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f pcre, \u043d\u043e \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 hyperscan (\u0442.\u043a. \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e).<\/p>\n<p>  Hyperscan \u0432\u0435\u0440\u0441\u0438\u044f \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435, \u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432 <a href=\"https:\/\/rspamd.com\/announce\/2016\/01\/18\/rspamd-1.1.0.html\">\u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e rspamd<\/a>. \u042f \u043c\u043e\u0433\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u0442\u044c hyperscan \u0434\u043b\u044f \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0445 \u043a \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 (DPI, \u043f\u0440\u043e\u043a\u0441\u0438 \u0438\u0442\u0434), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0435\u043a\u0441\u0442\u0435. <\/p>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u044f \u0434\u0435\u043b\u0430\u043b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 hyperscan \u0441 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Aho%E2%80%93Corasick_algorithm\">aho-corasick<\/a>. \u042f \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043b \u0441\u0430\u043c\u0443\u044e \u0431\u044b\u0441\u0442\u0440\u0443\u044e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0443\u044e \u043c\u043d\u0435 <a href=\"https:\/\/github.com\/mischasan\/aho-corasick\">\u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a> \u043e\u0442 Mischa Sandberg.<\/p>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f 10 \u0442\u044b\u0441\u044f\u0447 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u043d\u0430 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\u043d\u043e\u043c \u043f\u0438\u0441\u044c\u043c\u0435 c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a (\u0442\u043e \u0435\u0441\u0442\u044c, \u0445\u0443\u0434\u0448\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0434\u043b\u044f aho-corasic, \u0438\u043c\u0435\u044e\u0449\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c O(M+N), \u0433\u0434\u0435 M \u2014 \u0447\u0438\u0441\u043b\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a):<\/p>\n<pre> actrie compile time: 0.0743811 Hyperscan compile time: 0.1547; approx re: 0; total re: 7400 Hyperscan serialize time: 0.000178297; size: 1250856 bytes Hyperscan deserialize time: 0.000312379; size: 1250856 bytes Time for hyperscan re: 0.117938; matches: 3001024 Time for actrie: 0.100427; matches: 3000144 <\/pre>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0439 \u043d\u0435 \u0441\u043e\u0448\u043b\u043e\u0441\u044c \u0438\u0437-\u0437\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 ac-trie \u043a\u043e\u0434\u0435, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a hyperscan \u043d\u0435 \u043e\u0448\u0438\u0431\u0441\u044f \u043d\u0438 \u0440\u0430\u0437\u0443.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 <a href=\"https:\/\/highsecure.ru\/rspamd-hyperscan.pdf\">\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>. \u041a\u043e\u0434 \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 rspamd <a href=\"https:\/\/github.com\/vstakhov\/rspamd\/blob\/master\/src\/libserver\/re_cache.c\">\u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a>               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/275507\/\"> http:\/\/habrahabr.ru\/post\/275507\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043e\u043f\u044b\u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b <a href=\"https:\/\/github.com\/01org\/hyperscan\">hyperscan<\/a>. \u0422\u0430\u043a \u0432\u044b\u0448\u043b\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u043f\u0430\u043c-\u0444\u0438\u043b\u044c\u0442\u0440\u0430 <a href=\"https:\/\/rspamd.com\">rspamd<\/a> \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0445 \u043f\u0440\u0430\u0432\u0438\u043b, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f spamassassin \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u044b. \u041c\u043e\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <a href=\"https:\/\/rspamd.com\/doc\/modules\/spamassassin.html\">\u043f\u043b\u0430\u0433\u0438\u043d<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0447\u0438\u0442\u0430\u043b \u044d\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0438 \u0441\u0442\u0440\u043e\u0438\u043b \u0438\u0437 \u043d\u0438\u0445 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e. \u0417\u0430\u0442\u0435\u043c \u043d\u0430 \u044d\u0442\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0438\u0441\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u043e\u0431 \u044d\u0442\u043e\u043c \u044f \u0434\u0430\u0436\u0435 \u0434\u0435\u043b\u0430\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e <a href=\"https:\/\/highsecure.ru\/ast-rspamd.pdf\">\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>).<\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u0445\u043e\u0434\u0435 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e pcre \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0443\u0437\u043a\u0438\u043c \u043c\u0435\u0441\u0442\u043e\u043c, \u0438 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0438\u0441\u044c\u043c\u0430\u0445 \u044d\u0442\u043e\u0442 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. \u0412\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e \u043d\u0430 \u043f\u0438\u0441\u044c\u043c\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 pcre \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043e\u043a\u043e\u043b\u043e \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u0430 (!) \u0442\u0435\u043a\u0441\u0442\u0430. \u0420\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0440\u044e\u043a\u0438, \u0432\u0440\u043e\u0434\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0434\u043b\u044f \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b, \u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 pcre \u043f\u0443\u0442\u0435\u043c \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f jit fast path \u0447\u0435\u0440\u0435\u0437 <strong>pcre_jit_exec<\/strong> \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043e\u043f\u0430\u0441\u043d\u044b\u043c\u0438 \u2014 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0438 \u043e\u0442\u043a\u0440\u043e\u0432\u0435\u043d\u043d\u043e \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438 \u0438 \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c \u00ab\u0431\u0438\u0442\u044b\u0435\u00bb UTF8 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0438 \u043a \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u044b\u043c \u0431\u0430\u0433\u0430\u043c \u0441 \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0435\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 <a href=\"http:\/\/highload.ru\">highload<\/a> \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u0441\u043e \u0421\u043b\u0430\u0432\u043e\u0439 \u041e\u043b\u044c\u0445\u043e\u0432\u0447\u0435\u043d\u043a\u043e\u0432\u044b\u043c, \u0438 \u043e\u043d \u043c\u043d\u0435 \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 hyperscan. \u0414\u0430\u043b\u0435\u0435 \u044f \u043f\u0435\u0440\u0435\u0439\u0434\u0443 \u043a \u0441\u0443\u0442\u0438 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-272447","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/272447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=272447"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/272447\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=272447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=272447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=272447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}