{"id":350265,"date":"2023-07-14T15:01:20","date_gmt":"2023-07-14T15:01:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=350265"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=350265","title":{"rendered":"<span>\u0412 {n} \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0421\u0438<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/747826\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/70\/rj\/dw\/70rjdw_kr_4cforejtrelropgyy.png\" data-src=\"https:\/\/habrastorage.org\/webt\/70\/rj\/dw\/70rjdw_kr_4cforejtrelropgyy.png\"\/><\/div>\n<p><\/a><br \/>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u0446\u0438\u043a\u043b\u0430, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 \u0421\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e clang, \u0438 \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u0438\u0437\u043c\u0435\u0440\u044f\u044f \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 HackerNews, \u0438 \u043a \u0435\u0451 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/news.ycombinator.com\/item?id=36618344\">\u0437\u0434\u0435\u0441\u044c<\/a>.<a name=\"habracut\"><\/a><\/p>\n<blockquote><p>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440: \u044f \u043d\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0442 \u043f\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445, \u0447\u0438\u0441\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u0433\u0434\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u0434\u0443\u043c\u0430\u0435\u0442 \u043e \u0442\u043e\u043c, <i>\u043a\u0430\u043a <\/i>\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f.  <\/p><\/blockquote>\n<p>  \u041b\u0438\u0441\u0442\u0438\u043d\u0433\u0438 \u043a\u043e\u0434\u0430 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/github.com\/414owen\/blog-code\/tree\/master\/01-six-times-faster-than-c\">GitHub<\/a>.<\/p>\n<h2><font color=\"#3AC1EF\">\u0427\u0430\u0441\u0442\u044c I<\/font><\/h2>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0424\u0443\u043d\u043a\u0446\u0438\u044f<\/font><\/h3>\n<p>  \u041c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u043c\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043b\u0438\u0431\u043e \u0434\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<pre><code class=\"cs\">int run_switches(char *input) {   int res = 0;   while (true) {     char c = *input++;     switch (c) {       case '\\0':         return res;       case 's':         res += 1;         break;       case 'p':         res -= 1;         break;       default:         break;     }   } }<\/code><\/pre>\n<p>  \u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0435 <code>s<\/code> (<b>s<\/b>uccessor, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442), \u0430 \u0434\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0435 <code>p<\/code> (<b>p<\/b>redecessor, \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442).<\/p>\n<p>  \u042d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e gcc \u0438 clang \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041c\u043e\u0436\u0435\u0442, \u0434\u0430\u0436\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e? \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0435\u0451, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u0441\u0442 gcc \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u0438\u043b\u0438 \u0436\u0435 \u043f\u043e\u0438\u0441\u043a.<\/p>\n<p>  \u0412\u043e\u0442, \u0447\u0442\u043e \u0432\u044b\u0434\u0430\u043b clang (\u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0435 no-op \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e):<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># llvm-objdump -d --symbolize-operands --no-addresses --x86-asm-syntax=intel --no-show-raw-insn loop-1-clang.c.o  run_switches:       xor     eax, eax            # res = 0 loop:                             # while (true) {       movsx   ecx, byte ptr [rdi] #   c = *input       test    ecx, ecx            #   if (c == '\\0')       je      ret                 #     return       add     rdi, 1              #   input++       cmp     ecx, 'p'            #   if (c == 'p')       je      p                   #     goto p       cmp     ecx, 's'            #   if (c == 's')       jne     loop                #     continue       add     eax, 1              #   res++       jmp     loop                #   continue p:    add     eax, -1             #   res--       jmp     loop                # } ret:  ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u0435\u0440\u0441\u0438\u044f \u0441\u043e \u0441\u0442\u0440\u0435\u043b\u043a\u0430\u043c\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># objdump -Mintel -d --no-addresses --no-show-raw-insn --visualize-jumps loop-1-clang.c.o  run_switches:               xor    eax, eax loop:       \u256d\u2500\u2500\u2500\u2500\u27a4 movsx  ecx, byte ptr [rdi]       \u2502      test   ecx, ecx       \u2502 \u256d\u2500\u2500\u2500 je     ret       \u2502 \u2502    add    rdi, 1       \u2502 \u2502    cmp    ecx, 'p'       \u2502 \u2502 \u256d\u2500 je     p       \u2502 \u2502 \u2502  cmp    ecx, 's'       \u251c\u2500\u2502\u2500\u2502\u2500 jne    loop       \u2502 \u2502 \u2502  add    eax, 1       \u251c\u2500\u2502\u2500\u2502\u2500 jmp    loop p:    \u2502 \u2502 \u2570\u27a4 add    eax, -1       \u2570\u2500\u2502\u2500\u2500\u2500 jmp    loop ret:    \u2570\u2500\u2500\u27a4 ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: 3.23 s<\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c: 295.26 MiB\/s<\/li>\n<\/ul>\n<p>  Gcc \u0432\u044b\u0434\u0430\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f \u0447\u0443\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442 \u2013 \u0432 \u043d\u0451\u043c \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f (<code>je<\/code>, <code>je<\/code>, <code>jne<\/code>), \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u043a \u0447\u0435\u0442\u044b\u0440\u0451\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0431\u043b\u043e\u043a\u0430\u043c: <code>\\0<\/code>, <code>s<\/code>, <code>p<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u043b\u043e\u043a \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u041f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0439<\/font><\/h3>\n<p>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u043c\u044b \u043a\u043e\u0435-\u0447\u0442\u043e \u0437\u043d\u0430\u0435\u043c. \u041d\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0432\u044b\u0445\u043e\u0434 \u0438\u0437 \u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u043d\u0443\u043b\u044c-\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430 (<code>\\0<\/code>). \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0439 clang \u043a\u043e\u0434 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043d\u0443\u043b\u044c-\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430, \u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430. \u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043d\u0443\u043b\u044c-\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u0441\u044f \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0440\u0430\u0432\u043d\u043e 1. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f <code>p<\/code> \u0438\u043b\u0438 <code>s<\/code> \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0430 \u043d\u0435 \u043d\u0443\u043b\u044c-\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430.<\/p>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0438\u043c \u043d\u0430\u0448 \u0446\u0438\u043a\u043b.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u0435\u0440\u0441\u0438\u044f \u0441\u043e \u0441\u0442\u0440\u0435\u043b\u043a\u0430\u043c\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">run_switches:                xor    eax, eax loop:  \u256d\u2500\u2500\u2500\u2500\u2500\u27a4 movsx  ecx, byte ptr [rdi]        \u2502       inc    rdi        \u2502       cmp    ecx, 'p'        \u2502 \u256d\u2500\u2500\u2500\u2500 je     p        \u2502 \u2502     cmp    ecx, 's'        \u2502 \u2502 \u256d\u2500\u2500 je     s        \u2502 \u2502 \u2502   test   ecx, ecx        \u251c\u2500\u2502\u2500\u2502\u2500\u2500 jne    loop        \u2502 \u2502 \u2502   ret p:     \u2502 \u2570\u2500\u2502\u2500\u27a4 dec    eax        \u251c\u2500\u2500\u2500\u2502\u2500\u2500 jmp    loop s:     \u2502   \u2570\u2500\u27a4 inc    eax        \u2570\u2500\u2500\u2500\u2500\u2500\u2500 jmp    loop<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0413\u043e\u043b\u044b\u0439 \u043a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">run_switches:         xor     eax, eax loop:   movsx   ecx, byte ptr [rdi]         inc     rdi         cmp     ecx, 'p'         je      p         cmp     ecx, 's'         je      s         test    ecx, ecx         jne     loop         ret p:      dec     eax         jmp     loop s:      inc     eax         jmp     loop<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u043d\u044c\u0448\u0435 \u2014 \u043f\u0440\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0435 <code>p<\/code> \u0438\u043b\u0438 <code>s<\/code>, \u0430 \u043d\u0435 \u0440\u0435\u0434\u043a\u043e\u0433\u043e <code>\\0<\/code>.<\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: 3.10 s <\/li>\n<li>\u041f\u0440\u0438\u0440\u043e\u0441\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438:: 1.04x <\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c: 307.64 MiB\/s<\/li>\n<\/ul>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u041f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0431\u043b\u043e\u043a\u043e\u0432<\/font><\/h3>\n<p>  \u0418\u0442\u0430\u043a, \u043e\u0431\u0430 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f (<code>p<\/code> \u0438 <code>s<\/code>) \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043b\u0438\u0441\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0446\u0438\u043a\u043b\u0430, \u0442\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0430\u043c \u043d\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0432\u0435\u0442\u0432\u0435\u0439, \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0432 \u0435\u0451 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0431\u043b\u043e\u043a (\u0438\u043b\u0438 BasicBlock\u2122, \u0434\u043b\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432 \u043f\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430\u043c) \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0446\u0438\u043a\u043b\u0430?<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u0435\u0440\u0441\u0438\u044f \u0441\u043e \u0441\u0442\u0440\u0435\u043b\u043a\u0430\u043c\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">run_switches:               xor    eax, eax        \u256d\u2500\u2500\u2500\u2500\u2500 jmp    loop s:     \u2502 \u256d\u2500\u2500\u27a4 inc    eax loop:  \u251c\u2500\u2502\u2500\u2500\u27a4 movsx  ecx, byte ptr [rdi]        \u2502 \u2502    inc    rdi        \u2502 \u2502    cmp    ecx, 'p'        \u2502 \u2502 \u256d\u2500 je     p        \u2502 \u2502 \u2502  cmp    ecx, 's'        \u2502 \u2570\u2500\u2502\u2500 je     s        \u2502   \u2502  test   ecx, ecx        \u251c\u2500\u2500\u2500\u2502\u2500 jne    loop        \u2502   \u2502  ret p:     \u2502   \u2570\u27a4 dec    eax        \u2570\u2500\u2500\u2500\u2500\u2500 jmp    loop<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0413\u043e\u043b\u044b\u0439 \u043a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">run_switches:         xor     eax, eax         jmp     loop       # This is new s:      inc     eax        # This is up here now loop:   movsx   ecx, byte ptr [rdi]         inc     rdi         cmp     ecx, 'p'         je      p         cmp     ecx, 's'         je      s         test    ecx, ecx         jne     loop         ret p:      dec     eax         jmp     loop<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u0431\u043b\u043e\u043a <code>s<\/code> \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u043a\u0438\u0432\u0430\u0435\u0442 (fall through) \u0432 \u0446\u0438\u043a\u043b \u0431\u0435\u0437 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f. \u041d\u0435\u043f\u043b\u043e\u0445\u043e.<\/p>\n<p>  \u0412\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0446\u0438\u043a\u043b \u0438\u0437 \u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0431\u043b\u043e\u043a\u0430 <code>s<\/code>. \u0425\u043e\u0442\u044f \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441 \u2013 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0432 \u0446\u0438\u043a\u043b \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u0430\u043a \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 <code>s<\/code> \u043c\u044b \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e.<\/p>\n<p>  \u041d\u043e \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442?<\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: 2.98 s <\/li>\n<li>\u041e\u0431\u0449\u0435\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435: 1.08x<\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c: 320.02 MiB\/s<\/li>\n<\/ul>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0417\u0430\u043c\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u043e\u0439<\/font><\/h3>\n<p>  \u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b <a href=\"https:\/\/en.wikipedia.org\/wiki\/Branch_predictor\">\u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b<\/a>, \u043d\u043e \u043a\u0430\u043a \u043d\u0430\u0441\u0447\u0451\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e <code>jmp<\/code>? \u0427\u0442\u043e, \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0443\u0431\u0440\u0430\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0432 \u0446\u0438\u043a\u043b <code>p:<\/code>?<\/p>\n<p>  \u0414\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442 \u0440\u0430\u0432\u043d\u043e\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u0432\u0443\u043c \u0434\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0438 \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0443, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e? \u0417\u043d\u0430\u0447\u0438\u0442, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u043a\u0438\u0432\u0430\u043d\u0438\u044f \u0432 <code>s:<\/code>.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u0435\u0440\u0441\u0438\u044f \u0441\u043e \u0441\u0442\u0440\u0435\u043b\u043a\u0430\u043c\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">run_switches:                xor    eax, eax        \u256d\u2500\u2500\u2500\u2500\u2500\u2500 jmp    loop p:     \u2502   \u256d\u2500\u27a4 sub    eax, 2 s:     \u2502 \u256d\u2500\u2502\u2500\u27a4 inc    eax loop:  \u251c\u2500\u2502\u2500\u2502\u2500\u27a4 movsx  ecx, byte ptr [rdi]        \u2502 \u2502 \u2502   inc    rdi        \u2502 \u2502 \u2502   cmp    ecx, 'p'        \u2502 \u2502 \u2570\u2500\u2500 je     p        \u2502 \u2502     cmp    ecx, 's'        \u2502 \u2570\u2500\u2500\u2500\u2500 je     s        \u2502       test   ecx, ecx        \u2570\u2500\u2500\u2500\u2500\u2500\u2500 jne    loop                ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0413\u043e\u043b\u044b\u0439 \u043a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">run_switches:         xor     eax, eax         jmp     loop p:      sub     eax, 2 s:      inc     eax loop:   movsx   ecx, byte ptr [rdi]         inc     rdi         cmp     ecx, 'p'         je      p         cmp     ecx, 's'         je      s         test    ecx, ecx         jne     loop         ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0412\u043e\u0442 \u043c\u044b \u0438 \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u0442 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0443. \u0425\u043e\u0440\u043e\u0448\u043e. \u041d\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0431\u044b\u0441\u0442\u0440\u0435\u0435?<\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: 2.87 s <\/li>\n<li>\u041e\u0431\u0449\u0435\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435: 1.12x <\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c: 332.29 MiB\/s<\/li>\n<\/ul>\n<p>  \u0417\u0430\u0431\u0430\u0432\u043d\u044b\u0439 \u0444\u0430\u043a\u0442. \u0412\u0441\u0451 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043c\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c clang 16, \u043d\u043e gcc 12 \u043d\u0430 \u0434\u0435\u043b\u0435 \u0432\u044b\u0434\u0430\u0432\u0430\u043b \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 (\u0445\u043e\u0442\u044f \u0438 \u0431\u043e\u043b\u0435\u0435 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0439) \u043a\u043e\u0434. \u0415\u0433\u043e \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u0437\u0430 2,87 \u0441, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0451 \u0434\u043e\u0433\u043d\u0430\u043b\u0438. \u041d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 13 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 gcc \u2013 \u0438\u0437 19.<\/p>\n<p>  \u041f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e \u043a\u043e\u0434 gcc \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b \u0446\u0438\u043a\u043b \u0438 \u0434\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0431\u043b\u043e\u043a\u0438 \u043a\u0435\u0439\u0441\u043e\u0432.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0411\u0435\u0437 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f<\/font><\/h3>\n<p>  \u0425\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u044d\u0442\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0432\u0435\u0442\u0432\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? \u041a\u0430\u043a \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0438\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435? \u042f \u043d\u0435 \u0437\u043d\u0430\u044e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u0435\u0440\u0441\u0438\u044f \u0441\u043e \u0441\u0442\u0440\u0435\u043b\u043a\u0430\u043c\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># rdi: char *input # eax: ouput # r8:  1 # edx: -1 # ecx: char c # esi: n  run_switches:             xor    eax, eax             mov    r8d, 1             mov    edx, -1 loop:         \u256d\u2500\u2500\u27a4 movsx  ecx, byte ptr [rdi]        \u2502    test   ecx, ecx        \u2502 \u256d\u2500 je     ret        \u2502 \u2502  inc    rdi        \u2502 \u2502  mov    esi, 0        \u2502 \u2502  cmp    ecx, 'p'        \u2502 \u2502  cmove  esi, edx        \u2502 \u2502  cmp    ecx, 's'        \u2502 \u2502  cmove  esi, r8d        \u2502 \u2502  add    eax, esi        \u2570\u2500\u2502\u2500 jmp    loop ret:     \u2570\u27a4 ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># rdi: char *input # eax: ouput # r8:  1 # edx: -1 # ecx: char c # esi: n  run_switches:         xor    eax, eax             # res = 0         mov    r8d, 1               # need  1 in a register later         mov    edx, -1              # need -1 in a register later loop:                               # while (true) {         movsx  ecx, byte ptr [rdi]  #   char c = *input         test   ecx, ecx             #   if (c == '\\0')         je     ret                  #     return         inc    rdi                  #   input++         mov    esi, 0               #   n = 0         cmp    ecx, 'p'             #   if (c == 'p')         cmove  esi, edx             #     n = -1         cmp    ecx, 's'             #   if (c == 's')         cmove  esi, r8d             #     n = 1         add    eax, esi             #   res += n         jmp    loop                 # } ret:    ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0412\u0430\u0443, \u043c\u044b \u0443\u0434\u0430\u043b\u0438\u043b\u0438 \u0438\u0437 \u0433\u0440\u0430\u0444\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u0435\u043b\u043e\u043a\u2026<\/p>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f\/\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043c\u044b, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>cmove<\/code> \u0438\u043b\u0438 \u00ab\u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0443\u00bb.<\/p>\n<p>  \u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u0442\u0430\u043a\u043e\u0432\u044b: \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u043b\u044c, \u043f\u0440\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0435 <code>s<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 1, \u0430 \u043f\u0440\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0435 <code>p<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c -1. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435. <\/p>\n<p>  \u041d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u043e\u0432\u043e\u0440\u043e\u0442, \u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0442\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u0435\u0435?<\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: 0.48 s<\/li>\n<li>\u041e\u0431\u0449\u0435\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435: 6.73x<\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c: 1.94 GiB\/s<\/li>\n<\/ul>\n<p>  \u0414\u0430 \u0443\u0436, \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0447\u0435\u0440\u0442\u043e\u0432\u0441\u043a\u0438 \u0431\u044b\u0441\u0442\u0440\u043e.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430<\/font><\/h3>\n<p>  \u0412 x86_64 \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (1 \u0431\u0430\u0439\u0442\u0430) \u043d\u0430 0 \u0438\u043b\u0438 1. \u041e\u043d \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>sete<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0438 \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u043d\u0430\u0448\u0435\u0433\u043e <code>r8d<\/code>.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u0435\u0440\u0441\u0438\u044f \u0441\u043e \u0441\u0442\u0440\u0435\u043b\u043a\u0430\u043c\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">run_switches:              xor    eax, eax              mov    edx, -1 loop:         \u256d\u2500\u2500\u27a4 movsx  ecx, byte ptr [rdi]         \u2502    test   ecx, ecx         \u2502 \u256d\u2500 je     ret         \u2502 \u2502  inc    rdi         \u2502 \u2502  mov    esi, 0         \u2502 \u2502  cmp    ecx, 's'         \u2502 \u2502  sete   sil         \u2502 \u2502  cmp    ecx, 'p'         \u2502 \u2502  cmove  esi, edx         \u2502 \u2502  add    eax, esi         \u2570\u2500\u2502\u2500 jmp    loop ret:      \u2570\u27a4 ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">run_switches:         xor   eax, eax             # res = 0         mov   edx, -1              # need -1 in a register later loop:                              # while (true) {         movsx ecx, byte ptr [rdi]  #   char c = *input         test  ecx, ecx             #   if (c == '\\0')         je    ret                  #     return         inc   rdi                  #   input++         mov   esi, 0               #   n = 0         cmp   ecx, 's'             #   c == 's'?         sete  sil                  #     n = 0|1         cmp   ecx, 'p'             #   if (c == 'p')         cmove esi, edx             #     n = -1         add   eax, esi             #   res += n         jmp   loop                 # } ret:    ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041d\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442 \u043b\u0438 \u044d\u0442\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435?<\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: 0.51 s<\/li>\n<li>\u041e\u0431\u0449\u0435\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435: 6.33x<\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c: 1.83 GiB\/s<\/li>\n<\/ul>\n<p>  \u0427\u0442\u043e \u0436, \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0447\u0435\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>cmov<\/code>. \u0414\u0443\u043c\u0430\u044e, \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 8-\u0431\u0438\u0442\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u043c\u0435\u0441\u0442\u043e 32-\u0431\u0438\u0442\u043d\u044b\u0445.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438<\/font><\/h3>\n<p>  \u042f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0446\u0438\u043a\u043b \u043d\u0430\u0448\u0435\u0439 \u043b\u0443\u0447\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a\u043e\u0434\u0430. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u043e\u0434 \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u043b\u0441\u044f. <br \/>  \u0422\u043e\u0433\u0434\u0430 \u044f \u0440\u0435\u0448\u0438\u043b \u0432\u044b\u0440\u043e\u0432\u043d\u044f\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u043e \u0446\u0438\u043a\u043b\u0430 \u043f\u043e 16-\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 (\u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043e\u0432\u0435\u0442: \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>.align &lt;bytes><\/code> \u043f\u0435\u0440\u0435\u0434 \u043c\u0435\u0442\u043a\u043e\u0439, \u0438 GNU Assembler \u0432\u0441\u0442\u0430\u0432\u0438\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <code>nop<\/code> \u0437\u0430 \u0432\u0430\u0441). \u042d\u0442\u043e \u0442\u043e\u0436\u0435 \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u043b\u043e \u043a\u043e\u0434.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0430<\/font><\/h3>\n<p>  <\/p>\n<pre><code class=\"cs\">$ uname -sr Linux 6.1.33 $ lscpu ...   Model name:            AMD Ryzen 5 5625U with Radeon Graphics     CPU family:          25     Thread(s) per core:  2     Core(s) per socket:  6     Socket(s):           1 $ clang --version clang version 16.0.1 $ gcc --version gcc (GCC) 12.2.0<\/code><\/pre>\n<p>  \u0412\u0435\u0440\u0441\u0438\u0438 \u0421\u0438 \u0431\u044b\u043b\u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <code>-march=native<\/code>, \u0441\u043e\u043e\u0431\u0449\u0430\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u043c\u043e\u0451\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435, \u0430 \u043d\u0435 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u043c x86_64.<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a \u0442\u044b\u0441\u044f\u0447\u0443 \u0440\u0430\u0437 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0437 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f\u043c\u0438 <code>p<\/code> \u0438 <code>s<\/code>).<\/p>\n<p>  \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b \u044d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u0432\u044b\u0431\u0440\u0430\u0432 \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0412\u044b\u0432\u043e\u0434\u044b <\/font><\/h3>\n<p>  \u041f\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f 6-\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u043f\u0443\u0442\u0451\u043c \u0440\u0443\u0447\u043d\u043e\u0439 \u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u0436\u0430\u0442\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0421\u0438 \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0445\u043d\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b, \u043f\u043e\u0445\u043e\u0436\u0435, \u0435\u0449\u0451 \u043d\u0435 \u0432\u0441\u0442\u0440\u043e\u0438\u043b\u0438.<\/p>\n<p>  \u041d\u043e \u044d\u0442\u043e \u0435\u0449\u0451 \u043d\u0435 \u043a\u043e\u043d\u0435\u0446, \u0438 \u0434\u0430\u043b\u0435\u0435 \u0432\u0430\u0441 \u0436\u0434\u0451\u0442 \u0432\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043c\u043e\u0435\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430.<\/p>\n<h2><font color=\"#3AC1EF\">\u0427\u0430\u0441\u0442\u044c II<\/font><\/h2>\n<p>  \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 \u0421\u0438, \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0435\u0451, \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438, \u0434\u043e\u0431\u0438\u0432\u0448\u0438\u0441\u044c \u0448\u0435\u0441\u0442\u0438\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u0436\u0435 \u043c\u044b \u044d\u0442\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u043c.<\/p>\n<p>  \u041b\u0438\u0441\u0442\u0438\u043d\u0433\u0438 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0442\u0430\u043a\u0436\u0435 \u043b\u0435\u0436\u0430\u0442 \u043d\u0430 <a href=\"https:\/\/github.com\/414owen\/blog-code\/tree\/master\/02-the-same-speed-as-c\">GitHub<\/a>.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0433\u043b\u0430 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c 295.26 MiB\/s, \u0430 \u0435\u0451 \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2013 1.94 GiB\/s.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434 C\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">int run_switches(char *input) {   int res = 0;   while (true) {     char c = *input++;     switch (c) {       case '\\0':         return res;       case 's':         res += 1;         break;       case 'p':         res -= 1;         break;       default:         break;     }   } }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">asm + \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># llvm-objdump -d --symbolize-operands --no-addresses --x86-asm-syntax=intel --no-show-raw-insn loop-1-gcc.c.o  run_switches:       xor     eax, eax            # res = 0 loop:                             # while (true) {       movsx   ecx, byte ptr [rdi] #   c = *input       test    ecx, ecx            #   if (c == '\\0')       je      ret                 #     return       add     rdi, 1              #   input++       cmp     ecx, 'p'            #   if (c == 'p')       je      p                   #     goto p       cmp     ecx, 's'            #   if (c == 's')       jne     loop                #     continue       add     eax, 1              #   res++       jmp     loop                #   continue p:    add     eax, -1             #   res--       jmp     loop                # } ret:  ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">asm + \u0441\u0442\u0440\u0435\u043b\u043a\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># objdump -Mintel -d --no-addresses --no-show-raw-insn --visualize-jumps loop-2-gcc.c.o  run_switches:              xor    eax, eax loop:       \u256d\u2500\u2500\u2500\u2500\u27a4 movsx  ecx, byte ptr [rdi]       \u2502      test   ecx, ecx       \u2502 \u256d\u2500\u2500\u2500 je     ret       \u2502 \u2502    add    rdi, 1       \u2502 \u2502    cmp    ecx, 'p'       \u2502 \u2502 \u256d\u2500 je     p       \u2502 \u2502 \u2502  cmp    ecx, 's'       \u251c\u2500\u2502\u2500\u2502\u2500 jne    loop       \u2502 \u2502 \u2502  add    eax, 1       \u251c\u2500\u2502\u2500\u2502\u2500 jmp    loop p:    \u2502 \u2502 \u2570\u27a4 add    eax, -1       \u2570\u2500\u2502\u2500\u2500\u2500 jmp    loop ret:    \u2570\u2500\u2500\u27a4 ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: 3.23 s<\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c: 295.26 MiB\/s<\/li>\n<\/ul>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u041e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435 \u043a\u0435\u0439\u0441\u043e\u0432<\/font><\/h3>\n<p>  \u041c\u044b \u0432\u044b\u0440\u0430\u0437\u0438\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437. \u0412 \u043d\u0435\u0439 \u043c\u044b \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u0443 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Proof_by_exhaustion\">\u0430\u043d\u0430\u043b\u0438\u0437 \u043a\u0435\u0439\u0441\u043e\u0432<\/a> \u0434\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 (\u0438\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u044b).<\/p>\n<p>  \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043a\u0435\u0439\u0441\u043e\u0432 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0440\u0430\u0437\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u043c\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043c \u043f\u0443\u0442\u0438 \u043a\u043e\u0434\u0430, \u0438\u043c\u0435\u044e\u0449\u0438\u0435 \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u041e\u0431\u0430 \u043a\u0435\u0439\u0441\u0430 \u2013 <code>p<\/code> \u0438 <code>s<\/code> \u2013 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u0432 \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440 \u0447\u0438\u0441\u043b\u043e. \u041c\u043e\u0436\u0435\u0442, \u0442\u043e\u0433\u0434\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043a\u0435\u0439\u0441\u043e\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0443\u0442\u0438 \u043a\u043e\u0434\u0430, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u043e\u0433\u043e \u0436\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f?<\/p>\n<p>  \u042d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434 \u0421\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">#include &lt;stdbool.h>  static int to_add[256] = {   ['s'] = 1,   ['p'] = -1, };  int run_switches(const char *input) {   int res = 0;   while (true) {     char c = *input++;     if (c == '\\0') {       return res;     } else {       res += to_add[(int) c];     }   } }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">gcc asm<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># objdump -Mintel -d --no-addresses --no-show-raw-insn --visualize-jumps loop-2-gcc.c.o  run_switches:            movsx  rax, byte ptr [rdi]            lea    rdx, [rdi+1]            xor    ecx, ecx            lea    rsi, [rip+0]        # &lt;run_switches+0x11>            test   al,  al       \u256d\u2500\u2500\u2500 je     ret       \u2502    nop    dword ptr [rax] loop: \u2502 \u256d\u27a4 add    rdx, 0x1       \u2502 \u2502  add    ecx, dword ptr [rsi+rax*4]       \u2502 \u2502  movsx  rax, byte ptr [rdx-1]       \u2502 \u2502  test   al,  al       \u2502 \u2570\u2500 jne    loop ret:  \u2570\u2500\u2500\u27a4 mov    eax, ecx            ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">clang asm<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># objdump -Mintel -d --no-addresses --no-show-raw-insn --visualize-jumps loop-2-clang.c.o  run_switches:            mov    cl,  byte ptr [rdi]            test   cl,  cl       \u256d\u2500\u2500\u2500 je     ret       \u2502    add    rdi, 0x1       \u2502    xor    eax, eax       \u2502    lea    rdx, [rip+0x0]        # &lt;run_switches+0x13>       \u2502    cs nop word ptr [rax+rax*1+0x0]       \u2502    nop    dword ptr [rax] loop: \u2502 \u256d\u27a4 movsx  rcx, cl       \u2502 \u2502  add    eax, dword ptr [rdx+rcx*4]       \u2502 \u2502  movzx  ecx, byte ptr [rdi]       \u2502 \u2502  add    rdi, 0x1       \u2502 \u2502  test   cl,  cl       \u2502 \u2570\u2500 jne    loop       \u2502    ret ret:  \u2570\u2500\u2500\u27a4 xor    eax, eax            ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f GCC: 0.47 s<\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c GCC: 1.98 GiB\/s<\/li>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f Clang: 0.25 s<\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c Clang: 3.72 GiB\/s<\/li>\n<\/ul>\n<p>  \u041d\u0435\u043f\u043b\u043e\u0445\u043e. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 gcc \u043c\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043d\u0430\u0448\u0435\u0439 \u043b\u0443\u0447\u0448\u0435\u0439 (<code>cmov<\/code>) \u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438, \u043d\u043e \u0432\u044b\u0432\u043e\u0434 clang \u043f\u043e\u0447\u0442\u0438 \u0432\u0434\u0432\u043e\u0435 \u0435\u0451 \u043e\u043f\u0435\u0440\u0435\u0434\u0438\u043b.<\/p>\n<p>  \u041c\u0435\u0436\u0434\u0443 gcc \u0438 clang \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435. \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438:<\/p>\n<pre><code class=\"bash\">movzx  ecx, byte ptr [rdi]  movsx  rax, byte ptr [rdx-1]<\/code><\/pre>\n<p>  \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0441\u043c\u043e\u0433\u0443 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c gcc c\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e \u0441 <code>movzx<\/code> (\u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043d\u0443\u043b\u044f\u043c\u0438) \u0432\u043c\u0435\u0441\u0442\u043e <code>movsx<\/code> (\u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f, \u0442\u043e \u0435\u0441\u0442\u044c <code>uint8_t<\/code> \u0438\u043b\u0438 <code>unsigned char<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>char<\/code>. <\/p>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434 \u0421\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">#include &lt;stdbool.h> #include &lt;stdint.h>  static int to_add[256] = {   ['s'] = 1,   ['p'] = -1, };  int run_switches(const uint8_t *input) {   int res = 0;   while (true) {     uint8_t c = *input++;     if (c == '\\0') {       return res;     } else {       res += to_add[(int) c];     }   } }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">gcc asm<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># objdump -Mintel -d --no-addresses --no-show-raw-insn --visualize-jumps loop-3-gcc.c.o  run_switches:                movzx  eax, byte ptr [rdi]                lea    rdx, [rdi+0x1]                xor    ecx, ecx                lea    rsi, [rip+0x0]                test   al,  al         \u256d\u2500\u2500\u2500\u2500\u2500 je     ret         \u2502      nop    dword ptr [rax+0x0] loop:   \u2502  \u256d\u2500\u27a4 movzx  eax, al         \u2502  \u2502   add    rdx, 1         \u2502  \u2502   add    ecx, dword ptr [rsi+rax*4]         \u2502  \u2502   movzx  eax, byte ptr [rdx-1]         \u2502  \u2502   test   al,  al         \u2502  \u2570\u2500\u2500 jne    loop ret:    \u2570\u2500\u2500\u2500\u2500\u27a4 mov    eax,ecx                ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">clang asm<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># objdump -Mintel -d --no-addresses --no-show-raw-insn --visualize-jumps loop-3-clang.c.o  run_switches:                mov    cl,  byte ptr [rdi]                test   cl,  cl         \u256d\u2500\u2500\u2500\u2500\u2500 je     ret         \u2502      add    rdi, 1         \u2502      xor    eax, eax         \u2502      lea    rdx, [rip+0x0]         \u2502      cs nop word ptr [rax+rax*1+0x0]         \u2502      nop    dword ptr [rax] loop:   \u2502  \u256d\u2500\u27a4 movzx  ecx, cl         \u2502  \u2502   add    eax, dword ptr [rdx+rcx*4]         \u2502  \u2502   movzx  ecx, byte ptr [rdi]         \u2502  \u2502   add    rdi, 1         \u2502  \u2502   test   cl,  cl         \u2502  \u2570\u2500\u2500 jne    loop         \u2502      ret ret:    \u2570\u2500\u2500\u2500\u2500\u27a4 xor    eax,eax                ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0421\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043d\u043e \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043b\u0438 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0431\u044b\u0441\u0442\u0440\u0435\u0435?<\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f GCC: 0.47 s<\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c GCC: 1.98 GiB\/s<\/li>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f Clang: 0.25 s<\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c Clang: 3.72 GiB\/s<\/li>\n<\/ul>\n<p>  \u041d\u0435\u0442. \u0412\u0441\u0451 \u0432 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u043a\u0430\u043a \u0438 \u043f\u0440\u0435\u0436\u0434\u0435. \u0425\u043e\u0440\u043e\u0448\u043e, \u0442\u043e\u0433\u0434\u0430 \u0432 \u0447\u0451\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">gcc asm<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">loop: \u256d\u2500\u27a4 movzx  eax, al       \u2502   add    rdx, 1       \u2502   add    ecx, dword ptr [rsi+rax*4]       \u2502   movzx  eax, byte ptr [rdx-1]       \u2502   test   al,  al       \u2570\u2500\u2500 jne    loop<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">clang asm<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">loop: \u256d\u2500\u27a4 movzx  ecx, cl       \u2502   add    eax, dword ptr [rdx+rcx*4]       \u2502   movzx  ecx, byte ptr [rdi]       \u2502   add    rdi, 1       \u2502   test   cl,  cl       \u2570\u2500\u2500 jne    loop<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041e\u0442\u043b\u0438\u0447\u0438\u044f \u0442\u0440\u0438:<\/p>\n<ul>\n<li>\u043f\u043e\u0440\u044f\u0434\u043e\u043a;<\/li>\n<li><code>[rdi]<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>[rdx - 1]<\/code>;<\/li>\n<li>\u0432\u044b\u0431\u043e\u0440 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u041f\u0440\u043e\u043f\u0443\u0441\u043a \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/font><\/h3>\n<p>  \u041e\u0431\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0432\u044b\u0434\u0430\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e <code>movzx<\/code> \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0432 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<p>  \u042f \u043d\u0435 \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0432 \u043a\u0430\u043a\u043e\u043c-\u043b\u0438\u0431\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 32-\u0431\u0438\u0442\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 x86_64 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043d\u0443\u043b\u044f\u043c\u0438, \u0438 \u044f \u043d\u0435 \u0432\u0438\u0436\u0443 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043a\u043e\u0434\u0430, \u0433\u0434\u0435 \u0441\u0442\u0430\u0440\u0448\u0438\u0435 \u0431\u0438\u0442\u044b \u0431\u044b\u043b\u0438 \u0431\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b.<\/p>\n<p>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0447\u0443\u0442\u044c\u0451 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u043d\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u044d\u0442\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0421\u0438, \u0437\u0430\u043c\u0435\u043d\u0438\u0432:<\/p>\n<pre><code class=\"bash\">uint8_t c = *input++;<\/code><\/pre>\n<p>  \u041d\u0430<\/p>\n<pre><code class=\"bash\">uint64_t c = *input++;<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u044e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043a 8-\u0431\u0438\u0442\u043d\u043e\u0433\u043e, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0443\u043b\u044f\u043c\u0438.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">gcc asm<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">loop: \/-> add    rdx, 1       |   add    ecx, dword ptr [rsi+rax*4]       |   movzx  eax, byte ptr [rdx-1]       |   test   rax, rax       \\-- jne    loop<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">clang asm<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">loop: \/-> movzx  ecx,cl       |   add    eax,dword ptr [rdx+rcx*4]       |   movzx  ecx,byte ptr [rdi]       |   add    rdi,0x1       |   test   cl,cl       \\-- jne    &lt;run_switches+0x20><\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0427\u0442\u043e \u0436, \u0434\u043b\u044f gcc \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e. <\/p>\n<p>  \u041d\u0430 \u043e\u0434\u043d\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043c\u0435\u043d\u044c\u0448\u0435 \u0431\u0435\u0437 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0434\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430. \u0412\u0435\u0441\u044c\u043c\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e.<\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f gcc 0.47 s<\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c gcc: 1.98 GiB\/s<\/li>\n<\/ul>\n<p>  \u041d\u043e\u2026\u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u041f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u0435 asm<\/font><\/h3>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u2013 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. <\/p>\n<p>  \u041d\u0435\u0442, \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0430\u0434\u0451\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434\u2026 \u041f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u043c\u0435\u0440\u0435 \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043c\u0430\u0441\u0441\u0438\u0432, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 gcc, \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043c\u0435\u0442\u043a\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c.<\/p>\n<pre><code class=\"bash\">.text run_switches:           xor   eax, eax                   # res = 0 loop:                                      # while (true) {   \/---->  movsx rcx, byte ptr [rdi]        #   char c = *input   |       test  rcx, rcx                   #   if (c == '\\0')   |  \/--  je    ret                        #     return   |  |    add   eax, dword ptr [arr+rcx*4] #   res += arr[c]   |  |    inc   rdi                        #   input++   \\--|--  jmp   loop                       # } ret: \\->  ret  .data arr:         .fill 'p', 4, 0         .long -1, 0, 0, 1         .fill (256 - 's'), 4, 0<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043c\u043e\u0451 \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u0438 \u0442\u0443\u0442 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0432\u0435\u0440\u0441\u0438\u0438 \u0421\u0438. \u0417\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u043d\u0430 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0443\u0442\u0438 \u0434\u0430\u0436\u0435 \u0434\u0432\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 (\u043e\u0434\u0438\u043d \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439) \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c gcc \u0438 clang. \u041a\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u0441\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438?<\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: 0.24 s<\/li>\n<li>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c: 3.88 GiB\/s<\/li>\n<\/ul>\n<p>  \u0427\u0442\u043e \u0436, \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u043f\u0440\u0435\u0432\u0437\u043e\u0448\u0451\u043b gcc \u0438 clang. \u042f \u043e\u0436\u0438\u0434\u0430\u043b, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0443\u0434\u043d\u0435\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043a\u043e\u0434, \u0447\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u0441\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439\u2026<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/font><\/h3>\n<p>  \u0412\u044b\u0432\u043e\u0434 gcc \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0430\u0434\u0440\u0435\u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0435\u0433\u043e \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u044d\u0442\u043e\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u043d\u0430 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0443\u0442\u0438:<\/p>\n<pre><code class=\"bash\">lea    rsi, [add_arr] ... add    ecx, dword ptr [rsi+rax*4]<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0438\u0437\u043b\u0438\u0448\u043d\u0438\u043c, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043b\u0438\u0448\u043d\u0435\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <code>lea<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0430\u0434\u0440\u0435\u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.<\/p>\n<pre><code class=\"bash\">add    ecx, dword ptr [arr+rax*4]<\/code><\/pre>\n<p>  \u041c\u044b \u0443\u0434\u0430\u043b\u0438\u043b\u0438 \u043e\u0434\u043d\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e (<code>lea<\/code>) \u0438\u0437 \u043d\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0443\u0442\u0438, \u0442\u0430\u043a? \u0414\u0430, \u043d\u043e \u0435\u0441\u043b\u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442\u043e\u0432, \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u0434\u043b\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>add<\/code>, \u0430 <code>add<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 \u043d\u0430 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0443\u0442\u0438. <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0414\u043e<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">48 8d 34 25 00 00 00    lea    rsi,ds:0x0 ... 03 0c 86                add    ecx,DWORD PTR [rsi+rax*4]<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u0441\u043b\u0435<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">... 03 0c 85 00 00 00 00    add    ecx,DWORD PTR [rax*4+0]<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0430\u0434\u0440\u0435\u0441\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432 <code>rsi<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b. \u041f\u043e\u043a\u0430 \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 gcc<\/font><\/h3>\n<p>  \u0412 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u043d\u0430\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0446\u0438\u043a\u043b gcc \u043f\u043e\u0447\u0442\u0438 \u0432\u0434\u0432\u043e\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 clang \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u0442\u0430\u043a \u043f\u043e\u0445\u043e\u0436\u0438. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u044f \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b \u043a\u043e\u0434 gcc \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 <a href=\"https:\/\/github.com\/414owen\/blog-code\/blob\/master\/02-the-same-speed-as-c\/loop-6.x64.s\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0438 \u0432\u043d\u0451\u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a \u0434\u043b\u044f \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438, \u0442\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043d\u044f\u0442\u044c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0442\u043e \u0438 \u0432\u0435\u0440\u0441\u0438\u044f gcc, \u0442\u043e \u0435\u0441\u0442\u044c 0,47 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>  \u041d\u043e\u043e\u043e\u043e, \u043e\u043d \u0437\u0430\u043d\u044f\u043b 0,26 \u0441, \u043e\u043a\u0430\u0437\u0430\u0432\u0448\u0438\u0441\u044c \u043f\u043e\u0447\u0442\u0438 \u0432\u0434\u0432\u043e\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u0414\u0443\u043c\u0430\u044e, \u044f \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u043e\u0448\u0438\u0431\u043a\u0443? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0438\u0449\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u0432 \u0432\u044b\u0432\u043e\u0434\u0435. <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u044b\u0432\u043e\u0434 gcc<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> 9:   48 8d 35 00 00 00 00    lea    rsi,[rip+0]   10:   48 85 c0                test   rax,rax   13:   74 13                   je     28 ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u0441\u043e\u0431\u0440\u0430\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> 9:   48 8d 34 25 00 00 00    lea    rsi,ds:0   10:   00   11:   48 85 c0                test   rax,rax   14:   74 13                   je     29 ret<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0410\u0433\u0430! \u0417\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0430\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 <code>lea<\/code>.<\/p>\n<p>  \u042f \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u043e\u0431\u0435\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u043c\u0430\u0441\u0441\u0438\u0432, \u043f\u043e\u0445\u043e\u0436\u0435, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <code>.rodata<\/code> \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0430. \u0415\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438, \u043e\u0442\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0438\u043b\u0438 \u043c\u043d\u0435 \u043d\u0430 \u043f\u043e\u0447\u0442\u0443.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0449\u0443\u0442\u0438\u043c\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0443\u0442\u0451\u043c, \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u043b\u0438\u044f\u0435\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0438.<\/p>\n<p>  \u0411\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u0435\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0438\u043c \u0441\u0436\u0430\u0442\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043f\u044f\u0442\u044c \u043d\u0435\u0432\u0438\u043d\u043d\u044b\u0445 no-op, \u0442\u043e \u043c\u044b \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044e gcc.<\/p>\n<p>  \u041d\u043e \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043b\u0443\u0447\u0448\u0435 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0433\u0440\u0430\u0444\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0440\u0430\u0437\u0438\u0442 \u0441\u0432\u044f\u0437\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0445 no-op \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/zc\/rf\/_k\/zcrf_khnmxlkmwjvltuwtlluu8m.png\" data-src=\"https:\/\/habrastorage.org\/webt\/zc\/rf\/_k\/zcrf_khnmxlkmwjvltuwtlluu8m.png\"\/><\/div>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043f\u044f\u0442\u0438 no-op (\u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0431\u0430\u0439\u0442\u0443 \u043a\u0430\u0436\u0434\u0430\u044f), \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 2-\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e 20 no-op, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435. \u042d\u0442\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d?<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ew\/_1\/kv\/ew_1kvi9vmdn8czvr1-u_b4yrsi.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ew\/_1\/kv\/ew_1kvi9vmdn8czvr1-u_b4yrsi.png\"\/><\/div>\n<p>  \u0414\u0430, \u043e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f. \u0421 \u043a\u0430\u043a\u043e\u0439 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e? \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0432\u043e\u0439\u043a\u0438\u2026<\/p>\n<p>  \u2026 \u042d\u0442\u043e 64 \u2013 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e.<\/p>\n<p>  \u0412 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 15 \u0431\u0430\u0439\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 49 \u043e\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0431\u044b\u0441\u0442\u0440\u043e.<\/p>\n<p>  \u041c\u043e\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0446\u0438\u043a\u043b \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442 \u0440\u043e\u0432\u043d\u043e 16 \u0431\u0430\u0439\u0442. \u0417\u043d\u0430\u0447\u0438\u0442, \u044d\u0442\u043e\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0438\u0437 15 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0446\u0438\u043a\u043b gcc \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0434\u043e\u043b\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u0432\u0443\u0445 \u043a\u044d\u0448-\u043b\u0438\u043d\u0438\u0439. \u0410 \u043a\u0430\u043a\u043e\u0432 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u044d\u0448-\u043b\u0438\u043d\u0438\u0438 \u043d\u0430 \u043c\u043e\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435? 64 \u0431\u0430\u0439\u0442\u0430.<\/p>\n<p>  \u0425\u043e\u0440\u043e\u0448\u0438\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438! \u041c\u044b \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u0438 \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0430\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u044c gcc \u0432\u044b\u0440\u043e\u0432\u043d\u044f\u0442\u044c \u0446\u0438\u043a\u043b \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u0430\u0447\u043d\u043e?<\/p>\n<p>  \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b <code>CFLAGS=-falign-jumps= &lt;n> make bench-c-4-gcc<\/code> \u043f\u0440\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 <code>n<\/code>, \u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/g1\/vc\/ep\/g1vcep9ixnytddx6uab5vbrhg_m.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/g1\/vc\/ep\/g1vcep9ixnytddx6uab5vbrhg_m.jpeg\" data-blurred=\"true\"\/><\/div>\n<p>  \u041f\u0440\u0438\u0447\u0438\u043d\u0430, \u043f\u043e\u0445\u043e\u0436\u0435, \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u0446\u0438\u043a\u043b\u0430, \u044f\u0432\u043b\u044f\u044f\u0441\u044c \u0446\u0435\u043b\u044c\u044e \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u043e\u043c, \u043a\u0443\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0438\u0437 \u043a\u043e\u0434\u0430 \u0432\u044b\u0448\u0435.<\/p>\n<blockquote><p><i>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 gcc:<\/i><\/p>\n<p>  \u0426\u0435\u043b\u0438 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0443\u0442\u0451\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043f\u043e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0435, \u0440\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438.<\/p><\/blockquote>\n<p>  \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, <code>CFLAGS=-falign-loops=16<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<p>  \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e <code>-falign-loops<\/code> \u0430\u043a\u0442\u0438\u0432\u043d\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 <code>>= -O2<\/code>. \u041d\u043e \u0432 \u043d\u0435\u0439 \u0442\u0430\u043a\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f: \u00ab\u0415\u0441\u043b\u0438 <code>n<\/code> \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0438\u043b\u0438 \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u043b\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0435 \u043c\u0430\u0448\u0438\u043d\u043e\u0439\u00bb. \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 16 :\/<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0438\u0437\u043b\u0438\u0448\u043d\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u0443 \u043e\u043f\u0446\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u044b. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u044d\u0442\u043e \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u0446\u0438\u043a\u043b\u0430. Gcc \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>__attribute__((aligned(16)))<\/code>, \u043d\u043e \u043e\u043d\u0438 \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b \u043a \u043c\u0435\u0442\u043a\u0430\u043c\/\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c \u2013 \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c.<\/p>\n<p>  \u0412\u0441\u044f \u043d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u043a\u044d\u0448-\u043b\u0438\u043d\u0438\u044e \u0438, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 <code>__attribute__((aligned(64)))<\/code> \u0434\u043b\u044f <code>run_switches<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0442\u043e\u043d\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u043d\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044f \u043a\u043e\u0434 \u0434\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430. \u0425\u043e\u0442\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u0442\u043e-\u0442\u043e \u0437\u043d\u0430\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0448\u0435?<\/p>\n<h2><font color=\"#3AC1EF\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/font><\/h2>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0443\u0442\u0438. <\/li>\n<li>\u0421\u0436\u0430\u0442\u044b\u0435, \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0435 \u0446\u0438\u043a\u043b\u044b, \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u043a\u044d\u0448-\u043b\u0438\u043d\u0438\u044e, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043c\u043e\u043b\u043d\u0438\u0435\u043d\u043e\u0441\u043d\u043e.<\/li>\n<li>\u0421\u0436\u0430\u0442\u044b\u0435 \u0446\u0438\u043a\u043b\u044b, \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043f\u043e \u0434\u0432\u0443\u043c \u043a\u044d\u0448-\u043b\u0438\u043d\u0438\u044f\u043c, \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 2 \u0440\u0430\u0437\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u0441\u0432\u043e\u0438\u0445 \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0445 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432. <\/li>\n<li>\u041f\u043e\u0445\u043e\u0436\u0435, gcc \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u0434 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u0442\u0440\u043e\u0433\u043e.<\/li>\n<li>\u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 GNU Assembler \u0432\u0430\u0448\u0438\u043c \u0434\u0440\u0443\u0433\u043e\u043c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f <code>.align &lt;bytes><\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<blockquote><p><b><font color=\"#3AC1EF\"><a href=\"https:\/\/habr.com\/ru\/specials\/744204\/\">\u0412\u044b\u0438\u0433\u0440\u0430\u0439 \u0442\u0435\u043b\u0435\u0441\u043a\u043e\u043f \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0438\u0437\u044b \u0432 \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043a\u0432\u0438\u0437\u0435 \u043e\u0442 RUVDS. \u041f\u043e\u0435\u0445\u0430\u043b\u0438? ?<\/a><\/font><\/b><\/p><\/blockquote>\n<p><a href=\"http:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=Bright_Translate&amp;utm_content=v_n_raz_bystree_si\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/_p\/_h\/lv\/_p_hlvd2tv0cv9tny8tdytzfhje.png\" data-src=\"https:\/\/habrastorage.org\/webt\/_p\/_h\/lv\/_p_hlvd2tv0cv9tny8tdytzfhje.png\"\/><\/a><\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/747826\/\"> https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/747826\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/747826\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/70\/rj\/dw\/70rjdw_kr_4cforejtrelropgyy.png\" data-src=\"https:\/\/habrastorage.org\/webt\/70\/rj\/dw\/70rjdw_kr_4cforejtrelropgyy.png\"\/><\/div>\n<p><\/a><br \/>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u0446\u0438\u043a\u043b\u0430, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 \u0421\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e clang, \u0438 \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u0438\u0437\u043c\u0435\u0440\u044f\u044f \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 HackerNews, \u0438 \u043a \u0435\u0451 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/news.ycombinator.com\/item?id=36618344\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/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-350265","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350265","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=350265"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350265\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}