{"id":295184,"date":"2019-11-25T21:00:27","date_gmt":"2019-11-25T21:00:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=295184"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=295184","title":{"rendered":"\u0420\u0435\u0448\u0430\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0447\u0430\u0441\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 C++"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/477404\/\">\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u041a\u043e\u043c\u043f\u0430\u043d\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e, \u043f\u0438\u0448\u0435\u0442 \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0438 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0435 \u0431\u0438\u0437\u043d\u0435\u0441 \u043e\u0442 DDoS-\u0430\u0442\u0430\u043a, \u0431\u043e\u0442\u043e\u0432, \u043f\u0430\u0440\u0441\u0435\u0440\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043d\u043e\u0433\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u043b\u0435\u0436\u0438\u0442 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u0430\u043a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Reverse_proxy\">\u0440\u0435\u0432\u0435\u0440\u0441\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u0431\u044a\u0435\u043c\u044b \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0438, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043e\u0442\u0441\u0435\u0438\u0432\u0430\u044f \u0432\u0441\u0435 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0435.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u043d\u0435\u043b\u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u043c \u0442\u0440\u0430\u0444\u0438\u043a\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0441\u0442\u0430\u043d\u0446\u0438\u0439 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e. \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u043f\u044b\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c C++, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b \u0438 \u043d\u0430\u0431\u043e\u0440 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c boost.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0420\u0435\u0432\u0435\u0440\u0441\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u0440\u0435\u0432\u0435\u0440\u0441\u0438\u0432\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 C++ \u0438 boost.asio. \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0441\u0435\u0441\u0441\u0438\u0438. \u0421\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0441\u0435\u0441\u0441\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u043c, \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c. \u0422\u0430\u043a\u0436\u0435 \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0439 \u0431\u0443\u0444\u0435\u0440, \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u043e\u043a\u0435\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u0438 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0441\u043e\u043a\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0445 \u0441\u0435\u0441\u0441\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a boost.asio. \u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u043c \u0431\u0443\u0444\u0435\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0430\u043c \u0436\u0435.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0440\u0435\u0432\u0435\u0440\u0441\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u043a\u0441\u0438, \u0441\u0442\u0430\u043d\u0435\u0442 \u044f\u0441\u043d\u043e, \u0447\u0442\u043e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0435\u043b\u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0442\u0440\u0430\u0444\u0438\u043a \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0422\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u043d\u0430\u0440\u0430\u0449\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430. \u0417\u0430\u0434\u0443\u043c\u0430\u0435\u043c\u0441\u044f \u043e \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u0432\u043e\u043a\u0435\u0440\u0430\u0445 \u0438 \u043f\u0443\u043b\u0430\u0445 \u0434\u043b\u044f io \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043d\u043e\u0433\u043e\u043c \u0434\u0440\u0443\u0433\u043e\u043c. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043e \u043f\u0440\u0435\u0436\u0434\u0435\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u0445, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u044f\u043c\u0438.<\/p>\n<p>  \u041e \u043a\u0430\u043a\u043e\u043c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u0434\u0435\u0442 \u0440\u0435\u0447\u044c? \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0438\u0436\u0435: \u0432 \u043d\u0435\u043c \u043c\u044b \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043e\u0434\u0438\u043d \u0445\u0435\u0434\u0435\u0440 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u0434\u0432\u0430. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0441\u0445\u043e\u0436\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0440\u0430\u0441\u0442\u0435\u0442 \u0441 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u0411\u0435\u0437\u0434\u0443\u043c\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043d\u0438 \u0432 \u043a\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043b\u044c\u0437\u044f! \u0415\u0441\u043b\u0438 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e 1% \u043e\u0442 \u0432\u0441\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 99% \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c\u0438, \u0442\u043e \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434 \u044d\u0442\u043e\u0442 1%. \u041f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0432 \u044d\u0442\u043e\u043c boost::asio::const_buffer \u0438 boost::asio::mutable_buffer, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u0434\u043d\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p>  \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"plaintext\">Browser -&gt; Proxy:  &gt; POST \/ HTTP\/1.1 &gt; User-Agent: curl\/7.29.0 &gt; Host: 127.0.0.1:50080 &gt; Accept: *\/* &gt; Content-Length: 5888903 &gt; Content-Type: application\/x-www-form-urlencoded &gt; ...  Proxy -&gt; Service:  &gt; POST \/ HTTP\/1.1 &gt; User-Agent: curl\/7.29.0 &gt; Host: 127.0.0.1:50080 &gt; Accept: *\/* &gt; Transfer-Encoding: chunked &gt; Content-Type: application\/x-www-form-urlencoded &gt; Expect: 100-continue &gt; ...  Service -&gt; Proxy:  &lt; HTTP\/1.1 200 OK  Proxy -&gt; Browser  &lt; HTTP\/1.1 200 OK<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h3>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u043c\u0435\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u043d\u0430\u0434\u0435\u043b\u0435\u043d\u043e \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u0435\u0433\u043e \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u0435, \u043c\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e-\u0442\u0430\u043a\u0438 \u0434\u043e\u043b\u0433\u043e \u0440\u0430\u0434\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u0445\u043e\u0440\u043e\u0448\u043e \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  \u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0443 \u043d\u0430\u0441 \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u0441 \u043f\u0440\u0438\u0445\u043e\u0434\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b\u0440\u043e\u0441 \u0438 \u0442\u0440\u0430\u0444\u0438\u043a. \u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0430\u0442\u0430\u043a. \u041f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0432 \u0441\u0435\u0440\u0432\u0438\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u044b <a href=\"https:\/\/perf.wiki.kernel.org\/index.php\/Tutorial\">perf<\/a>, \u043c\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043a\u0443\u0447\u0435\u0439 \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0442\u043e\u043f\u0435. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043a\u043e\u043d\u0442\u0443\u0440\u0435 \u0441 \u043f\u043e\u043c\u043e\u0448\u044c\u044e <a href=\"https:\/\/github.com\/yandex\/yandex-tank\">yandex-tank<\/a> \u0438 \u043f\u0430\u0442\u0440\u043e\u043d\u043e\u0432, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0430. \u041f\u043e\u0434\u0446\u0435\u043f\u0438\u0432\u0448\u0438\u0441\u044c \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/software.intel.com\/en-us\/vtune\">amplifier<\/a> \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443\u2026<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 amplifier (woslab):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tz\/ks\/d9\/tzksd9oddf-rhcfphtkxkun-pdg.png\"><\/p>\n<p>  \u041d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 operator new \u0440\u0430\u0431\u043e\u0442\u0430\u043b 67 \u0441\u0435\u043a\u0443\u043d\u0434, \u0430 operator delete \u0438 \u0442\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u2014 97 \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<p>  \u0422\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043d\u0430\u0441 \u0440\u0430\u0441\u0441\u0442\u0440\u043e\u0438\u043b\u0430. \u041a\u0430\u043a \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0435\u0431\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 operator new \u0438 operator delete? \u041b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043e\u0442\u043a\u0430\u0437\u0430\u0432\u0448\u0438\u0441\u044c \u043e\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0445 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u0447\u0430\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u043a\u0443\u0447\u0435. \u041c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0442\u0440\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u0445. \u0414\u0432\u0430 \u0438\u0437 \u043d\u0438\u0445 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435: <a href=\"https:\/\/en.wikipedia.org\/wiki\/Object_pool_pattern\">object pool<\/a> \u0438 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Stack-based_memory_allocation\">stack allocation<\/a>. \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0445\u043e\u0440\u043e\u0448\u043e \u043b\u043e\u0436\u0430\u0442\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0443\u043b \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u0441\u0442\u0435\u043a\u0435, \u0438\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0432 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0435 io \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u043c. \u041b\u0443\u0447\u0448\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435, \u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u043c \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c. \u041d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043d <a href=\"https:\/\/en.wikipedia.org\/wiki\/Slab_allocation\">slab allocation<\/a> \u0438\u043b\u0438 slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>  \u0418\u0434\u0435\u044f slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0435 \u043d\u043e\u0432\u0430. \u041e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d\u0430 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 Solaris, \u043f\u0435\u0440\u0435\u043a\u043e\u0447\u0435\u0432\u0430\u0432 \u043f\u043e\u0437\u0436\u0435 \u0432 \u044f\u0434\u0440\u043e Linux, \u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0440\u043e\u0449\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043f\u0443\u043b\u0435. \u041c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437 \u043f\u0443\u043b\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d, \u0430 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 operator new \u0438 operator delete! \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 \u044f\u0434\u0440\u0435 slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0435\u043c\u0430\u0444\u043e\u0440\u043e\u0432, \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u0444\u0430\u0439\u043b\u043e\u0432, \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0412 \u043d\u0430\u0448\u0435\u043c \u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u043b\u0435\u0433\u043b\u043e \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0435 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u0441\u0435 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0438\u0445.<\/p>\n<p>  \u0414\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 (slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/zb\/k2\/u8\/zbk2u8m0jexhso3nmkttzxkvrw0.png\"><\/p>\n<p>  \u041f\u043e\u043c\u0438\u043c\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e slab \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b \u0435\u0441\u0442\u044c \u0432 \u044f\u0434\u0440\u0435, \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0432 \u044e\u0437\u0435\u0440\u0441\u043f\u0435\u0439\u0441\u0435. \u0418\u0445 \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u0430 \u0442\u0435\u0445, \u0447\u0442\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u044e\u0442\u0441\u044f, \u0442\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b. \u041c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/github.com\/tarantool\/small\">libsmall<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e <a href=\"https:\/\/github.com\/tarantool\/tarantool\">tarantool<\/a>. \u0412 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435.<\/p>\n<ul>\n<li>small::allocator<\/li>\n<li>small::slab_cache (thread local)<\/li>\n<li>small::slab<\/li>\n<li>small::arena<\/li>\n<li>small::quota<\/li>\n<\/ul>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 small::slab \u2014 \u044d\u0442\u043e \u043f\u0443\u043b \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 small::slab_cache \u2014 \u044d\u0442\u043e \u043a\u044d\u0448, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 \u043f\u0443\u043b\u043e\u0432 \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 small::allocator \u2014 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043a\u044d\u0448, \u0438\u0449\u0435\u0442 \u0432 \u043d\u0435\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0443\u043b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b small::arena \u0438 small::quota \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043d\u0438\u0436\u0435.<\/p>\n<h3>\u041e\u0431\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 libsmall \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0430 C, \u0430 \u043d\u0435 \u043d\u0430 C++, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0435\u0440\u0442\u043e\u043a \u0434\u043b\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 C++.<\/p>\n<ul>\n<li>variti::slab_allocator<\/li>\n<li>variti::slab<\/li>\n<li>variti::thread_local_slab<\/li>\n<li>variti::slab_allocate_shared<\/li>\n<\/ul>\n<p>  \u041a\u043b\u0430\u0441\u0441 variti::slab_allocator \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u0430. \u0412\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 variti::slab \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0431\u0438\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 libsmall. \u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d variti::thread_local_slab? \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u044d\u0448\u0438 slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f thread local \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u0432\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u043a\u044d\u0448\u0435\u0439. \u0421\u0434\u0435\u043b\u0430\u043d\u043e \u044d\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0443\u043b\u044e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u043c\u044b \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u0441\u0432\u043e\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 variti::slab, \u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0435\u043c\u0443 \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0438 variti::thread_local_slab. \u041f\u0440\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e variti::slab_allocate_shared \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>  \u0412\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 variti::slab_allocator \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u0423 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0431\u0430\u0439\u043d\u0434\u0430 \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 void \u043d\u0430 char. \u0418\u0437 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u0435\u043e\u0431\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 nullptr \u0432 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 std::bad_alloc \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u043c\u044f\u0442\u044c. \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c, \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u0440\u043e\u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u044c \u043e\u0431\u0435\u0440\u0442\u043a\u0438 variti::thread_local_slab.<\/p>\n<p>  \u0421\u043d\u0438\u043f\u043f\u0435\u0442 (slab_allocator.hpp):<\/p>\n<pre><code class=\"cpp\">template &lt;typename T&gt; class slab_allocator { public:    using value_type = T;   using pointer = value_type*;   using const_pointer = const value_type*;   using reference = value_type&amp;;   using const_reference = const value_type&amp;;    template &lt;typename U&gt;   struct rebind {     using other = slab_allocator&lt;U&gt;;   };    slab_allocator() {}    template &lt;typename U&gt;   slab_allocator(const slab_allocator&lt;U&gt;&amp; other) {}    T* allocate(size_t n, const void* = nullptr) {     auto p = static_cast&lt;T*&gt;(thread_local_slab::allocate(sizeof(T) * n));     if (!p &amp;&amp; n)       throw std::bad_alloc();     return p;   }    void deallocate(T* p, size_t n) {     thread_local_slab::deallocate(p, sizeof(T) * n);   } };  template &lt;&gt; class slab_allocator&lt;void&gt; { public:    using value_type = void;   using pointer = void*;   using const_pointer = const void*;    template &lt;typename U&gt;   struct rebind {     typedef slab_allocator&lt;U&gt; other;   }; };<\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 variti::slab. \u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043c\u044b \u043e\u0442\u0432\u043e\u0434\u0438\u043c \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 1 GiB \u043f\u0430\u043c\u044f\u0442\u0438. \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0443\u043b\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 1 MiB. \u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 2 \u0431\u0430\u0439\u0442\u0430 (\u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 libsmall \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442 \u0435\u0433\u043e \u0434\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e \u2014 8 \u0431\u0430\u0439\u0442\u043e\u0432). \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0448\u0435 slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u0440\u0430\u0442\u043d\u044b\u0439 \u0434\u0432\u0443\u043c (\u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043e\u0439 2.f). \u0418\u0442\u043e\u0433\u043e, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 8, 16, 32 \u0438 \u0442.\u0434. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 24 \u0431\u0430\u0439\u0442\u0430, \u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438. \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u043d\u0435\u0442 \u0432\u0430\u043c \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432 \u043f\u0443\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 32 \u0431\u0430\u0439\u0442\u0430. \u041e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f 8 \u0431\u0430\u0439\u0442 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u0430\u0438\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u0421\u043d\u0438\u043f\u043f\u0435\u0442 (slab.hpp):<\/p>\n<pre><code class=\"cpp\">inline void* phys_to_virt_p(void* p) { return reinterpret_cast&lt;char*&gt;(p) + sizeof(std::thread::id); } inline size_t phys_to_virt_n(size_t n) { return n - sizeof(std::thread::id); } inline void* virt_to_phys_p(void* p) { return reinterpret_cast&lt;char*&gt;(p) - sizeof(std::thread::id); } inline size_t virt_to_phys_n(size_t n) { return n + sizeof(std::thread::id); }  inline std::thread::id&amp; phys_thread_id(void* p) { return *reinterpret_cast&lt;std::thread::id*&gt;(p); }    class slab : public noncopyable { public:    slab() {     small::quota_init(&amp; quota_, 1024 * 1024 * 1024);     small::slab_arena_create(&amp;arena_, &amp; quota_, 0, 1024 * 1024, MAP_PRIVATE);     small::slab_cache_create(&amp;cache_, &amp;arena_);     small::allocator_create(&amp;allocator_, &amp;cache_, 2, 2.f);   }    ~slab() {     small::allocator_destroy(&amp;allocator_);     small::slab_cache_destroy(&amp;cache_);     small::slab_arena_destroy(&amp;arena_);   }    void* allocate(size_t n) {     auto phys_n = virt_to_phys_n(n);     auto phys_p = small::malloc(&amp;allocator_, phys_n);     if (!phys_p)       return nullptr;     phys_thread_id(phys_p) = std::this_thread::get_id();     return phys_to_virt_p(phys_p);   }    void deallocate(const void* p, size_t n) {     auto phys_p = virt_to_phys_p(const_cast&lt;void*&gt;(p));     auto phys_n = virt_to_phys_n(n);     assert(phys_thread_id(phys_p) == std::this_thread::get_id());     small::free(&amp;allocator_, phys_p, phys_n);   }  private:    small::quota quota_;   small::slab_arena arena_;   small::slab_cache cache_;   small::allocator allocator_; };<\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0441\u0430\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 variti::slab. \u0422\u0430\u043a \u043a\u0430\u043a \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u043e\u043d \u0441\u0432\u043e\u0439 (\u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u043e thread local), \u0442\u043e \u043e\u0431\u0449\u0438\u0439 \u043b\u0438\u043c\u0438\u0442 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u043d\u0435 1 GiB, \u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u044f\u043c\u043e \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u0435\u043d \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u0414\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 (std::thread::id):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/_8\/65\/jy\/_865jyoyp0qqoz7-tgsgmjsc9b0.png\"><\/p>\n<p>  \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 thread local \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u2014 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412\u044b \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u043f\u043e\u0442\u043e\u043a\u0435. \u0414\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 boost.asio \u043f\u043e\u0440\u043e\u0439 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e. \u0414\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0432\u0435\u0434\u043e\u043c\u043e \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u043c\u044b \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u043e\u0442\u043e\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 allocate. \u0417\u0430\u0442\u0435\u043c \u044d\u0442\u043e\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 deallocate. \u041f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0432 \u044d\u0442\u043e\u043c \u0445\u0435\u043b\u043f\u0435\u0440\u044b phys_to_virt_p \u0438 virt_to_phys_p.<\/p>\n<p>  \u0421\u043d\u0438\u043f\u043f\u0435\u0442 (thread_local_slab.hpp):<\/p>\n<pre><code class=\"cpp\">class thread_local_slab : public noncopyable { public:    static void initialize();   static void finalize();   static void* allocate(size_t n);   static void deallocate(const void* p, size_t n); };<\/code><\/pre>\n<p>  \u0421\u043d\u0438\u043f\u043f\u0435\u0442 (thread_local_slab.cpp):<\/p>\n<pre><code class=\"cpp\">static thread_local slab* slab_;  void thread_local_slab::initialize() { slab_ = new slab(slab_cfg_); } void thread_local_slab::finalize() { delete slab_; } void* thread_local_slab::malloc(size_t n) { return slab_-&gt;malloc(n); } void thread_local_slab::free(const void* p, size_t n) { slab_-&gt;free(p, n); }<\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u043f\u043e\u0442\u043e\u043a\u043e\u043c \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f (\u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 io \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430\u043c\u0438), \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c. \u0412\u0441\u0435, \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442, \u044d\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044f \u0435\u0433\u043e io \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0432 std::shared_ptr \u0441 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c \u0434\u0435\u043b\u0438\u0442\u0435\u0440\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0441\u0440\u0430\u0437\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0430 \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u0432 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u043c \u0440\u0430\u043d\u0435\u0435 io \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435. \u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 io \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c.<\/p>\n<p>  \u0421\u043d\u0438\u043f\u043f\u0435\u0442 (slab_helper.hpp):<\/p>\n<pre><code class=\"cpp\">template &lt;typename T, typename Allocator, typename... Args&gt; std::shared_ptr&lt;T&gt; slab_allocate_shared(Allocator allocator, Args... args) {   T* p = allocator.allocate(1);   new ((void*)p) T(std::forward&lt;Args&gt;(args)...);   std::shared_ptr&lt;T&gt; ptr(p, [allocator](T* p) {     p-&gt;~T();     allocator.deallocate(p);   });   return ptr; };  template &lt;typename T, typename Allocator, typename... Args&gt; std::shared_ptr&lt;T&gt; slab_allocate_shared(Allocator allocator, boost::asio::io_service* io, Args... args) {   T* p = allocator.allocate(1);   new ((void*)p) T(std::forward&lt;Args&gt;(args)...);   std::shared_ptr&lt;T&gt; ptr(p, [allocator, io](T* p) {     io-&gt;post([allocator, p]() {       p-&gt;~T();       allocator.deallocate(p);     });   });   return ptr; };<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0430\u0434 \u043e\u0431\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435\u043c libsmall \u0431\u044b\u043b\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430, \u043c\u044b \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u043b\u0438 \u043d\u0430 slab \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b \u0447\u0430\u043d\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0431\u0443\u0444\u0435\u0440\u0430. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043c\u044b \u043f\u043e\u0448\u043b\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 slab \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u043c\u0443 \u0431\u0443\u0444\u0435\u0440\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438 \u043a\u043e \u0432\u0441\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0439.<\/p>\n<ul>\n<li>variti::chunk<\/li>\n<li>variti::streambuf<\/li>\n<li>variti::server_session<\/li>\n<li>variti::client_session<\/li>\n<\/ul>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0435\u0448\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e: \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 slab \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438. \u0418 \u0435\u0441\u043b\u0438 \u0441 \u043f\u0435\u0440\u0432\u044b\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0445 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0435\u043d\u0438\u0439 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e (\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043a \u043f\u0440\u043e\u0441\u0442\u044b\u043c), \u0442\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c\u0438 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044f\u043c\u0438.<\/p>\n<ul>\n<li>std::list<\/li>\n<li>std::deque<\/li>\n<li>std::vector<\/li>\n<li>std::string<\/li>\n<li>std::map<\/li>\n<li>std::unordered_map<\/li>\n<\/ul>\n<p>  \u041e\u0434\u043d\u043e \u0438\u0437 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c (\u0447\u0435\u043c \u043e\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435, \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435). \u0412 \u0442\u0430\u043a\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u043b\u043e\u0436\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e slab \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u043e\u0432, \u0430 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043d\u0435\u0442.<\/p>\n<p>  \u0414\u043b\u044f std::list slab \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u042d\u0442\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u043c\u0435\u0435\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 std::list \u0432 slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043d\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u0432\u044b\u0448\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f! \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0438 std::map. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043b\u0438\u0448\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e \u043d\u0435 \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0430 \u0434\u0435\u0440\u0435\u0432\u043e.<\/p>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 std::deque \u0432\u0441\u0435 \u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u042d\u0442\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u0447\u0430\u043d\u043a\u0438. \u041f\u043e\u043a\u0430 \u0447\u0430\u043d\u043a\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0442\u043e\u0447\u043d\u043e, std::deque \u0432\u0435\u0434\u0435\u0442 \u0441\u0435\u0431\u044f \u0442\u0430\u043a\u0436\u0435, \u043a\u0430\u043a \u0438 std::list, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f, \u044d\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u0431\u043b\u043e\u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f. \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f slab \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043d\u043e\u0432\u044b\u043c \u0442\u0438\u043f\u043e\u043c. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u043f\u043e\u0434\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0442\u0438. \u042d\u0442\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043d\u0435 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043b\u0438\u0431\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 std::deque \u0442\u0430\u043c, \u0433\u0434\u0435 \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043b\u0438\u0431\u043e \u043e\u0442\u0434\u0430\u043b\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0435 std::list.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0437\u044f\u0442\u044c std::vector \u0438 std::string, \u0442\u043e \u0432 \u043d\u0438\u0445 \u0432\u0441\u0435 \u0435\u0449\u0435 \u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u0442\u0438\u0445 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0432 \u0447\u0435\u043c-\u0442\u043e \u0441\u0445\u043e\u0436\u0430 \u0441 std::deque, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0438\u0445 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u0440\u0430\u0441\u0442\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u041c\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u043b\u0438 std::vector \u0438 std::string \u043d\u0430 std::deque, \u0430 \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 std::list. \u0414\u0430, \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0433\u0434\u0435-\u0442\u043e \u0434\u0430\u0436\u0435 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u044d\u0442\u043e \u043f\u043e\u0432\u043b\u0438\u044f\u043b\u043e \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0441\u0438\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0440\u0430\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0441\u0435 \u0438 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u043e\u0441\u044c.<\/p>\n<p>  \u0420\u043e\u0432\u043d\u043e \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b\u0438 \u0438 \u0441 std::unordered_map, \u043e\u0442\u043a\u0430\u0437\u0430\u0432\u0448\u0438\u0441\u044c \u043e\u0442 \u043d\u0435\u0433\u043e \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u0441\u0430\u043c\u043e\u043f\u0438\u0441\u0430\u043d\u043e\u0433\u043e variti::flat_map, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0447\u0435\u0440\u0435\u0437 std::deque. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0441 \u0445\u0435\u0434\u0435\u0440\u0430\u043c\u0438 http \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 nginx.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434<\/h3>\n<p>  \u0417\u0430\u043a\u043e\u043d\u0447\u0438\u0432 \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 \u0441\u0435\u0441\u0441\u0438\u0439 \u043d\u0430 slab \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b, \u043c\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0443\u0447\u0435\u0439 \u0431\u043e\u043b\u0435\u0435, \u0447\u0435\u043c \u0432 \u043f\u043e\u043b\u0442\u043e\u0440\u0430 \u0440\u0430\u0437\u0430.<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 amplifier (coldslab):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ls\/yx\/l_\/lsyxl_b6xngl5xap-t5erwn4now.png\"><\/p>\n<p>  \u041d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 operator new \u0440\u0430\u0431\u043e\u0442\u0430\u043b 32 \u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u0430 operator delete \u2014 24 \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u041a \u044d\u0442\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0443\u0447\u0435\u0439: smalloc \u2014 21 \u0441\u0435\u043a\u0443\u043d\u0434\u0430, mslab_alloc \u2014 37 \u0441\u0435\u043a\u0443\u043d\u0434, smfree \u2014 8 \u0441\u0435\u043a\u0443\u043d\u0434, mslab_free \u2014 21 \u0441\u0435\u043a\u0443\u043d\u0434\u0430. \u0418\u0442\u043e\u0433\u043e, 143 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043f\u0440\u043e\u0442\u0438\u0432 161 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>  \u041d\u043e \u044d\u0442\u0438 \u0437\u0430\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0431\u0435\u0437 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u044d\u0448\u0435\u0439 \u0432 slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u0441\u0442\u0440\u0435\u043b\u044c\u0431\u044b \u0438\u0437 yandex-tank \u043e\u0431\u0449\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0443\u043b\u0443\u0447\u0448\u0438\u043b\u0430\u0441\u044c.<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 amplifier (hotslab):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gc\/zj\/kt\/gczjkt5r8yedhniu5afswdjqk2y.png\"><\/p>\n<p>  \u041d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 operator new \u0440\u0430\u0431\u043e\u0442\u0430\u043b 20 \u0441\u0435\u043a\u0443\u043d\u0434, smalloc \u2014 16 \u0441\u0435\u043a\u0443\u043d\u0434, mslab_alloc \u2014 27 \u0441\u0435\u043a\u0443\u043d\u0434, operator delete \u2014 16 \u0441\u0435\u043a\u0443\u043d\u0434, smfree \u2014 7 \u0441\u0435\u043a\u0443\u043d\u0434, mslab_free \u2014 17 \u0441\u0435\u043a\u0443\u043d\u0434. \u0418\u0442\u043e\u0433\u043e, 103 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043f\u0440\u043e\u0442\u0438\u0432 161 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>  \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0437\u0430\u043c\u0435\u0440\u043e\u0432:<\/p>\n<pre><code class=\"plaintext\">                     woslab    coldslab     hotslab operator new            67s         32s         20s smalloc                   -         21s         16s mslab_alloc               -         37s         27s operator delete         94s         24s         16s smfree                    -          8s          7s mslab_free                -         21s         17s  summary                161s        143s        103s <\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0435\u0449\u0435 \u043b\u0443\u0447\u0448\u0435, \u0442\u0430\u043a \u043a\u0430\u043a slab \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b \u0440\u0435\u0448\u0430\u044e\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0434\u043e\u043b\u0433\u043e\u0433\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u043e \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e. \u0411\u0435\u0437 slab \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430 operator new \u0438 operator delete \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c\u0441\u044f. \u0421\u043e slab \u2014 \u043e\u043d\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u0443\u0440\u043e\u0432\u043d\u0435.<\/p>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, slab \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0435\u0448\u0430\u044e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u043d\u0430 \u043d\u0438\u0445 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u0432\u043e\u043f\u0440\u043e\u0441 \u0447\u0430\u0441\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0432\u0430\u0441 \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d. \u041d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043e\u0431 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d\u0438 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f! \u0414\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 slab \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043c\u043d\u043e\u0433\u043e! \u041d\u0443 \u0438 \u0447\u0435\u043c \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u0435\u043c \u0447\u0430\u0449\u0435 \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043a\u044d\u0448. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f slab \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u043e\u0432, \u043d\u043e \u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0430 \u043f\u043e\u0437\u0434\u043d\u0435\u0439 \u0441\u0442\u0430\u0434\u0438\u0438.<\/p>\n<h3>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u041e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/github.com\/variti-com\/slab-allocator\">\u0442\u0443\u0442<\/a>!<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <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\/477404\/\"> https:\/\/habr.com\/ru\/post\/477404\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/477404\/\">\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u041a\u043e\u043c\u043f\u0430\u043d\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e, \u043f\u0438\u0448\u0435\u0442 \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0438 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0435 \u0431\u0438\u0437\u043d\u0435\u0441 \u043e\u0442 DDoS-\u0430\u0442\u0430\u043a, \u0431\u043e\u0442\u043e\u0432, \u043f\u0430\u0440\u0441\u0435\u0440\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043d\u043e\u0433\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u043b\u0435\u0436\u0438\u0442 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u0430\u043a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Reverse_proxy\">\u0440\u0435\u0432\u0435\u0440\u0441\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u0431\u044a\u0435\u043c\u044b \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0438, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043e\u0442\u0441\u0435\u0438\u0432\u0430\u044f \u0432\u0441\u0435 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0435.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u043d\u0435\u043b\u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u043c \u0442\u0440\u0430\u0444\u0438\u043a\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0441\u0442\u0430\u043d\u0446\u0438\u0439 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e. \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u043f\u044b\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c C++, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b \u0438 \u043d\u0430\u0431\u043e\u0440 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c boost.  <\/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-295184","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295184","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=295184"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295184\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=295184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=295184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=295184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}