{"id":343425,"date":"2023-01-01T09:00:25","date_gmt":"2023-01-01T09:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=343425"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=343425","title":{"rendered":"<span>Boson \u2014 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0421\u0423\u0411\u0414 \u00ab\u0441 \u043d\u0443\u043b\u044f\u00bb (\u0447\u0430\u0441\u0442\u044c I)<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8b7\/d1c\/afc\/8b7d1cafce825c18652fa95ed50a3118.gif\" alt=\"(C) \u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Seagate\" title=\"(C) \u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Seagate\" width=\"600\" height=\"337\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8b7\/d1c\/afc\/8b7d1cafce825c18652fa95ed50a3118.gif\"\/><figcaption>(C) \u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Seagate<\/figcaption><\/figure>\n<h2>1. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/571758\/\" rel=\"noopener noreferrer nofollow\">\u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430<\/a> \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0445\u043e\u0431\u0431\u0438 \u043f\u0440\u043e\u0448\u0435\u043b \u0433\u043e\u0434 \u0438 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0451\u043c\u043a\u0438\u0439 \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e. <\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a &#171;\u043a\u0440\u043e\u0432\u0430\u0432\u043e\u0433\u043e&#187; enterprise \u0432 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0421\u0423\u0411\u0414 (SQL\/NoSQL) \u0438 \u043c\u0435\u043d\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u043e \u043a\u0430\u043a \u043e\u043d\u0438 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0432 \u0441\u0430\u043c\u043e\u043c \u0441\u0435\u0440\u0434\u0446\u0435, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u043d\u0438\u0437\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435. \u041f\u043e\u0447\u0438\u0442\u0430\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/sqlite\/sqlite\" rel=\"noopener noreferrer nofollow\">SQLite <\/a>\u0438 <a href=\"https:\/\/github.com\/mongodb\/mongo\" rel=\"noopener noreferrer nofollow\">MongoDB<\/a>, \u043f\u0440\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445 \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043e\u0441\u043e\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0448\u0438\u0440\u043e\u043a\u0443\u044e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0435\u043a\u0443\u044e \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0441\u0442\u044c, \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0421\u0423\u0411\u0414) &#8212; \u044d\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0432\u0441\u0435\u043c \u043f\u043e\u0434 \u0441\u0438\u043b\u0443. \u041e\u0442\u043b\u0438\u0447\u043d\u043e &#8212; \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u043e, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0430\u0434\u043e. \u0421 \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u0435\u0439 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0434\u0435\u043b\u0443.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0445\u043e\u0440\u043e\u0448\u043e \u0431\u044b \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439. <strong>Boson &#8212; \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u0430\u044f, \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0421\/\u0421++<\/strong>:<\/p>\n<ol>\n<li>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 API \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e ID \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 B+ Tree \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u043a\u043b\u044e\u0447\/\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (JSON).<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 LRU-cache \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u0431\u0435\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439 &#171;\u0447\u0438\u0441\u0442\u044b\u0439&#187; C\/C++ \u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/strong><\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0441\u043b\u043e\u044f, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0430\u0451\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/18d\/e35\/9e7\/18de359e739aac168a8308467b26e9d6.png\" alt=\"\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0441\u043b\u043e\u0451\u0432 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 Boson\" title=\"\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0441\u043b\u043e\u0451\u0432 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 Boson\" width=\"1267\" height=\"432\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/18d\/e35\/9e7\/18de359e739aac168a8308467b26e9d6.png\"\/><figcaption>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0441\u043b\u043e\u0451\u0432 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 Boson<\/figcaption><\/figure>\n<p>\u041d\u0430\u0447\u043d\u0443 \u043f\u043e\u044d\u0442\u0430\u043f\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043d\u0438\u0437\u0443 \u0432\u0432\u0435\u0440\u0445. \u041f\u0435\u0440\u0432\u043e\u0435 &#8212; \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430.<\/p>\n<h2>2. \u041a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 (CachedFileIO)<\/h2>\n<p>\u0412\u0441\u0435 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c I\/O \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u044f (HDD\/SSD) \u0432 \u0441\u043e\u0442\u043d\u0438 \u0440\u0430\u0437 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0447\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e (RAM), \u0430 RAM \u0432 \u0441\u043e\u0442\u043d\u0438 \u0440\u0430\u0437 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 I\/O \u043a\u044d\u0448 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 (CPU). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 &#171;\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435&#187; \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043a\u0443\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u044c <a href=\"https:\/\/en.m.wikipedia.org\/wiki\/Locality_of_reference\" rel=\"noopener noreferrer nofollow\">\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0434\u0430\u043d\u043d\u044b\u043c<\/a>. <\/p>\n<p>\u0412 \u0440\u044f\u0434\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430, \u0447\u0442\u043e \u043a\u044d\u0448 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 10-15% \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u0451\u0442 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0431\u043e\u043b\u0435\u0435 95% \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0439 \u0432 \u043a\u044d\u0448 (cache hits), \u0430 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043e\u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a\u0430\u043a 70%\/30% \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438) &#8212; \u044d\u0442\u043e \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f. \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c CachedFileIO \u0431\u0443\u0434\u0435\u043c \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 STDIO (fread, fwrite) &#8212; \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0431\u043e\u043b\u0435\u0435 50% \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0443\u0441\u043f\u0435\u0445\u043e\u043c.<\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u043c \u0431\u043b\u043e\u043a\u043e\u043c \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u0435\u043c (storage device) \u0438 \u043a\u044d\u0448\u0435\u043c \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 (memory cache) \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 (8\u041a\u0431). \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <strong>\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/strong> (<strong>Page<\/strong>). \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u043c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0434\u0438\u0441\u043a\u0430 (HDD) \u0438\u043b\u0438 \u0431\u043b\u043e\u043a\u0430\u043c (SSD) \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438 \u0441 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u041a\u044d\u0448\u0435\u043c (cache) \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e\/\u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0444\u0430\u0439\u043b\u0430.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435 \u043a\u043b\u0430\u0441\u0441 CachedFileIO \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043d\u0435\u043c\u0443 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c:<\/p>\n<ul>\n<li>\n<p><strong>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043a\u044d\u0448\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0430\u0440\u044b\u0435<\/strong>. \u0422\u043e \u0435\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <strong>Least Recent Used (LRU)<\/strong>, \u043d\u043e \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u044d\u0448\u0430 \u043d\u0435 \u0432\u043b\u0438\u044f\u043b \u043d\u0430 \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043a\u0430\u043a \u0441\u043e\u0442\u043d\u0438, \u0442\u0430\u043a \u0438 \u0441\u043e\u0442\u043d\u0438 \u0442\u044b\u0441\u044f\u0447 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u043a\u044d\u0448\u0435 &#8212; O(1)<\/strong>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u043a\u044d\u0448 &#8212; O(1)<\/strong>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0438\u0437 \u043a\u044d\u0448\u0430 &#8212; O(1)<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e Fetch-Before-Write (FBW)<\/strong>. \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0431\u044b\u043b\u0430 \u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0435\u0451 \u0432 \u043a\u044d\u0448. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043c\u044b \u043d\u0435 \u0437\u0430\u0442\u0435\u0440\u043b\u0438 \u0442\u043e, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e &#171;cache-friendly&#187; \u0434\u043b\u044f CPU.<\/strong> \u0416\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0438 \u0432 \u043a\u044d\u0448, \u043e\u043d\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u043a\u044d\u0448\u0430 CPU (\u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0440\u044f\u0434\u043e\u043c).<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b (8192 \u0431\u0430\u0439\u0442\u0430)<\/strong>. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446 (\u0441\u0435\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 HDD \u0438\u043b\u0438 \u0431\u043b\u043e\u043a\u0430 \u043d\u0430 SSD) \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c 64-\u0431\u0438\u0442\u043d\u043e\u0439<\/strong> (\u043d\u0435 \u0438\u043c\u0435\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u0444\u0430\u0439\u043b\u044b \u0431\u043e\u043b\u0435\u0435 4\u0413\u0431).<\/p>\n<\/li>\n<li>\n<p><strong>\u0418\u043c\u0435\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 API, \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p><strong><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/em><\/strong><em>: \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u044d\u0442\u0430\u043f\u0435, \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f, \u043c\u044b \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0432 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 (file lock), \u0442\u0430\u043a \u043a\u0430\u043a \u0431\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445 \u0434\u043b\u044f \u041e\u0421 API \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f (thread safe) \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u0437\u0436\u0435<\/em>.<\/p>\n<p>\u041a\u0430\u043a \u043d\u0435\u043a\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0410. \u041f\u0440\u0438\u0432\u0430\u043b\u043e\u0432, \u043d\u0430 \u043a\u043e\u0433\u0434\u0430-\u0442\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u043c \u043a\u0430\u043d\u0430\u043b\u0435 \u0420\u0411\u041a, &#171;<em>\u0432\u0435\u0449\u0438 \u043d\u0435 \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435, \u043a\u0430\u043a \u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. \u0418 \u043d\u0435 \u0442\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043a\u0430\u043a \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439..<\/em>.&#187;. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0447\u043d\u0435\u043c \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043a\u044d\u0448\u0430 LRU\/FBW. <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0438\u0441\u043a, \u0432\u0441\u0442\u0430\u0432\u043a\u0430, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\/\u0432 \u043a\u044d\u0448 \u043f\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u044b\u043b\u0430 O(1), \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043a <strong>\u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/strong> \u0438 <strong>\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/strong>. \u041f\u0435\u0440\u0432\u044b\u0439 \u043d\u0430\u043c \u0434\u0430\u0451\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u0430, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0432 Java \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d LinkedHashMap, \u0442\u043e \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 C++ \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0435\u0442. \u0418 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e &#8212; \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u0430\u043c\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/704\/b82\/6f8\/704b826f858fe785a6a4eb5330e168b5.jpg\" alt=\"\u0412\u043e\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043d\u0430\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445: \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a\" title=\"\u0412\u043e\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043d\u0430\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445: \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a\" width=\"1200\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/704\/b82\/6f8\/704b826f858fe785a6a4eb5330e168b5.jpg\" data-blurred=\"true\"\/><figcaption>\u0412\u043e\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043d\u0430\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445: \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/figcaption><\/figure>\n<p><strong>\u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 LRU Cache \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f<\/strong>: <\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c CachedFileIO \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 (read, readPage). \u041c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0444\u0430\u0439\u043b\u0430 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446. <\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u043e\u043d\u0430 \u0432 \u043a\u044d\u0448\u0435 &#8212; \u0438\u0449\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u0430\u0448\u043b\u0430\u0441\u044c \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435 &#8212; \u044d\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u043a\u044d\u0448, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0451 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 &#171;\u0441\u0432\u0435\u0436\u0443\u044e&#187;, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u044d\u0448\u0430. \u0415\u0441\u043b\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043a\u044d\u0448\u0430 \u043d\u0435\u0442, \u0442\u043e \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c (\u0435\u0441\u043b\u0438 \u0431\u044b\u043b\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0430 &#8212; \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u0430 DIRTY) \u043d\u0430 \u0434\u0438\u0441\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 &#171;\u0441\u0442\u0430\u0440\u0443\u044e&#187;  (\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432 \u0441\u043f\u0438\u0441\u043a\u0435) \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432 \u043a\u044d\u0448\u0435, \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0412 \u043a\u043e\u043d\u0446\u0435, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0434\u0438\u0441\u043a\u0430, \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0435\u0451 \u043d\u043e\u043c\u0435\u0440 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u043f\u0438\u0441\u043a\u0430 (List) \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0443\u0437\u0435\u043b \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u041f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u0430\u043a CLEAN (&#171;\u0447\u0438\u0441\u0442\u0430\u044f&#187;), \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044f, \u0447\u0442\u043e \u0432 \u043d\u0435\u0451 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441 \u0434\u0438\u0441\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0432\u043d\u043e\u0441\u0438\u043b\u0438\u0441\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 \u043a\u044d\u0448\u0430 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0431\u0443\u0444\u0435\u0440.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u041b\u043e\u0433\u0438\u043a\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f (Fetch-Before-Write)<\/strong>:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c CachedFileIO \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (write, writePage). \u041c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0444\u0430\u0439\u043b\u0430 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446. <\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u043e\u043d\u0430 \u0432 \u043a\u044d\u0448\u0435 &#8212; \u0438\u0449\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u0430\u0448\u043b\u0430\u0441\u044c \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435 &#8212; \u044d\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u043a\u044d\u0448, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0451 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 &#171;\u0441\u0432\u0435\u0436\u0443\u044e&#187;, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043a\u044d\u0448\u0430. \u041f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u0438\u0445 \u043a\u0430\u043a DIRTY (\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0435).<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u043a\u044d\u0448\u0435, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u0447\u0442\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0440\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441 \u0434\u0438\u0441\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u0443\u044e \u0438 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u044d\u0448, \u043f\u043e\u043c\u0435\u0447\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u0430\u043a DIRTY.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0441\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0438 \u0432 \u043d\u0438\u0445 \u043d\u0435 \u0432\u043d\u043e\u0441\u0438\u043b\u0438\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043c\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a CLEAN (&#171;\u0447\u0438\u0441\u0442\u044b\u0435&#187;), \u0430 \u0432 \u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0442\u043e-\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438, \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u043a\u0430\u043a DIRTY (&#171;\u0433\u0440\u044f\u0437\u043d\u044b\u0435&#187;). \u041f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0438\u0437 \u043a\u044d\u0448\u0430, \u0432\u0441\u0435 \u0433\u0440\u044f\u0437\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u044c, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u0440\u0438 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0438 (flush) \u043d\u0430 \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u044c \u0432\u0441\u0435\u0433\u043e \u043a\u044d\u0448\u0430, \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u0444\u0430\u0439\u043b\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3cd\/7a4\/b61\/3cd7a4b616b9b1bcbbd712be451a90d7.png\" alt=\"\u0418\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430: \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e, \u0441\u0432\u0435\u0440\u0445\u0443 \u0443\u043a\u0430\u0437\u0430\u043d \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.\" title=\"\u0418\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430: \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e, \u0441\u0432\u0435\u0440\u0445\u0443 \u0443\u043a\u0430\u0437\u0430\u043d \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.\" width=\"1624\" height=\"660\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3cd\/7a4\/b61\/3cd7a4b616b9b1bcbbd712be451a90d7.png\"\/><figcaption>\u0418\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430: \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e, \u0441\u0432\u0435\u0440\u0445\u0443 \u0443\u043a\u0430\u0437\u0430\u043d \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/figcaption><\/figure>\n<p>\u041a\u043b\u0430\u0441\u0441 CachedFileIO \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cpp\">#pragma once  #define _ITERATOR_DEBUG_LEVEL 0                  \/\/ MSVC debug performance fix  #include &lt;cstdio> #include &lt;cstring> #include &lt;cstdint> #include &lt;unordered_map>  namespace Boson {  \/\/------------------------------------------------------------------------- constexpr uint64_t PAGE_SIZE      = 8192;         \/\/ 8192 bytes page size constexpr uint64_t MINIMAL_CACHE  = 256 * 1024;   \/\/ 256Kb minimal cache constexpr uint64_t DEFAULT_CACHE  = 1*1024*1024;  \/\/ 1Mb default cache constexpr uint64_t NOT_FOUND      = -1;           \/\/ \"Not found\" signature \/\/-------------------------------------------------------------------------  typedef enum {                              \/\/ Cache Page State CLEAN = 0,                              \/\/ Page has not been changed DIRTY = 1                               \/\/ Cache page is rewritten } PageState;  typedef struct { uint8_t data[PAGE_SIZE]; } CachePageData;  class alignas(64) CachePage {               \/\/ Align to CPU cache line public: uint64_t  filePageNo;                   \/\/ Page number in file PageState state;                        \/\/ Current page state uint64_t  availableDataLength;          \/\/ Available amount of data uint8_t*  data;                         \/\/ Pointer to data (payload) std::list&lt;CachePage*>::iterator it;     \/\/ Cache list node iterator };  \/\/-------------------------------------------------------------------------  typedef                                     \/\/ Double linked list std::list&lt;CachePage*>                   \/\/ of cached pages pointers CacheLinkedList;  typedef                                     \/\/ Hashmap of cached pages std::unordered_map&lt;size_t, CachePage*>  \/\/ File page No. -> CachePage*            CachedPagesMap;                           \/\/-------------------------------------------------------------------------  typedef enum {                              \/\/ CachedFileIO stats types TOTAL_REQUESTS,                         \/\/ Total requests to cache TOTAL_CACHE_MISSES,                     \/\/ Total number of cache misses TOTAL_CACHE_HITS,                       \/\/ Total number of cache hits TOTAL_BYTES_WRITTEN,                    \/\/ Total bytes written TOTAL_BYTES_READ,                \/\/ Total bytes read TOTAL_WRITE_TIME_NS,                    \/\/ Total write time (ns) TOTAL_READ_TIME_NS,                     \/\/ Total read time (ns) CACHE_HITS_RATE,                        \/\/ Cache hits rate (0-100%) CACHE_MISSES_RATE,                      \/\/ Cache misses rate (0-100%) WRITE_THROUGHPUT,                       \/\/ Write throughput Mb\/sec READ_THROUGHPUT                         \/\/ Read throughput Mb\/sec } CachedFileStats;   \/\/------------------------------------------------------------------------- \/\/ Binary random access LRU cached file IO \/\/------------------------------------------------------------------------- class CachedFileIO { public: CachedFileIO(); ~CachedFileIO();  bool open(const char* path, size_t cache = DEFAULT_CACHE, bool readOnly = false); bool close(); bool isOpen();  size_t read(size_t position, void* dataBuffer, size_t length); size_t write(size_t position, const void* dataBuffer, size_t length); size_t readPage(size_t pageNo, void* userPageBuffer); size_t writePage(size_t pageNo, const void* userPageBuffer); size_t flush();  void   resetStats(); double getStats(CachedFileStats type); size_t getFileSize(); size_t getCacheSize(); size_t setCacheSize(size_t cacheSize);  private:  void       allocatePool(size_t pagesCount); void       releasePool(); CachePage* allocatePage(); CachePage* getFreeCachePage();                             CachePage* searchPageInCache(size_t filePageNo); CachePage* loadPageToCache(size_t filePageNo); bool       persistCachePage(CachePage* pageInfo); bool       clearCachePage(CachePage* pageInfo);  uint64_t        maxPagesCount;           \/\/ Maximum cache capacity (pages) uint64_t        pageCounter;             \/\/ Allocated pages counter  uint64_t        totalBytesRead;          \/\/ Total bytes read uint64_t        totalBytesWritten;       \/\/ Total bytes written uint64_t        totalReadDuration;       \/\/ Time of read operations (ns) uint64_t        totalWriteDuration;      \/\/ Time of write operations (ns) uint64_t        cacheRequests;           \/\/ Cache requests counter uint64_t        cacheMisses;             \/\/ Cache misses counter  std::FILE*      fileHandler;             \/\/ OS file handler bool            readOnly;                \/\/ Read only flag CachedPagesMap  cacheMap;                \/\/ Cached pages map  CacheLinkedList cacheList;               \/\/ Cached pages double linked list CachePage*      cachePageInfoPool;       \/\/ Cache pages info memory pool CachePageData*  cachePageDataPool;       \/\/ Cache pages data memory pool };     }<\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442 <a href=\"https:\/\/github.com\/Basheyev\/Boson\/blob\/master\/src\/storage\/CachedFileIO.cpp\" rel=\"noopener noreferrer nofollow\">CachedFileIO.cpp<\/a>.<\/p>\n<h2>3. \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 CachedFileIO<\/h2>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0443 \u043c\u0435\u043d\u044f \u043d\u0430 \u043a\u043e\u043c\u043f\u0435 \u0441\u0442\u043e\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e SSD \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u043a\u0443\u043f\u0438\u043b HDD \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 USB, \u0447\u0442\u043e\u0431\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u0430\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432. \u041f\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u044f \u0443\u0434\u0438\u0432\u0438\u043b\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0443\u0432\u0438\u0434\u0435\u043b \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430\u044f (!). \u041d\u043e \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u043d\u044f\u043b \u0432 \u0447\u0435\u043c \u0434\u0435\u043b\u043e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/fa8\/10a\/cd2\/fa810acd202a564f0229162e3a6e3437.jpg\" width=\"800\" height=\"358\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fa8\/10a\/cd2\/fa810acd202a564f0229162e3a6e3437.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0437\u0430\u043d\u044f\u0442\u0438\u0435\u043c \u0447\u0435\u043c \u0441\u0430\u043c\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u044d\u0448 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043f\u043b\u044e\u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u041e\u0421 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e (\u043d\u0435 \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e), \u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u0430\u0445 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430, \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0432\u043e\u0434\/\u0432\u044b\u0432\u043e\u0434 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432. \u0417\u0430\u043c\u0435\u0440\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432 \u043b\u043e\u0431 &#8212; \u0442\u0430\u043a \u0441\u0435\u0431\u0435 \u0438\u0434\u0435\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u043e\u0432 \u043d\u0443\u0436\u043d\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u0431\u044a\u0435\u043c\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0442 \u0438 \u043e\u0431\u044a\u0435\u043c \u043a\u044d\u0448\u0430, \u0438 \u043e\u0431\u044a\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c. \u0422\u0430\u043a\u0436\u0435 \u0440\u0430\u043d\u0435\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e:<\/p>\n<blockquote>\n<p>\u0412 \u0440\u044f\u0434\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430, \u0447\u0442\u043e \u043a\u044d\u0448 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 10-15% \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u0451\u0442 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0431\u043e\u043b\u0435\u0435 95% \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0439 \u0432 \u043a\u044d\u0448 (cache hits), \u0430 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043e\u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a\u0430\u043a 70%\/30%<\/p>\n<\/blockquote>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 <strong>\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b:<\/strong> \u03c3 =4% \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0430\u0437\u044b \u0438 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u043a\u0430\u043a\u043e\u043c \u0442\u043e \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 &#8212; \u0434\u043b\u044f CachedFileIO \u0431\u0435\u0437 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445, \u043b\u0438\u0448\u044c \u0431\u044b \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/60f\/6ef\/62a\/60f6ef62a1fd2de70ecd1e70802f4a6e.jpg\" width=\"547\" height=\"186\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/60f\/6ef\/62a\/60f6ef62a1fd2de70ecd1e70802f4a6e.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c Box Muller`\u0430 \u0431\u0443\u0434\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b \u0447\u0438\u0441\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0443\u0447\u0430\u0441\u0442\u043a\u0438 \u0444\u0430\u0439\u043b\u0430 (\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435):<\/p>\n<pre><code class=\"cpp\">\/** * *  @brief  Box Muller Method *  @return normal distributed random number * *\/ double CachedFileIOTest::randNormal(double mean, double stddev) { static double n2 = 0.0; static int n2_cached = 0; if (!n2_cached) { double x, y, r; do { x = 2.0 * rand() \/ RAND_MAX - 1.0; y = 2.0 * rand() \/ RAND_MAX - 1.0; r = x * x + y * y; } while (r == 0.0 || r > 1.0); double d = sqrt(-2.0 * log(r) \/ r); double n1 = x * d; n2 = y * d; double result = n1 * stddev + mean; n2_cached = 1; return result; } else { n2_cached = 0; return n2 * stddev + mean; } } <\/code><\/pre>\n<p>\u0411\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430, \u043c\u0435\u043b\u043a\u0438\u043c\u0438 \u043f\u043e\u0440\u0446\u0438\u044f\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b CachedFileIO (read, write, readPage, writePage) \u0438 STDIO (fread, fwrite). \u0412\u043e\u0442 <a href=\"https:\/\/github.com\/Basheyev\/Boson\/blob\/master\/src\/test\/CachedFileIOTest.h\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442 \u0441\u0430\u043c \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a \u043d\u0430 \u043a\u043e\u043b\u0435\u043d\u043a\u0430\u0445<\/a> \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a\u0438\u0445 \u043b\u0438\u0431\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432. \u0418 \u0432\u043e\u0442 \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/6cc\/72e\/7de\/6cc72e7ded01a6e6d93c3c82233e7cb3.jpg\" width=\"728\" height=\"463\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6cc\/72e\/7de\/6cc72e7ded01a6e6d93c3c82233e7cb3.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 release \u0441\u0431\u043e\u0440\u043a\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <strong>CachedFileIO<\/strong> \u0438 <strong>STDIO<\/strong> \u043f\u0440\u0438 \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0445 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0434\u0430\u043b\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<ul>\n<li>\n<p><strong>50%-97% \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \u043a\u044d\u0448 \u0434\u0430\u0451\u0442 \u043e\u0442 50%-600% \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>35%-49% \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \u043a\u044d\u0448 \u0434\u0430\u0451\u0442 \u043e\u0442 12%-36% \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>1%-25%  \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0439 \u0432 \u043a\u044d\u0448 \u0434\u0430\u044e\u0442 \u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0442 5%-20%<\/strong> <\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u043d\u0430\u0447\u0438\u0442 \u0432\u0441\u0451 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043a\u0430\u043a \u043d\u0430\u0434\u043e \u0438\u043b\u0438, \u0442\u043e\u0447\u043d\u0435\u0435, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n<p><strong><em>\u041d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435<\/em><\/strong><em>: \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435 MSVC \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 debug \u043e\u0447\u0435\u043d\u044c &#171;\u0442\u043e\u0440\u043c\u043e\u0437\u044f\u0442&#187; \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u043c\u0435\u0448\u0430\u044e\u0442 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f\u043c. \u0412 20-30 \u0440\u0430\u0437 \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 release. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438\u0445 \u043e\u0442\u043b\u0430\u0434\u043a\u0443 _ITERATOR_DEBUG_LEVEL.<\/em><\/p>\n<p>\u0418\u0442\u0430\u043a, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u043c\u043d\u043e\u0433\u043e \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 CachedFileIO, \u043d\u043e \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043b\u043e\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 Boson &#8212; StorageIO.<\/p>\n<p><strong>\u0414\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0438!<\/strong><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/708768\/\"> https:\/\/habr.com\/ru\/post\/708768\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption>(C) \u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Seagate<\/figcaption><\/figure>\n<h2>1. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/571758\/\" rel=\"noopener noreferrer nofollow\">\u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430<\/a> \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0445\u043e\u0431\u0431\u0438 \u043f\u0440\u043e\u0448\u0435\u043b \u0433\u043e\u0434 \u0438 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0451\u043c\u043a\u0438\u0439 \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e. <\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a &#171;\u043a\u0440\u043e\u0432\u0430\u0432\u043e\u0433\u043e&#187; enterprise \u0432 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0421\u0423\u0411\u0414 (SQL\/NoSQL) \u0438 \u043c\u0435\u043d\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u043e \u043a\u0430\u043a \u043e\u043d\u0438 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0432 \u0441\u0430\u043c\u043e\u043c \u0441\u0435\u0440\u0434\u0446\u0435, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u043d\u0438\u0437\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435. \u041f\u043e\u0447\u0438\u0442\u0430\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/sqlite\/sqlite\" rel=\"noopener noreferrer nofollow\">SQLite <\/a>\u0438 <a href=\"https:\/\/github.com\/mongodb\/mongo\" rel=\"noopener noreferrer nofollow\">MongoDB<\/a>, \u043f\u0440\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445 \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043e\u0441\u043e\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0448\u0438\u0440\u043e\u043a\u0443\u044e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0435\u043a\u0443\u044e \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0441\u0442\u044c, \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0421\u0423\u0411\u0414) &#8212; \u044d\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0432\u0441\u0435\u043c \u043f\u043e\u0434 \u0441\u0438\u043b\u0443. \u041e\u0442\u043b\u0438\u0447\u043d\u043e &#8212; \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u043e, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0430\u0434\u043e. \u0421 \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u0435\u0439 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0434\u0435\u043b\u0443.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0445\u043e\u0440\u043e\u0448\u043e \u0431\u044b \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439. <strong>Boson &#8212; \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u0430\u044f, \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0421\/\u0421++<\/strong>:<\/p>\n<ol>\n<li>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 API \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e ID \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 B+ Tree \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u043a\u043b\u044e\u0447\/\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (JSON).<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 LRU-cache \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u0431\u0435\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439 &#171;\u0447\u0438\u0441\u0442\u044b\u0439&#187; C\/C++ \u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/strong><\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0441\u043b\u043e\u044f, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0430\u0451\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><figcaption>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0441\u043b\u043e\u0451\u0432 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 Boson<\/figcaption><\/figure>\n<p>\u041d\u0430\u0447\u043d\u0443 \u043f\u043e\u044d\u0442\u0430\u043f\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043d\u0438\u0437\u0443 \u0432\u0432\u0435\u0440\u0445. \u041f\u0435\u0440\u0432\u043e\u0435 &#8212; \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430.<\/p>\n<h2>2. \u041a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 (CachedFileIO)<\/h2>\n<p>\u0412\u0441\u0435 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c I\/O \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u044f (HDD\/SSD) \u0432 \u0441\u043e\u0442\u043d\u0438 \u0440\u0430\u0437 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0447\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e (RAM), \u0430 RAM \u0432 \u0441\u043e\u0442\u043d\u0438 \u0440\u0430\u0437 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 I\/O \u043a\u044d\u0448 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 (CPU). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 &#171;\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435&#187; \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043a\u0443\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u044c <a href=\"https:\/\/en.m.wikipedia.org\/wiki\/Locality_of_reference\" rel=\"noopener noreferrer nofollow\">\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0434\u0430\u043d\u043d\u044b\u043c<\/a>. <\/p>\n<p>\u0412 \u0440\u044f\u0434\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430, \u0447\u0442\u043e \u043a\u044d\u0448 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 10-15% \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u0451\u0442 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0431\u043e\u043b\u0435\u0435 95% \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0439 \u0432 \u043a\u044d\u0448 (cache hits), \u0430 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043e\u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a\u0430\u043a 70%\/30% \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438) &#8212; \u044d\u0442\u043e \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f. \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c CachedFileIO \u0431\u0443\u0434\u0435\u043c \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 STDIO (fread, fwrite) &#8212; \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0431\u043e\u043b\u0435\u0435 50% \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0443\u0441\u043f\u0435\u0445\u043e\u043c.<\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u043c \u0431\u043b\u043e\u043a\u043e\u043c \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u0435\u043c (storage device) \u0438 \u043a\u044d\u0448\u0435\u043c \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 (memory cache) \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 (8\u041a\u0431). \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <strong>\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/strong> (<strong>Page<\/strong>). \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u043c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0434\u0438\u0441\u043a\u0430 (HDD) \u0438\u043b\u0438 \u0431\u043b\u043e\u043a\u0430\u043c (SSD) \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438 \u0441 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u041a\u044d\u0448\u0435\u043c (cache) \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e\/\u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0444\u0430\u0439\u043b\u0430.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435 \u043a\u043b\u0430\u0441\u0441 CachedFileIO \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043d\u0435\u043c\u0443 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c:<\/p>\n<ul>\n<li>\n<p><strong>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043a\u044d\u0448\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0430\u0440\u044b\u0435<\/strong>. \u0422\u043e \u0435\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <strong>Least Recent Used (LRU)<\/strong>, \u043d\u043e \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u044d\u0448\u0430 \u043d\u0435 \u0432\u043b\u0438\u044f\u043b \u043d\u0430 \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043a\u0430\u043a \u0441\u043e\u0442\u043d\u0438, \u0442\u0430\u043a \u0438 \u0441\u043e\u0442\u043d\u0438 \u0442\u044b\u0441\u044f\u0447 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u043a\u044d\u0448\u0435 &#8212; O(1)<\/strong>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u043a\u044d\u0448 &#8212; O(1)<\/strong>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0438\u0437 \u043a\u044d\u0448\u0430 &#8212; O(1)<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e Fetch-Before-Write (FBW)<\/strong>. \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0431\u044b\u043b\u0430 \u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0435\u0451 \u0432 \u043a\u044d\u0448. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043c\u044b \u043d\u0435 \u0437\u0430\u0442\u0435\u0440\u043b\u0438 \u0442\u043e, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e &#171;cache-friendly&#187; \u0434\u043b\u044f CPU.<\/strong> \u0416\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0438 \u0432 \u043a\u044d\u0448, \u043e\u043d\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u043a\u044d\u0448\u0430 CPU (\u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0440\u044f\u0434\u043e\u043c).<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b (8192 \u0431\u0430\u0439\u0442\u0430)<\/strong>. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446 (\u0441\u0435\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 HDD \u0438\u043b\u0438 \u0431\u043b\u043e\u043a\u0430 \u043d\u0430 SSD) \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c 64-\u0431\u0438\u0442\u043d\u043e\u0439<\/strong> (\u043d\u0435 \u0438\u043c\u0435\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u0444\u0430\u0439\u043b\u044b \u0431\u043e\u043b\u0435\u0435 4\u0413\u0431).<\/p>\n<\/li>\n<li>\n<p><strong>\u0418\u043c\u0435\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 API, \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p><strong><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/em><\/strong><em>: \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u044d\u0442\u0430\u043f\u0435, \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f, \u043c\u044b \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0432 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 (file lock), \u0442\u0430\u043a \u043a\u0430\u043a \u0431\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445 \u0434\u043b\u044f \u041e\u0421 API \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f (thread safe) \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u0437\u0436\u0435<\/em>.<\/p>\n<p>\u041a\u0430\u043a \u043d\u0435\u043a\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0410. \u041f\u0440\u0438\u0432\u0430\u043b\u043e\u0432, \u043d\u0430 \u043a\u043e\u0433\u0434\u0430-\u0442\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u043c \u043a\u0430\u043d\u0430\u043b\u0435 \u0420\u0411\u041a, &#171;<em>\u0432\u0435\u0449\u0438 \u043d\u0435 \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435, \u043a\u0430\u043a \u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. \u0418 \u043d\u0435 \u0442\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043a\u0430\u043a \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439..<\/em>.&#187;. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0447\u043d\u0435\u043c \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043a\u044d\u0448\u0430 LRU\/FBW. <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0438\u0441\u043a, \u0432\u0441\u0442\u0430\u0432\u043a\u0430, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\/\u0432 \u043a\u044d\u0448 \u043f\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u044b\u043b\u0430 O(1), \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043a <strong>\u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/strong> \u0438 <strong>\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/strong>. \u041f\u0435\u0440\u0432\u044b\u0439 \u043d\u0430\u043c \u0434\u0430\u0451\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u0430, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0432 Java \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d LinkedHashMap, \u0442\u043e \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 C++ \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0435\u0442. \u0418 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e &#8212; \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u0430\u043c\u0438.<\/p>\n<figure class=\"full-width\"><figcaption>\u0412\u043e\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043d\u0430\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445: \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/figcaption><\/figure>\n<p><strong>\u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 LRU Cache \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f<\/strong>: <\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c CachedFileIO \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 (read, readPage). \u041c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0444\u0430\u0439\u043b\u0430 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446. <\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u043e\u043d\u0430 \u0432 \u043a\u044d\u0448\u0435 &#8212; \u0438\u0449\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u0430\u0448\u043b\u0430\u0441\u044c \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435 &#8212; \u044d\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u043a\u044d\u0448, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0451 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 &#171;\u0441\u0432\u0435\u0436\u0443\u044e&#187;, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u044d\u0448\u0430. \u0415\u0441\u043b\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043a\u044d\u0448\u0430 \u043d\u0435\u0442, \u0442\u043e \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c (\u0435\u0441\u043b\u0438 \u0431\u044b\u043b\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0430 &#8212; \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u0430 DIRTY) \u043d\u0430 \u0434\u0438\u0441\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 &#171;\u0441\u0442\u0430\u0440\u0443\u044e&#187;  (\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432 \u0441\u043f\u0438\u0441\u043a\u0435) \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432 \u043a\u044d\u0448\u0435, \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0412 \u043a\u043e\u043d\u0446\u0435, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0434\u0438\u0441\u043a\u0430, \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0435\u0451 \u043d\u043e\u043c\u0435\u0440 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u043f\u0438\u0441\u043a\u0430 (List) \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0443\u0437\u0435\u043b \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u041f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u0430\u043a CLEAN (&#171;\u0447\u0438\u0441\u0442\u0430\u044f&#187;), \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044f, \u0447\u0442\u043e \u0432 \u043d\u0435\u0451 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441 \u0434\u0438\u0441\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0432\u043d\u043e\u0441\u0438\u043b\u0438\u0441\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 \u043a\u044d\u0448\u0430 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0431\u0443\u0444\u0435\u0440.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u041b\u043e\u0433\u0438\u043a\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f (Fetch-Before-Write)<\/strong>:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c CachedFileIO \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (write, writePage). \u041c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0444\u0430\u0439\u043b\u0430 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446. <\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u043e\u043d\u0430 \u0432 \u043a\u044d\u0448\u0435 &#8212; \u0438\u0449\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u0430\u0448\u043b\u0430\u0441\u044c \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435 &#8212; \u044d\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u043a\u044d\u0448, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0451 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 &#171;\u0441\u0432\u0435\u0436\u0443\u044e&#187;, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043a\u044d\u0448\u0430. \u041f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u0438\u0445 \u043a\u0430\u043a DIRTY (\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0435).<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u043a\u044d\u0448\u0435, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u0447\u0442\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0440\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441 \u0434\u0438\u0441\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u0443\u044e \u0438 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u044d\u0448, \u043f\u043e\u043c\u0435\u0447\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u0430\u043a DIRTY.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0441\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0438 \u0432 \u043d\u0438\u0445 \u043d\u0435 \u0432\u043d\u043e\u0441\u0438\u043b\u0438\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043c\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a CLEAN (&#171;\u0447\u0438\u0441\u0442\u044b\u0435&#187;), \u0430 \u0432 \u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0442\u043e-\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438, \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u043a\u0430\u043a DIRTY (&#171;\u0433\u0440\u044f\u0437\u043d\u044b\u0435&#187;). \u041f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0438\u0437 \u043a\u044d\u0448\u0430, \u0432\u0441\u0435 \u0433\u0440\u044f\u0437\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u044c, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u0440\u0438 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0438 (flush) \u043d\u0430 \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u044c \u0432\u0441\u0435\u0433\u043e \u043a\u044d\u0448\u0430, \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u0444\u0430\u0439\u043b\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<figure class=\"full-width\"><figcaption>\u0418\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430: \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e, \u0441\u0432\u0435\u0440\u0445\u0443 \u0443\u043a\u0430\u0437\u0430\u043d \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/figcaption><\/figure>\n<p>\u041a\u043b\u0430\u0441\u0441 CachedFileIO \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cpp\">#pragma once  #define _ITERATOR_DEBUG_LEVEL 0                  \/\/ MSVC debug performance fix  #include &lt;cstdio> #include &lt;cstring> #include &lt;cstdint> #include &lt;unordered_map>  namespace Boson {  \/\/------------------------------------------------------------------------- constexpr uint64_t PAGE_SIZE      = 8192;         \/\/ 8192 bytes page size constexpr uint64_t MINIMAL_CACHE  = 256 * 1024;   \/\/ 256Kb minimal cache constexpr uint64_t DEFAULT_CACHE  = 1*1024*1024;  \/\/ 1Mb default cache constexpr uint64_t NOT_FOUND      = -1;           \/\/ \"Not found\" signature \/\/-------------------------------------------------------------------------  typedef enum {                              \/\/ Cache Page State CLEAN = 0,                              \/\/ Page has not been changed DIRTY = 1                               \/\/ Cache page is rewritten } PageState;  typedef struct { uint8_t data[PAGE_SIZE]; } CachePageData;  class alignas(64) CachePage {               \/\/ Align to CPU cache line public: uint64_t  filePageNo;                   \/\/ Page number in file PageState state;                        \/\/ Current page state uint64_t  availableDataLength;          \/\/ Available amount of data uint8_t*  data;                         \/\/ Pointer to data (payload) std::list&lt;CachePage*>::iterator it;     \/\/ Cache list node iterator };  \/\/-------------------------------------------------------------------------  typedef                                     \/\/ Double linked list std::list&lt;CachePage*>                   \/\/ of cached pages pointers CacheLinkedList;  typedef                                     \/\/ Hashmap of cached pages std::unordered_map&lt;size_t, CachePage*>  \/\/ File page No. -> CachePage*            CachedPagesMap;                           \/\/-------------------------------------------------------------------------  typedef enum {                              \/\/ CachedFileIO stats types TOTAL_REQUESTS,                         \/\/ Total requests to cache TOTAL_CACHE_MISSES,                     \/\/ Total number of cache misses TOTAL_CACHE_HITS,                       \/\/ Total number of cache hits TOTAL_BYTES_WRITTEN,                    \/\/ Total bytes<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-343425","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/343425","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=343425"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/343425\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}