{"id":328049,"date":"2022-01-15T03:00:21","date_gmt":"2022-01-15T03:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=328049"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=328049","title":{"rendered":"<span>\u0423\u0441\u043a\u043e\u0440\u044f\u0435\u043c hugo \u043d\u0430 20% \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 reflect<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430\u0439\u0442\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u0437\u043a\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438\u043b\u0438 \u0437\u0440\u0435\u043b\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u0440\u0435\u0434\u043a\u043e\u0441\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u042f \u0431\u044b\u043b \u0443\u0434\u0438\u0432\u043b\u0451\u043d, \u043a\u043e\u0433\u0434\u0430 \u0432 top10 \u0441\u043f\u0438\u0441\u043a\u0435 CPU-\u043f\u0440\u043e\u0444\u0438\u043b\u044f <a href=\"https:\/\/github.com\/gohugoio\/hugo\" rel=\"nofollow noopener noreferrer\">hugo<\/a> \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 <a href=\"https:\/\/github.com\/GSA\/digitalgov.gov\" rel=\"nofollow noopener noreferrer\">digitalgov.gov<\/a> \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>reflect.Type.MethodByName()<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">      flat  flat%   sum%        cum   cum%      8.84s  6.28%  6.28%     57.85s 41.10%  reflect.(*rtype).MethodByName      7.93s  5.63% 11.92%      8.50s  6.04%  reflect.name.readVarint      7.56s  5.37% 17.29%    111.79s 79.43%  reflect.Value.call      7.53s  5.35% 22.64%     23.33s 16.58%  runtime.mallocgc      7.29s  5.18% 27.82%     16.10s 11.44%  reflect.name.name<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0442\u0430\u043a \u0432\u044b\u0448\u043b\u043e \u0438 \u0447\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"pochemu-methodbyname-takoy-medlennyy\">\u041f\u043e\u0447\u0435\u043c\u0443 MethodByName \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439<\/h2>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 MethodByName:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">func (t *rtype) MethodByName(name string) (m Method, ok bool) {     \/\/ &lt;\u043b\u0438\u0448\u043d\u0438\u0439 \u043a\u043e\u0434 \u0432\u044b\u0440\u0435\u0437\u0430\u043d>      \/\/ TODO(mdempsky): Binary search.     for i, p := range ut.exportedMethods() {         if t.nameOff(p.name).name() == name {             return t.Method(i), true         }     }     return Method{}, false }<\/code><\/pre>\n<p>  <\/p>\n<p>MethodByName \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a. \u0415\u0441\u043b\u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0443 \u0442\u0438\u043f\u0430 \u043c\u043d\u043e\u0433\u043e, \u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u043b\u0433\u043e, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0433\u0434\u0435-\u0442\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u043b\u0430\u0439\u0441\u0430.<\/p>\n<p>  <\/p>\n<h2 id=\"kak-mozhno-uskorit-methodbyname\">\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c MethodByName<\/h2>\n<p>  <\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0435\u0440\u0432\u044b\u0439: \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c MethodByName. \u0418\u043b\u0438 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041d\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">func (t *rtype) MethodByName(name string) (m Method, ok bool) {     \/\/ &lt;\u043b\u0438\u0448\u043d\u0438\u0439 \u043a\u043e\u0434 \u0432\u044b\u0440\u0435\u0437\u0430\u043d>      if len(methods) > 8 {         i := sort.Search(len(methods), func(i int) bool {             return t.nameOff(methods[i].name).name() >= name         })         if i &lt; len(methods) &amp;&amp; t.nameOff(methods[i].name).name() == name {             return t.Method(i), true         }     } else {         for i, p := range methods {             if t.nameOff(p.name).name() == name {                 return t.Method(i), true             }         }     }     return Method{}, false }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0434\u043b\u044f \u043c\u0430\u043b\u044b\u0445 \u0441\u043b\u0430\u0439\u0441\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u044f. \u041d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u0445 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0432 \u043b\u044e\u0431\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u0440\u043e\u043c\u0435 \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u043b\u0430\u0439\u0441\u0430.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u0446\u0438\u0444\u0440\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">name                           old time\/op  new time\/op  delta MethodByName\/4_first-8          426ns \u00b1 2%   423ns \u00b1 1%     ~    MethodByName\/4_last-8           482ns \u00b1 1%   476ns \u00b1 1%   -1.33% MethodByName\/4_nonexisting-8   57.8ns \u00b1 0%  57.3ns \u00b1 1%   -0.78% MethodByName\/16_first-8         427ns \u00b1 1%   538ns \u00b1 0%  +25.97% MethodByName\/16_last-8          643ns \u00b1 1%   519ns \u00b1 1%  -19.24% MethodByName\/16_nonexisting-8   194ns \u00b1 0%   105ns \u00b1 0%  -46.03% MethodByName\/32_first-8         429ns \u00b1 1%   552ns \u00b1 1%  +28.78% MethodByName\/32_last-8          831ns \u00b1 0%   540ns \u00b1 2%  -34.97% MethodByName\/32_nonexisting-8   396ns \u00b1 1%   125ns \u00b1 1%  -68.56% MethodByName\/64_first-8         431ns \u00b1 1%   580ns \u00b1 2%  +34.64% MethodByName\/64_last-8         1.36\u00b5s \u00b1 1%  0.56\u00b5s \u00b1 1%  -58.95% MethodByName\/64_nonexisting-8   759ns \u00b1 0%   146ns \u00b1 1%  -80.82% [Geo mean]                      430ns        303ns       -29.58%<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c, \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0445\u0443\u0436\u0435 \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u043b\u0430\u0439\u0441\u0430. \u0415\u0441\u043b\u0438 \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0438 \u0438 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0433\u0434\u0435-\u0442\u043e \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435, \u0442\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d.<\/p>\n<p>  <\/p>\n<h2 id=\"proveryaem-vliyanie-na-hugo\">\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 hugo<\/h2>\n<p>  <\/p>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0441\u0430\u0439\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0441\u044f \u0437\u0430 <code>20.4<\/code> \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0431\u0435\u0440\u0451\u043c hugo \u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u043c \u043f\u0430\u043a\u0435\u0442\u043e\u043c <code>reflect<\/code> \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u0431\u043e\u0440\u043a\u0443 \u0441\u0430\u0439\u0442\u0430 \u0435\u0449\u0451 \u0440\u0430\u0437.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0441\u0431\u043e\u0440\u043a\u0430 \u0441\u0430\u0439\u0442\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 <code>16.5<\/code> \u0441\u0435\u043a\u0443\u043d\u0434!<\/p>\n<p>  <\/p>\n<p>\u0410 \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043c \u0441 \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u043c?<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(pprof) top 20 Showing nodes accounting for 50.85s, 44.61% of 114s total Dropped 1174 nodes (cum &lt;= 0.57s) Showing top 20 nodes out of 194       flat  flat%   sum%        cum   cum%      8.64s  7.58%  7.58%     25.01s 21.94%  runtime.mallocgc      7.69s  6.75% 14.32%     87.02s 76.33%  reflect.Value.call      4.17s  3.66% 17.98%      5.39s  4.73%  runtime.heapBitsSetType      2.88s  2.53% 20.51%         4s  3.51%  runtime.findObject      2.83s  2.48% 22.99%      2.83s  2.48%  runtime.nextFreeFast (inline)      2.79s  2.45% 25.44%      9.46s  8.30%  runtime.scanobject      2.74s  2.40% 27.84%      2.74s  2.40%  runtime.duffcopy      1.82s  1.60% 29.44%      1.88s  1.65%  runtime.pageIndexOf      1.76s  1.54% 30.98%      1.76s  1.54%  runtime.memclrNoHeapPointers      1.69s  1.48% 32.46%      3.24s  2.84%  runtime.mapaccess2      1.66s  1.46% 33.92%      1.83s  1.61%  syscall.Syscall      1.49s  1.31% 35.23%      1.61s  1.41%  reflect.name.readVarint      1.43s  1.25% 36.48%      3.07s  2.69%  reflect.name.name      1.42s  1.25% 37.73%     10.54s  9.25%  reflect.FuncOf      1.37s  1.20% 38.93%      1.75s  1.54%  github.com\/gohugoio\/hugo\/...      1.34s  1.18% 40.11%      4.99s  4.38%  sync.(*Map).Load      1.33s  1.17% 41.27%      1.33s  1.17%  reflect.(*rtype).Kind      1.29s  1.13% 42.40%      1.29s  1.13%  cmpbody      1.28s  1.12% 43.53%      1.28s  1.12%  runtime.resolveNameOff      1.23s  1.08% 44.61%      1.30s  1.14%  runtime.heapBitsForAddr<\/code><\/pre>\n<p>  <\/p>\n<p>MethodByName, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043d\u0430 1-\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u0432\u0445\u043e\u0434\u0438\u0442 \u0434\u0430\u0436\u0435 \u0432 top20.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u043d\u0430\u043c \u0441\u0442\u043e\u0438\u0442 \u043a\u043e\u043f\u043d\u0443\u0442\u044c \u0433\u043b\u0443\u0431\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0432\u044b\u0432\u043e\u0434\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043c \u0431\u044b\u043b\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 MethodByName \u0438 \u043a\u0430\u043a\u043e\u0432\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0441\u043b\u0430\u0439\u0441\u043e\u0432 exportedMethods \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0435\u0442\u043e\u0434 \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0437\u0430 \u0441\u0431\u043e\u0440\u043a\u0443 \u0441\u0430\u0439\u0442\u0430: 17042238.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">15920637 times | 120 methods 493669 times | 29 methods 227736 times | 16 methods 180098 times | 8 methods 143846 times | 39 methods 31371 times | 6 methods 14636 times | 1 methods 10933 times | 31 methods 10094 times | 9 methods 9026 times | 4 methods 102 times | 113 methods 85 times | 7 methods 4 times | 114 methods 1 times | 0 methods<\/code><\/pre>\n<p>  <\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0431\u044b\u043b\u0430 \u043d\u0430\u0434 \u0442\u0438\u043f\u043e\u043c, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e 120 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">12998952 times | 98 index pos 1203864 times | 70 index pos 515978 times | 102 index pos 354191 times | 110 index pos 262965 times | 6 index pos 200819 times | 11 index pos 178457 times | 19 index pos 170806 times | 97 index pos 147510 times | 74 index pos 136927 times | 3 index pos 123071 times | 20 index pos 106250 times | 9 index pos 87190 times | 7 index pos 62767 times | 31 index pos 62192 times | 5 index pos 50170 times | 51 index pos 49120 times | 69 index pos 45325 times | 72 index pos 42236 times | 115 index pos 38646 times | 0 index pos 37106 times | 28 index pos 22744 times | 108 index pos 21521 times | 14 index pos 18134 times | 92 index pos 17341 times | 4 index pos 11535 times | 103 index pos 10791 times | 63 index pos 10303 times | 2 index pos 9170 times | 10 index pos 7278 times | 68 index pos 5936 times | 15 index pos 5466 times | 65 index pos 5385 times | 16 index pos 5172 times | 47 index pos 4478 times | 43 index pos 3032 times | 40 index pos 2340 times | 17 index pos 2265 times | 25 index pos 1516 times | 44 index pos 1068 times | 88 index pos 843 times | 1 index pos 709 times | 71 index pos 358 times | 109 index pos 100 times | 67 index pos 50 times | 64 index pos 40 times | 42 index pos 33 times | 34 index pos 17 times | 86 index pos 15 times | 83 index pos 15 times | 41 index pos 15 times | 33 index pos 12 times | 118 index pos 5 times | 8 index pos 5 times | 27 index pos 4 times | 66 index pos<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438\u0441\u043a\u043e\u043c\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0442\u043e\u0436\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u044b\u0431\u043e\u0440. \u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 98.<\/p>\n<p>  <\/p>\n<h2 id=\"podvodnye-kamni\">\u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438<\/h2>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u0432\u044b\u0448\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <code>sort.Search<\/code>, \u043d\u043e \u043e\u043d \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u043b\u044f \u043f\u0430\u043a\u0435\u0442\u0430 <code>reflect<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0430\u043a\u0435\u0442 <code>sort<\/code> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 <code>reflect<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>sort.Search<\/code> \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 <code>reflect<\/code> \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 internal \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f Go, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u043a\u0435\u0442\u0430 <code>sort<\/code>, \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0435\u0435 \u043e\u0442 <code>reflect<\/code>.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u0444\u0430\u043a\u0442\u043e\u0440 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0430\u0442\u0447\u0430, \u0432\u0435\u0434\u044c \u0441\u0430\u043c\u044b\u0439 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d.<\/p>\n<p>  <\/p>\n<h2 id=\"kak-vosproizvesti-rezultaty-sobrat-profili\">\u041a\u0430\u043a \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u0438<\/h2>\n<p>  <\/p>\n<pre><code class=\"bash\">$ git clone https:\/\/github.com\/GSA\/digitalgov.gov.git $ cd digitalgov.gov $ hugo --profile-cpu cpu.out<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>go tool pprof<\/code> \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u0440\u043e\u0444\u0438\u043b\u044f <code>cpu.out<\/code>.<\/p>\n<p>  <\/p>\n<p>\u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b hugo \u0441 \u043a\u043e\u043c\u043c\u0438\u0442\u0430 <a href=\"https:\/\/github.com\/gohugoio\/hugo\/commit\/c8b5ab75b743914f89b51046eee8e3daa2eb1eec\" rel=\"nofollow noopener noreferrer\">c8b5ab75b743914f89b51046eee8e3daa2eb1eec<\/a>. \u041d\u043e \u0434\u0443\u043c\u0430\u044e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0412 <code>digitalgov.gov<\/code> \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u0444\u0430\u0439\u043b\u043e\u0432, \u0443\u0431\u0440\u0430\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f getenv \u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0438\u0445 \u0432 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">    modified:   themes\/digital.gov\/layouts\/partials\/core\/head.html     modified:   themes\/digital.gov\/layouts\/partials\/core\/set-env.html<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0435\u0440\u0441\u0438\u044f Go \u043e\u0441\u043e\u0431\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0432 MethodByName \u0431\u044b\u043b \u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<p>  <\/p>\n<h2 id=\"vyvody\">\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>  <\/p>\n<p>\u042f \u0432\u044b\u0441\u043b\u0430\u043b <a href=\"https:\/\/go-review.googlesource.com\/c\/go\/+\/378634\/\" rel=\"nofollow noopener noreferrer\">CL<\/a> \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 Go, \u043d\u043e \u043d\u0435 \u0437\u043d\u0430\u044e, \u043f\u0440\u0438\u043c\u0443\u0442 \u0435\u0433\u043e \u0438\u043b\u0438 \u043d\u0435\u0442 (spoiler: \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0442).<\/p>\n<p>  <\/p>\n<p>\u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0431\u044b\u043b\u043e \u0437\u0430\u0431\u0430\u0432\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043a\u0430\u043a \u0442\u0430\u043a\u0430\u044f \u0431\u0435\u0437\u043e\u0431\u0438\u0434\u043d\u0430\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u043b\u0430 \u0441\u0431\u043e\u0440\u043a\u0443 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430 \u043d\u0430 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u044f \u043e\u0436\u0438\u0434\u0430\u043b \u043e\u0442 hugo \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c &#171;The world\u2019s fastest framework for building websites.&#187;<\/p>\n<p>  <\/p>\n<blockquote><p>\u0415\u0441\u043b\u0438 \u0432\u0434\u0440\u0443\u0433 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c +1 \u043a \u0432\u044b\u0441\u043b\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0430\u0442\u0447\u0443, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e, \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0440\u0435\u0430\u043a\u0446\u0438\u044e \u043a <a href=\"https:\/\/github.com\/golang\/go\/issues\/50617\" rel=\"nofollow noopener noreferrer\">golang\/issue50617<\/a>.<\/p><\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/645727\/\"> https:\/\/habr.com\/ru\/post\/645727\/<\/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_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430\u0439\u0442\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u0437\u043a\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438\u043b\u0438 \u0437\u0440\u0435\u043b\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u0440\u0435\u0434\u043a\u043e\u0441\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u042f \u0431\u044b\u043b \u0443\u0434\u0438\u0432\u043b\u0451\u043d, \u043a\u043e\u0433\u0434\u0430 \u0432 top10 \u0441\u043f\u0438\u0441\u043a\u0435 CPU-\u043f\u0440\u043e\u0444\u0438\u043b\u044f <a href=\"https:\/\/github.com\/gohugoio\/hugo\" rel=\"nofollow noopener noreferrer\">hugo<\/a> \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 <a href=\"https:\/\/github.com\/GSA\/digitalgov.gov\" rel=\"nofollow noopener noreferrer\">digitalgov.gov<\/a> \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>reflect.Type.MethodByName()<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">      flat  flat%   sum%        cum   cum%      8.84s  6.28%  6.28%     57.85s 41.10%  reflect.(*rtype).MethodByName      7.93s  5.63% 11.92%      8.50s  6.04%  reflect.name.readVarint      7.56s  5.37% 17.29%    111.79s 79.43%  reflect.Value.call      7.53s  5.35% 22.64%     23.33s 16.58%  runtime.mallocgc      7.29s  5.18% 27.82%     16.10s 11.44%  reflect.name.name<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0442\u0430\u043a \u0432\u044b\u0448\u043b\u043e \u0438 \u0447\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-328049","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328049","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=328049"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328049\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=328049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=328049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=328049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}