{"id":489843,"date":"2026-08-05T09:48:36","date_gmt":"2026-08-05T09:48:36","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=489843"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=489843","title":{"rendered":"\u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 JS \u043d\u0435 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0435"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u0440\u043e \u043c\u0438\u043a\u0440\u043e-\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e. \u041f\u0440\u043e, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0441\u0430\u043c\u0443\u044e \u0431\u0435\u0437\u043e\u0431\u0438\u0434\u043d\u0443\u044e \u0432\u0435\u0449\u044c: \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <code>{}<\/code>.<\/p>\n<p><code>[object Object]<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u0447\u0442\u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0435\u0439. \u0421\u043e\u0437\u0434\u0430\u043b \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u0430\u043f\u0438\u0445\u0430\u043b \u043f\u043e\u043b\u0435\u0439 \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0443\u0434\u0430\u043b\u0438\u043b \u043d\u0435\u043d\u0443\u0436\u043d\u043e\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0437\u0430\u0431\u044b\u043b. \u041d\u043e, \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e, \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0434\u043b\u044f \u0442\u0435\u0431\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0434\u043b\u044f V8, \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0439 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u0430 \u201c\u0431\u0435\u0437\u043e\u0431\u0438\u0434\u043d\u044b\u0439\u201d <code>delete<\/code> \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0441\u0435\u0431\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043f\u0443\u0441\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e.<\/p>\n<p>\u0414\u043b\u044f 99% \u0441\u0438\u0441\u0442\u0435\u043c \u044d\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0410 \u0432\u043e\u0442 \u0435\u0441\u043b\u0438 \u0443 \u0442\u0435\u0431\u044f hot path, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0442\u044b\u0441\u044f\u0447 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0438\u043b\u0438 \u0442\u044b \u043f\u0438\u0448\u0435\u0448\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0439 \u043a\u043e\u0434, \u0441\u0442\u043e\u0438\u0442 \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e V8 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441 \u0442\u0432\u043e\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438.<\/p>\n<p><strong>\u0418 \u0447\u0435\u0433\u043e \u043e\u043d \u0442\u0430\u043c \u0441 \u043d\u0438\u043c\u0438 \u0434\u0435\u043b\u0430\u0435\u0442?<\/strong><\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0442\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u0448\u044c \u043e\u0431\u044a\u0435\u043a\u0442, V8 \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u00ab\u043c\u0435\u0448\u043e\u043a \u043a\u043b\u044e\u0447\u0435\u0439\u00bb. \u041e\u043d \u0441\u0442\u0440\u043e\u0438\u0442 \u0434\u043b\u044f \u043d\u0435\u0433\u043e <strong>hidden class<\/strong> (<em>map<\/em> \u0432\u043d\u0443\u0442\u0440\u0438 V8) \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 layout: \u043a\u0430\u043a\u0438\u0435 \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e\u043b\u044f, \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u043d\u0438 \u043b\u0435\u0436\u0430\u0442, \u043a\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043f\u043e \u043a\u0430\u043a\u0438\u043c \u043e\u0444\u0441\u0435\u0442\u0430\u043c \u0447\u0438\u0442\u0430\u0442\u044c. \u0421\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u044d\u0442\u043e \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u0430\u043a struct \u0432 C. Hidden class \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430 \u043d\u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0443.<\/p>\n<p>Hidden classes \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 <strong>transitions<\/strong> \u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 <strong>transition tree<\/strong>. \u041a\u043e\u0433\u0434\u0430 \u0442\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0448\u044c \u043f\u043e\u043b\u0435 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443, V8 \u0438\u0434\u0451\u0442 \u043f\u043e \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0443 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e hidden class: \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u0442\u0430\u043a\u0438\u043c \u043f\u043e\u043b\u0435\u043c \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u044b\u0439 hidden class \u0438 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0442\u043a\u0443 \u0434\u0435\u0440\u0435\u0432\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0434\u0443\u0442 \u043f\u043e \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430\u043c \u0432 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u043d\u0438 <strong>\u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0442 \u043e\u0434\u0438\u043d hidden class<\/strong>. \u042d\u0442\u043e \u0434\u0430\u0451\u0442 V8 \u0431\u0430\u0437\u0443 \u0434\u043b\u044f <strong>inline cache<\/strong>: \u00ab\u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043e\u0444\u0441\u0435\u0442\u0443 \u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u0435\u0436\u0438\u0442 string, \u0447\u0438\u0442\u0430\u0435\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a\u00bb.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 hidden classes \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0440\u0430\u0441\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f (\u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443, \u043f\u043e \u0442\u0438\u043f\u0430\u043c, \u043f\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044e), inline cache \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442:<\/p>\n<ul>\n<li>\n<p><strong>monomorphic<\/strong> (\u043e\u0434\u0438\u043d shape \u2014 fast path),<\/p>\n<\/li>\n<li>\n<p><strong>polymorphic<\/strong> (\u0434\u043e 4 shapes \u2014 V8 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439, \u0432\u0441\u0451 \u0435\u0449\u0451 \u0431\u044b\u0441\u0442\u0440\u043e),<\/p>\n<\/li>\n<li>\n<p><strong>megamorphic<\/strong> (4+ \u2014 V8 \u0441\u0434\u0430\u0451\u0442\u0441\u044f, \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 generic lookup).<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u0442\u0451\u0442 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435.<\/p>\n<p><strong>\u0413\u0434\u0435 \u0442\u044b \u0442\u0435\u0440\u044f\u0435\u0448\u044c?<\/strong><\/p>\n<p>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 vs \u043b\u0438\u0442\u0435\u0440\u0430\u043b:<\/p>\n<pre><code>const a = {}a.id = 1a.name = 'jopa'const b = { id: 1, name: 'jopa' }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043d\u0430 \u043e\u0434\u0438\u043d hidden class. \u0423 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430 \u0435\u0441\u0442\u044c \u0431\u043e\u043d\u0443\u0441 V8 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 shape \u043a\u0430\u043a <strong>boilerplate<\/strong> \u0438 \u043f\u0440\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 \u0430\u043b\u043b\u043e\u0446\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0440\u0430\u0437\u0443 \u0441 \u0433\u043e\u0442\u043e\u0432\u044b\u043c layout, \u0431\u0435\u0437 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e transition tree. \u041d\u043e \u0432 hot loop \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432\u0448\u0435\u043c\u0441\u044f \u0440\u0435\u0436\u0438\u043c\u0435 \u043a\u043e\u043f\u0435\u0435\u0447\u043d\u0430\u044f.<\/p>\n<p>\u0425\u0443\u0436\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u043b\u0435\u0439 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442:<\/p>\n<pre><code>function makeA(id, name) { return { id, name } }function makeB(name, id) { return { name, id } }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u0443\u0436\u0435 <strong>\u0434\u0432\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 hidden class<\/strong>. \u041b\u044e\u0431\u043e\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0438\u0442\u0430\u0435\u0442 <code>obj.id<\/code> \u0447\u0435\u0440\u0435\u0437 \u044d\u0442\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0438, \u0432\u0438\u0434\u0438\u0442 \u0434\u0432\u0430 shape \u043d\u0430 \u043e\u0434\u043d\u043e\u043c call site \u0438 IC \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f polymorphic. \u0421\u0430\u043c\u043e \u043f\u043e \u0441\u0435\u0431\u0435 \u0435\u0449\u0451 \u043d\u0435 \u0431\u043e\u043b\u044c\u043d\u043e, \u043d\u043e \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435 \u0434\u0432\u0430, \u0430 \u0448\u0435\u0441\u0442\u044c, \u0442\u043e \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 megamorphic.<\/p>\n<p>\u0415\u0449\u0451 \u043a\u0435\u0439\u0441 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439:<\/p>\n<pre><code>const user = { id, name }if (isAdmin) {  user.role = 'admin'}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0427\u0430\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u043c\u0435\u0435\u0442 shape <code>{id, name}<\/code>, \u0447\u0430\u0441\u0442\u044c \u2014 <code>{id, name, role}<\/code>. \u0423\u0436\u0435 polymorphic. \u041b\u0443\u0447\u0448\u0435 \u043a\u043b\u0430\u0441\u0442\u044c <code>role: null<\/code> \u0441\u0440\u0430\u0437\u0443 \u0438 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p><strong>delete \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f<\/strong><\/p>\n<pre><code>delete user.name<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0443\u0442 V8 \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u043e\u0449\u0430\u0435\u0442. <code>delete<\/code> \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 <strong>dictionary mode<\/strong> (\u043e\u043d \u0436\u0435 slow mode, normalized properties). \u042d\u0442\u043e hashmap \u0432\u043c\u0435\u0441\u0442\u043e \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e layout. \u041d\u0438 inline cache, \u043d\u0438 \u043e\u0444\u0441\u0435\u0442\u043e\u0432, \u043a\u0430\u0436\u0434\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 hash lookup \u0432 C++ runtime. \u0418 \u043e\u0431\u0440\u0430\u0442\u043d\u043e V8 \u043e\u0431\u044a\u0435\u043a\u0442 <strong>\u0443\u0436\u0435 \u043d\u0435 \u0432\u0435\u0440\u043d\u0451\u0442<\/strong>, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0444\u043e\u0440\u043c\u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c.<\/p>\n<p>\u0412\u0440\u043e\u0434\u0435 \u043a\u0430\u043a \u043f\u0430\u043c\u044f\u0442\u044c \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u043b. \u0410 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 <code>Map<\/code> \u0431\u0435\u0437 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0439 <code>null<\/code> \u0438\u043b\u0438 <code>undefined<\/code>. Shape \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f, \u0434\u0432\u0438\u0436\u043e\u043a \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442 \u0432 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p><strong>\u0410 \u0447\u0442\u043e \u043f\u043e \u0446\u0438\u0444\u0440\u0430\u043c?<\/strong><\/p>\n<p>\u0421\u0442\u0435\u043d\u0434: Node 24, \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 \u0442\u0440\u0435\u043c\u044f \u043f\u043e\u043b\u044f\u043c\u0438, \u0432 hot loop \u0447\u0438\u0442\u0430\u0435\u043c <code>obj.id<\/code>, \u043c\u0435\u0440\u044f\u0435\u043c ns\/op. \u041f\u043e \u0442\u0440\u0438 \u043f\u0440\u043e\u0433\u043e\u043d\u0430, \u0447\u0442\u043e\u0431\u044b JIT \u0443\u0441\u043f\u0435\u043b \u0443\u0441\u0442\u0430\u043a\u0430\u043d\u0438\u0442\u044c\u0441\u044f.<\/p>\n<ul>\n<li>\n<p>literal (same shape): <strong>3.99 \u043d\u0441<\/strong><\/p>\n<\/li>\n<li>\n<p>stepwise (same order): <strong>4.08 \u043d\u0441<\/strong><\/p>\n<\/li>\n<li>\n<p>poly IC (2 shape): <strong>4.65 \u043d\u0441<\/strong><\/p>\n<\/li>\n<li>\n<p>megamorphic (6 shapes): <strong>8.51 \u043d\u0441<\/strong><\/p>\n<\/li>\n<li>\n<p>dict mode (after <code>delete<\/code>): <strong>56.12 \u043d\u0441<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e \u0432\u0438\u0434\u043d\u043e:<\/p>\n<ul>\n<li>\n<p><strong>literal vs stepwise<\/strong> \u2014 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0442. V8 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043e\u0431\u043e\u0438\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>polymorphic IC (2 shape)<\/strong> \u2014 ~15% \u043e\u0432\u0435\u0440\u0445\u0435\u0434. V8 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0442\u044f\u043d\u0435\u0442 \u0434\u043e 4 shape \u043d\u0430 \u043e\u0434\u043d\u043e\u043c call site.<\/p>\n<\/li>\n<li>\n<p><strong>megamorphic (6 shape)<\/strong> \u2014 <strong>x2+ \u043a \u0447\u0442\u0435\u043d\u0438\u044e<\/strong>. \u0423\u0436\u0435 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>delete (dictionary mode)<\/strong> \u2014 <strong>x14 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435<\/strong>. \u0411\u043e\u043b\u044c\u043d\u043e \ud83d\ude42<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430 100k RPS \u00d7 50 \u0447\u0442\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u0435\u0439 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 dict-mode \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u2014 \u043f\u043e\u0442\u0435\u0440\u044f ~260 \u043c\u0441 CPU\/\u0441.<\/p>\n<p><strong>\u0410 \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0430 Node 22?<\/strong><\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u2014 \u0442\u0435 \u0436\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043d\u0430 Node 22:<\/p>\n<ul>\n<li>\n<p>literal: <strong>11.0 \u2192 4.0 \u043d\u0441<\/strong> (x2.8)<\/p>\n<\/li>\n<li>\n<p>stepwise: <strong>11.1 \u2192 4.1 \u043d\u0441<\/strong> (x2.7)<\/p>\n<\/li>\n<li>\n<p>poly (2 shape): <strong>10.3 \u2192 4.7 \u043d\u0441<\/strong> (x2.2)<\/p>\n<\/li>\n<li>\n<p>megamorphic: <strong>14.1 \u2192 8.5 \u043d\u0441<\/strong> (x1.7)<\/p>\n<\/li>\n<li>\n<p>dict mode: <strong>56.8 \u2192 56.1 \u043d\u0441<\/strong> (=)<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e:<\/p>\n<ul>\n<li>\n<p><strong>Fast path \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043b\u0438\u0437\u0430\u043c\u0438 \u0441\u0442\u0430\u043b ~x2.5 \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/strong> TurboFan \u0438 Maglev \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0442\u044e\u043d\u0438\u0442\u044c\u0441\u044f, \u043c\u043e\u043d\u043e\u0445\u0440\u043e\u043c\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u043d\u0430 Node 24 \u2014 4 \u043d\u0441 \u043f\u0440\u043e\u0442\u0438\u0432 11 \u043d\u0430 Node 22.<\/p>\n<\/li>\n<li>\n<p><strong>Dict mode \u2014 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430.<\/strong> 56 \u043d\u0441 \u043d\u0430 \u043e\u0431\u0435\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445. \u042d\u0442\u043e C++ hashmap lookup, JIT \u0442\u0430\u043c \u043d\u0435 \u0438\u0433\u0440\u0430\u0435\u0442, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0447\u0435\u0433\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 fast\/slow \u0440\u0430\u0441\u0442\u0451\u0442.<\/strong> \u041d\u0430 Node 22 <code>delete<\/code> \u0431\u044b\u043b x5 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 literal\u2019\u0430, \u043d\u0430 Node 24 \u2014 \u0443\u0436\u0435 <strong>x14<\/strong>. Fast path \u0443\u0445\u043e\u0434\u0438\u0442 \u0432\u043f\u0435\u0440\u0451\u0434, slow path \u0441\u0442\u043e\u0438\u0442.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b\u0432\u043e\u0434: \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u043d\u043e\u0432\u044b\u043c V8 \u0441\u0438\u0434\u0435\u0442\u044c \u0432 dictionary mode \u0438\u043b\u0438 megamorphic IC \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u0441\u0451 \u0434\u043e\u0440\u043e\u0436\u0435 <em>\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e<\/em> \u201c\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e\u201d \u043a\u043e\u0434\u0430.<\/p>\n<p><strong>\u0410 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e?<\/strong><\/p>\n<ul>\n<li>\n<p>\u0412 hot path \u2014 <strong>\u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b<\/strong>, \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u0441\u0440\u0430\u0437\u0443. \u041d\u0435 \u0437\u043d\u0430\u0435\u0448\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u043e\u0436 <code>null<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u044f \u0432\u043e \u0432\u0441\u0435\u0445 \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u2014 <strong>\u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435<\/strong>. \u0414\u0435\u043b\u0430\u0435\u0448\u044c <code>{ id, name }<\/code>, \u0434\u0435\u043b\u0430\u0439 \u0432\u0435\u0437\u0434\u0435 <code>{ id, name }<\/code>.<\/p>\n<\/li>\n<li>\n<p><code><strong>delete<\/strong><\/code><strong> \u2014 \u043d\u0435 \u043d\u0443\u0436\u043e\u043d<\/strong>. \u0422\u043e\u043b\u044c\u043a\u043e <code>obj.field = null<\/code> (\u0438\u043b\u0438 <code>undefined<\/code>).<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0438 \u0447\u0430\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u2014 <strong>\u043a\u043b\u0430\u0441\u0441<\/strong> \u0438\u043b\u0438 <strong>\u0444\u0430\u0431\u0440\u0438\u043a\u0430<\/strong>. \u041e\u0434\u0438\u043d shape \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0434\u0438\u043d call site \u0432 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043d\u0430 \u0432\u0441\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u0436\u0438\u0437\u043d\u0438.: \u0447\u0435\u0442\u044b\u0440\u0435 shape \u043f\u043e\u0442\u043e\u043b\u043e\u043a V8, \u0434\u0430\u043b\u044c\u0448\u0435 generic.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0427\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435?<\/strong><\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442 \u0432 JS \u043d\u0435 \u00ab\u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044c\u00bb. \u042d\u0442\u043e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0441 V8: \u0442\u044b \u043e\u0431\u0435\u0449\u0430\u0435\u0448\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 shape, V8 \u043e\u0431\u0435\u0449\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0447\u0435\u0440\u0435\u0437 hidden classes \u0438 inline cache. \u041d\u0430\u0440\u0443\u0448\u0430\u0435\u0448\u044c \u2014 \u0441\u044a\u0435\u0437\u0436\u0430\u0435\u0448\u044c \u0432 polymorphic, \u043f\u043e\u0442\u043e\u043c megamorphic, \u043f\u043e\u0442\u043e\u043c dictionary mode. \u0421 \u043a\u0430\u0436\u0434\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u0434\u043e\u0440\u043e\u0436\u0435.<\/p>\n<p>\u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c CRUD \u044d\u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u043e. \u041d\u0430 hot path \u2014 \u044d\u0442\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 CPU \u0438 \u0437\u0430\u043c\u0435\u0442\u043d\u044b\u0435 \u0445\u0432\u043e\u0441\u0442\u044b \u043f\u043e p99.<\/p>\n<p><code>Date.now()<\/code> \u0442\u0440\u0430\u0442\u0438\u043b CPU \u043d\u0430 syscall, <code>parseFloat<\/code> \u2014 \u043d\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433, \u043f\u043b\u043e\u0445\u043e\u0439 shape \u2014 \u043d\u0430 cache miss. \u0410 \u043f\u043e\u0442\u043e\u043c \u0433\u043e\u0432\u043e\u0440\u044f\u0442: \u201c\u043e\u0439 \u0434\u0430 \u043d\u0443 \u043a\u0430\u043a\u043e\u0439 Node, \u043e\u043d \u0436\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0430 Go \u0438 \u043f\u043e\u0439\u0434\u0435\u043c \u0437\u0430 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u044b\u043c \u043b\u0430\u0442\u0435 \u043d\u0430 \u0440\u0430\u0441\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u201d<\/p>\n<p>\u041d\u043e shape, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u0438. \u0414\u0430\u0436\u0435 \u043f\u0440\u0438 \u0442\u043e\u043c \u0436\u0435 hidden class \u0441\u043c\u0435\u043d\u0430 \u0442\u0438\u043f\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u043e\u043b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e V8 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u0430 <code>number<\/code>, <code>string<\/code> \u0438 <code>null<\/code>, \u043f\u0440\u0438 \u0447\u0451\u043c \u0442\u0443\u0442 <code>Smi<\/code>, <code>Double<\/code>, <code>HeapObject<\/code> \u0438 <code>Tagged<\/code> \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u043e\u0432\u0435\u0442 \u00ab\u043f\u043e\u043b\u043e\u0436\u0438 <code>null<\/code> \u0437\u0430\u0440\u0430\u043d\u0435\u0435\u00bb \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f.<\/p>\n<p><em>Node \u0431\u044b\u0441\u0442\u0440\u044b\u0439. \u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0439 \u0435\u043c\u0443.<\/em><\/p>\n<p><strong>\u0427\u0442\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c?<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/mathiasbynens.be\/notes\/shapes-ics\" rel=\"noopener noreferrer nofollow\">V8 internals: hidden classes &amp; inline caches<\/a> \u2014 Mathias Bynens, must-read<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/v8.dev\/blog\/fast-properties\" rel=\"noopener noreferrer nofollow\">Fast properties in V8<\/a> \u2014 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043b\u043e\u0433 V8<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/v8.dev\/blog\/elements-kinds\" rel=\"noopener noreferrer nofollow\">Elements kinds in V8<\/a> \u2014 \u043f\u0440\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0438 \u0438\u0445 shapes<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/live.vkvideo.ru\/piterjs\/record\/fcded7fe-9136-43c0-a16e-161e5855f205?tab=video&amp;tc=1304\" rel=\"noopener noreferrer nofollow\">PiterJS#91<\/a> \u2014 \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043a\u043b\u0430\u0434\u0430<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/t.me\/zero_deps\/103\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0441\u0442 \u0432 \u0422\u0413<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/zerodeps-tech\/\" rel=\"noopener noreferrer nofollow\">zerodeps-tech\/object-shapes-bench<\/a> \u2014 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1066944\/\">https:\/\/habr.com\/ru\/articles\/1066944\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u0440\u043e \u043c\u0438\u043a\u0440\u043e-\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e. \u041f\u0440\u043e, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0441\u0430\u043c\u0443\u044e \u0431\u0435\u0437\u043e\u0431\u0438\u0434\u043d\u0443\u044e \u0432\u0435\u0449\u044c: \u043e\u0431\u044b\u0447\u043d\u044b\u0439 {}.[object Object] \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u0447\u0442\u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0435\u0439. \u0421\u043e\u0437\u0434\u0430\u043b \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u0430\u043f\u0438\u0445\u0430\u043b \u043f\u043e\u043b\u0435\u0439 \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0443\u0434\u0430\u043b\u0438\u043b \u043d\u0435\u043d\u0443\u0436\u043d\u043e\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0437\u0430\u0431\u044b\u043b. \u041d\u043e, \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e, \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0434\u043b\u044f \u0442\u0435\u0431\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0434\u043b\u044f V8, \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0439 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u0430 \u201c\u0431\u0435\u0437\u043e\u0431\u0438\u0434\u043d\u044b\u0439\u201d delete \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0441\u0435\u0431\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043f\u0443\u0441\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e.\u0414\u043b\u044f 99% \u0441\u0438\u0441\u0442\u0435\u043c \u044d\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0410 \u0432\u043e\u0442 \u0435\u0441\u043b\u0438 \u0443 \u0442\u0435\u0431\u044f hot path, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0442\u044b\u0441\u044f\u0447 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0438\u043b\u0438 \u0442\u044b \u043f\u0438\u0448\u0435\u0448\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0439 \u043a\u043e\u0434, \u0441\u0442\u043e\u0438\u0442 \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e V8 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441 \u0442\u0432\u043e\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438.\u0418 \u0447\u0435\u0433\u043e \u043e\u043d \u0442\u0430\u043c \u0441 \u043d\u0438\u043c\u0438 \u0434\u0435\u043b\u0430\u0435\u0442?\u041a\u043e\u0433\u0434\u0430 \u0442\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u0448\u044c \u043e\u0431\u044a\u0435\u043a\u0442, V8 \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u00ab\u043c\u0435\u0448\u043e\u043a \u043a\u043b\u044e\u0447\u0435\u0439\u00bb. \u041e\u043d \u0441\u0442\u0440\u043e\u0438\u0442 \u0434\u043b\u044f \u043d\u0435\u0433\u043e hidden class (map \u0432\u043d\u0443\u0442\u0440\u0438 V8) \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 layout: \u043a\u0430\u043a\u0438\u0435 \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e\u043b\u044f, \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u043d\u0438 \u043b\u0435\u0436\u0430\u0442, \u043a\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043f\u043e \u043a\u0430\u043a\u0438\u043c \u043e\u0444\u0441\u0435\u0442\u0430\u043c \u0447\u0438\u0442\u0430\u0442\u044c. \u0421\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u044d\u0442\u043e \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u0430\u043a struct \u0432 C. Hidden class \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430 \u043d\u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0443.Hidden classes \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 transitions \u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 transition tree. \u041a\u043e\u0433\u0434\u0430 \u0442\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0448\u044c \u043f\u043e\u043b\u0435 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443, V8 \u0438\u0434\u0451\u0442 \u043f\u043e \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0443 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e hidden class: \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u0442\u0430\u043a\u0438\u043c \u043f\u043e\u043b\u0435\u043c \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u044b\u0439 hidden class \u0438 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0442\u043a\u0443 \u0434\u0435\u0440\u0435\u0432\u0430.\u0415\u0441\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0434\u0443\u0442 \u043f\u043e \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430\u043c \u0432 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u043d\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0442 \u043e\u0434\u0438\u043d hidden class. \u042d\u0442\u043e \u0434\u0430\u0451\u0442 V8 \u0431\u0430\u0437\u0443 \u0434\u043b\u044f inline cache: \u00ab\u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043e\u0444\u0441\u0435\u0442\u0443 \u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u0435\u0436\u0438\u0442 string, \u0447\u0438\u0442\u0430\u0435\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a\u00bb.\u041a\u043e\u0433\u0434\u0430 hidden classes \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0440\u0430\u0441\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f (\u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443, \u043f\u043e \u0442\u0438\u043f\u0430\u043c, \u043f\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044e), inline cache \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442:monomorphic (\u043e\u0434\u0438\u043d shape \u2014 fast path),polymorphic (\u0434\u043e 4 shapes \u2014 V8 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439, \u0432\u0441\u0451 \u0435\u0449\u0451 \u0431\u044b\u0441\u0442\u0440\u043e),megamorphic (4+ \u2014 V8 \u0441\u0434\u0430\u0451\u0442\u0441\u044f, \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 generic lookup).\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u0442\u0451\u0442 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435.\u0413\u0434\u0435 \u0442\u044b \u0442\u0435\u0440\u044f\u0435\u0448\u044c?\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 vs \u043b\u0438\u0442\u0435\u0440\u0430\u043b:const a = {}a.id = 1a.name = &#8216;jopa&#8217;const b = { id: 1, name: &#8216;jopa&#8217; }\u0415\u0441\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043d\u0430 \u043e\u0434\u0438\u043d hidden class. \u0423 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430 \u0435\u0441\u0442\u044c \u0431\u043e\u043d\u0443\u0441 V8 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 shape \u043a\u0430\u043a boilerplate \u0438 \u043f\u0440\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 \u0430\u043b\u043b\u043e\u0446\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0440\u0430\u0437\u0443 \u0441 \u0433\u043e\u0442\u043e\u0432\u044b\u043c layout, \u0431\u0435\u0437 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e transition tree. \u041d\u043e \u0432 hot loop \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432\u0448\u0435\u043c\u0441\u044f \u0440\u0435\u0436\u0438\u043c\u0435 \u043a\u043e\u043f\u0435\u0435\u0447\u043d\u0430\u044f.\u0425\u0443\u0436\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u043b\u0435\u0439 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442:function makeA(id, name) { return { id, name } }function makeB(name, id) { return { name, id } }\u042d\u0442\u043e \u0443\u0436\u0435 \u0434\u0432\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 hidden class. \u041b\u044e\u0431\u043e\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0438\u0442\u0430\u0435\u0442 obj.id \u0447\u0435\u0440\u0435\u0437 \u044d\u0442\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0438, \u0432\u0438\u0434\u0438\u0442 \u0434\u0432\u0430 shape \u043d\u0430 \u043e\u0434\u043d\u043e\u043c call site \u0438 IC \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f polymorphic. \u0421\u0430\u043c\u043e \u043f\u043e \u0441\u0435\u0431\u0435 \u0435\u0449\u0451 \u043d\u0435 \u0431\u043e\u043b\u044c\u043d\u043e, \u043d\u043e \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435 \u0434\u0432\u0430, \u0430 \u0448\u0435\u0441\u0442\u044c, \u0442\u043e \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 megamorphic.\u0415\u0449\u0451 \u043a\u0435\u0439\u0441 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439:const user = { id, name }if (isAdmin) {  user.role = &#8216;admin&#8217;}\u0427\u0430\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u043c\u0435\u0435\u0442 shape {id, name}, \u0447\u0430\u0441\u0442\u044c \u2014 {id, name, role}. \u0423\u0436\u0435 polymorphic. \u041b\u0443\u0447\u0448\u0435 \u043a\u043b\u0430\u0441\u0442\u044c role: null \u0441\u0440\u0430\u0437\u0443 \u0438 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.delete \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044fdelete user.name\u0412\u043e\u0442 \u0442\u0443\u0442 V8 \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u043e\u0449\u0430\u0435\u0442. delete \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 dictionary mode (\u043e\u043d \u0436\u0435 slow mode, normalized properties). \u042d\u0442\u043e hashmap \u0432\u043c\u0435\u0441\u0442\u043e \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e layout. \u041d\u0438 inline cache, \u043d\u0438 \u043e\u0444\u0441\u0435\u0442\u043e\u0432, \u043a\u0430\u0436\u0434\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 hash lookup \u0432 C++ runtime. \u0418 \u043e\u0431\u0440\u0430\u0442\u043d\u043e V8 \u043e\u0431\u044a\u0435\u043a\u0442 \u0443\u0436\u0435 \u043d\u0435 \u0432\u0435\u0440\u043d\u0451\u0442, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0444\u043e\u0440\u043c\u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c.\u0412\u0440\u043e\u0434\u0435 \u043a\u0430\u043a \u043f\u0430\u043c\u044f\u0442\u044c \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u043b. \u0410 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 Map \u0431\u0435\u0437 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438.\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0439 null \u0438\u043b\u0438 undefined. Shape \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f, \u0434\u0432\u0438\u0436\u043e\u043a \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442 \u0432 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.\u0410 \u0447\u0442\u043e \u043f\u043e \u0446\u0438\u0444\u0440\u0430\u043c?\u0421\u0442\u0435\u043d\u0434: Node 24, \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 \u0442\u0440\u0435\u043c\u044f \u043f\u043e\u043b\u044f\u043c\u0438, \u0432 hot loop \u0447\u0438\u0442\u0430\u0435\u043c obj.id, \u043c\u0435\u0440\u044f\u0435\u043c ns\/op. \u041f\u043e \u0442\u0440\u0438 \u043f\u0440\u043e\u0433\u043e\u043d\u0430, \u0447\u0442\u043e\u0431\u044b JIT \u0443\u0441\u043f\u0435\u043b \u0443\u0441\u0442\u0430\u043a\u0430\u043d\u0438\u0442\u044c\u0441\u044f.literal (same shape): 3.99 \u043d\u0441stepwise (same order): 4.08 \u043d\u0441poly IC (2 shape): 4.65 \u043d\u0441megamorphic (6 shapes): 8.51 \u043d\u0441dict mode (after delete): 56.12 \u043d\u0441\u0427\u0442\u043e \u0432\u0438\u0434\u043d\u043e:literal vs stepwise \u2014 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0442. V8 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043e\u0431\u043e\u0438\u043c\u0438.polymorphic IC (2 shape) \u2014 ~15% \u043e\u0432\u0435\u0440\u0445\u0435\u0434. V8 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0442\u044f\u043d\u0435\u0442 \u0434\u043e 4 shape \u043d\u0430 \u043e\u0434\u043d\u043e\u043c call site.megamorphic (6 shape) \u2014 x2+ \u043a \u0447\u0442\u0435\u043d\u0438\u044e. \u0423\u0436\u0435 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e.delete (dictionary mode) \u2014 x14 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435. \u0411\u043e\u043b\u044c\u043d\u043e :)\u041d\u0430 100k RPS \u00d7 50 \u0447\u0442\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u0435\u0439 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 dict-mode \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u2014 \u043f\u043e\u0442\u0435\u0440\u044f ~260 \u043c\u0441 CPU\/\u0441.\u0410 \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0430 Node 22?\u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u2014 \u0442\u0435 \u0436\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043d\u0430 Node 22:literal: 11.0 \u2192 4.0 \u043d\u0441 (x2.8)stepwise: 11.1 \u2192 4.1 \u043d\u0441 (x2.7)poly (2 shape): 10.3 \u2192 4.7 \u043d\u0441 (x2.2)megamorphic: 14.1 \u2192 8.5 \u043d\u0441 (x1.7)dict mode: 56.8 \u2192 56.1 \u043d\u0441 (=)\u0427\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e:Fast path \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043b\u0438\u0437\u0430\u043c\u0438 \u0441\u0442\u0430\u043b ~x2.5 \u0431\u044b\u0441\u0442\u0440\u0435\u0435. TurboFan \u0438 Maglev \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0442\u044e\u043d\u0438\u0442\u044c\u0441\u044f, \u043c\u043e\u043d\u043e\u0445\u0440\u043e\u043c\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u043d\u0430 Node 24 \u2014 4 \u043d\u0441 \u043f\u0440\u043e\u0442\u0438\u0432 11 \u043d\u0430 Node 22.Dict mode \u2014 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430. 56 \u043d\u0441 \u043d\u0430 \u043e\u0431\u0435\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445. \u042d\u0442\u043e C++ hashmap lookup, JIT \u0442\u0430\u043c \u043d\u0435 \u0438\u0433\u0440\u0430\u0435\u0442, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0447\u0435\u0433\u043e.\u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 fast\/slow \u0440\u0430\u0441\u0442\u0451\u0442. \u041d\u0430 Node 22 delete \u0431\u044b\u043b x5 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 literal\u2019\u0430, \u043d\u0430 Node 24 \u2014 \u0443\u0436\u0435 x14. Fast path \u0443\u0445\u043e\u0434\u0438\u0442 \u0432\u043f\u0435\u0440\u0451\u0434, slow path \u0441\u0442\u043e\u0438\u0442.\u0412\u044b\u0432\u043e\u0434: \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u043d\u043e\u0432\u044b\u043c V8 \u0441\u0438\u0434\u0435\u0442\u044c \u0432 dictionary mode \u0438\u043b\u0438 megamorphic IC \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u0441\u0451 \u0434\u043e\u0440\u043e\u0436\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u201c\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e\u201d \u043a\u043e\u0434\u0430.\u0410 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e?\u0412 hot path \u2014 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b, \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u0441\u0440\u0430\u0437\u0443. \u041d\u0435 \u0437\u043d\u0430\u0435\u0448\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u043e\u0436 null.\u041f\u043e\u043b\u044f \u0432\u043e \u0432\u0441\u0435\u0445 \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u2014 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u0414\u0435\u043b\u0430\u0435\u0448\u044c { id, name }, \u0434\u0435\u043b\u0430\u0439 \u0432\u0435\u0437\u0434\u0435 { id, name }.delete \u2014 \u043d\u0435 \u043d\u0443\u0436\u043e\u043d. \u0422\u043e\u043b\u044c\u043a\u043e obj.field = null (\u0438\u043b\u0438 undefined).\u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0438 \u0447\u0430\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u2014 \u043a\u043b\u0430\u0441\u0441 \u0438\u043b\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0430. \u041e\u0434\u0438\u043d shape \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e.\u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0434\u0438\u043d call site \u0432 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043d\u0430 \u0432\u0441\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u0436\u0438\u0437\u043d\u0438.: \u0447\u0435\u0442\u044b\u0440\u0435 shape \u043f\u043e\u0442\u043e\u043b\u043e\u043a V8, \u0434\u0430\u043b\u044c\u0448\u0435 generic.\u0427\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435?\u041e\u0431\u044a\u0435\u043a\u0442 \u0432 JS \u043d\u0435 \u00ab\u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044c\u00bb. \u042d\u0442\u043e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0441 V8: \u0442\u044b \u043e\u0431\u0435\u0449\u0430\u0435\u0448\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 shape, V8 \u043e\u0431\u0435\u0449\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0447\u0435\u0440\u0435\u0437 hidden classes \u0438 inline cache. \u041d\u0430\u0440\u0443\u0448\u0430\u0435\u0448\u044c \u2014 \u0441\u044a\u0435\u0437\u0436\u0430\u0435\u0448\u044c \u0432 polymorphic, \u043f\u043e\u0442\u043e\u043c megamorphic, \u043f\u043e\u0442\u043e\u043c dictionary mode. \u0421 \u043a\u0430\u0436\u0434\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u0434\u043e\u0440\u043e\u0436\u0435.\u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c CRUD \u044d\u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u043e. \u041d\u0430 hot path \u2014 \u044d\u0442\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 CPU \u0438 \u0437\u0430\u043c\u0435\u0442\u043d\u044b\u0435 \u0445\u0432\u043e\u0441\u0442\u044b \u043f\u043e p99.Date.now() \u0442\u0440\u0430\u0442\u0438\u043b CPU \u043d\u0430 syscall, parseFloat \u2014 \u043d\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433, \u043f\u043b\u043e\u0445\u043e\u0439 shape \u2014 \u043d\u0430 cache miss. \u0410 \u043f\u043e\u0442\u043e\u043c \u0433\u043e\u0432\u043e\u0440\u044f\u0442: \u201c\u043e\u0439 \u0434\u0430 \u043d\u0443 \u043a\u0430\u043a\u043e\u0439 Node, \u043e\u043d \u0436\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0430 Go \u0438 \u043f\u043e\u0439\u0434\u0435\u043c \u0437\u0430 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u044b\u043c \u043b\u0430\u0442\u0435 \u043d\u0430 \u0440\u0430\u0441\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u201d\u041d\u043e shape, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u0438. \u0414\u0430\u0436\u0435 \u043f\u0440\u0438 \u0442\u043e\u043c \u0436\u0435 hidden class \u0441\u043c\u0435\u043d\u0430 \u0442\u0438\u043f\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u043e\u043b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e V8 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u0430 number, string \u0438 null, \u043f\u0440\u0438 \u0447\u0451\u043c \u0442\u0443\u0442 Smi, Double, HeapObject \u0438 Tagged \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u043e\u0432\u0435\u0442 \u00ab\u043f\u043e\u043b\u043e\u0436\u0438 null \u0437\u0430\u0440\u0430\u043d\u0435\u0435\u00bb \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f.Node \u0431\u044b\u0441\u0442\u0440\u044b\u0439. \u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0439 \u0435\u043c\u0443.\u0427\u0442\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c?V8 internals: hidden classes &amp; inline caches \u2014 Mathias Bynens, must-readFast properties in V8 \u2014 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043b\u043e\u0433 V8Elements kinds in V8 \u2014 \u043f\u0440\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0438 \u0438\u0445 shapesPiterJS#91 \u2014 \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043a\u043b\u0430\u0434\u0430\u041f\u043e\u0441\u0442 \u0432 \u0422\u0413zerodeps-tech\/object-shapes-bench \u2014 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 https:\/\/habr.com\/ru\/articles\/1066944\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-489843","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/489843","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=489843"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/489843\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=489843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=489843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=489843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}