{"id":494436,"date":"2026-09-12T05:24:47","date_gmt":"2026-09-12T05:24:47","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=494436"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=494436","title":{"rendered":"LRU-\u043a\u044d\u0448 \u043d\u0430 PHP 8.5 \u0434\u043b\u044f Identity Map: 15+ \u043c\u043b\u043d. \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043d\u0430 \u0441\u043b\u0430\u0431\u043e\u043c \u043d\u043e\u0443\u0442\u0435"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>LRU \u043d\u0430 PHP \u2014 \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e, \u0432\u0440\u043e\u0434\u0435 \u0431\u044b, \u0443\u0436\u0435 \u0432\u0441\u0435 \u043a\u043e\u043c\u0443 \u043d\u0435 \u043b\u0435\u043d\u044c \u0440\u0435\u0448\u0438\u043b\u0438 \u0432\u0434\u043e\u043b\u044c \u0438 \u043f\u043e\u043f\u0435\u0440\u0451\u043a.<\/p>\n<p>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0445\u0435\u043c\u0430: O(1)-\u043f\u043e\u0438\u0441\u043a \u043f\u043e \u043a\u043b\u044e\u0447\u0443 + \u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u2014 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0432\u0441\u0435\u043c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0448\u044c \u043c\u0435\u0440\u0438\u0442\u044c, \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0432\u044b\u0434\u0430\u044e\u0442 2\u20135 \u043c\u043b\u043d ops\/sec. \u0414\u043b\u044f \u0432\u0435\u0431\u0430 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u0430 \u0432\u043e\u0442 \u0434\u043b\u044f highload \u2014 \u0443\u0436\u0435 \u043d\u0435\u0442. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 LRU \u2014 \u044d\u0442\u043e \u043d\u0435 \u00ab<em>\u0433\u0434\u0435-\u0442\u043e \u0432 \u043a\u044d\u0448\u0435 Redis<\/em>\u00bb, \u0430 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442 <strong>Identity Map<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0438\u0434\u0438\u0442 \u043f\u0440\u044f\u043c\u043e \u0432 hot path \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>\u042f \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u043e\u0439 \u043f\u0435\u0440\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0432\u0435\u0440\u0445 Eloquent \u2014 \u0441 Identity Map, Unit of Work \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b LRU \u2014 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0439. \u0415\u0441\u043b\u0438 \u0435\u0433\u043e \u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0438\u0436\u0435 2\u20133 \u043c\u043b\u043d ops\/sec, \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u043a\u044d\u0448\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u0441\u043e\u0442\u043d\u044f\u043c\u0438 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441. \u042d\u0442\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c\u043e \u0441\u043e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0411\u0414. \u0412 \u0438\u0442\u043e\u0433\u0435 Identity Map \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u043e\u043a\u0443\u043f\u0430\u0442\u044c\u0441\u044f: \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0438\u0441\u0442\u0443\u044e \u0434\u0435\u0433\u0440\u0430\u0434\u0430\u0446\u0438\u044e latency \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0445\u0438\u0442\u0430.<\/p>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u044e LRU, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0437\u043a\u0438\u043c \u043c\u0435\u0441\u0442\u043e\u043c \u0432\u043e\u043e\u0431\u0449\u0435.<\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439: \u0432\u0437\u044f\u0442\u044c \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e (<strong>HashMap<\/strong> + <strong>doubly linked list<\/strong>), \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0443\u0447\u0435\u0441\u0442\u044c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 JIT. \u041d\u0430 \u0434\u0435\u043b\u0435 \u2014 10 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439, \u043a\u0430\u0436\u0434\u0430\u044f \u0441 \u0437\u0430\u043c\u0435\u0440\u043e\u043c. \u0413\u0434\u0435-\u0442\u043e \u044f \u0442\u0435\u0440\u044f\u043b 50% \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 property hooks, \u0430 \u0433\u0434\u0435-\u0442\u043e, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 \u0434\u0430\u0432\u0430\u043b\u043e +25%.<\/p>\n<p><strong>\u0418\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u0446\u0438\u0444\u0440\u0430<\/strong>: 15.4 \u043c\u043b\u043d ops\/sec \u043d\u0430 <code>touch<\/code> \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0438 \u044d\u0442\u043e \u0432\u0441\u0451 \u043d\u0430 \u0441\u043b\u0430\u0431\u043e\u043c \u043d\u043e\u0443\u0442\u0435, \u0434\u0430 \u0435\u0449\u0451 \u0438 \u0432 Docker \u0441 \u043a\u0443\u0447\u0435\u0439 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041d\u0430 \u043f\u0440\u043e\u0434\u0435, \u043f\u0440\u0430\u0432\u0434\u0430, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u043b.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c10\/dd8\/305\/c10dd8305cda933cc9755a638ae478aa.jpg\" width=\"1210\" height=\"1158\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/c10\/dd8\/305\/c10dd8305cda933cc9755a638ae478aa.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c10\/dd8\/305\/c10dd8305cda933cc9755a638ae478aa.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h2>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/h2>\n<pre><code class=\"php\">&lt;?php declare(strict_types=1);namespace App\\Orm\\IdentityMap\\Lru;\/** * @phpstan-extends \\IteratorAggregate&lt;int, non-empty-string&gt; *\/interface LruCacheInterface extends \\Countable, \\IteratorAggregate{    \/**     * @phpstan-param non-empty-string $key     * @phpstan-return non-empty-string|null     *\/    public function touch(string $key): ?string;    \/**     * @phpstan-param iterable&lt;non-empty-string&gt; $keys     * @phpstan-return list&lt;non-empty-string&gt;     *\/    public function touchMany(iterable $keys): array;    \/**     * @phpstan-return non-empty-string|null     * @throws \\AssertionError     *\/    public function evict(): ?string;    \/**     * @phpstan-param string $key     * @phpstan-return void     *\/    public function remove(string $key): void;    \/**     * @phpstan-return void     *\/    public function clear(): void;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><strong>\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>touch()<\/code> \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043b\u044e\u0447 \u0438\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u044e. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 evicted key (<em>\u0435\u0441\u043b\u0438 \u0431\u044b\u043b<\/em>).<\/p>\n<\/li>\n<li>\n<p><code>touchMany()<\/code> \u2014 \u043c\u0430\u0441\u0441\u043e\u0432\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u044b\u0442\u0435\u0441\u043d\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p><code>evict()<\/code> \u2014 \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u0442\u0435\u0441\u043d\u0435\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430.<\/p>\n<\/li>\n<li>\n<p><code>remove()<\/code> \u2014 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430.<\/p>\n<\/li>\n<li>\n<p><code>clear()<\/code> \u2014 \u043f\u043e\u043b\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<pre><code class=\"php\">&lt;?php declare(strict_types=1);namespace App\\Orm\\IdentityMap\\Lru;\/** * @implements LruCacheInterface *\/final class LruCache implements LruCacheInterface{    \/**     * @phpstan-var array&lt;non-empty-string, int&lt;0, max&gt;&gt;     *\/    private array $nodes = [];    \/**     * @phpstan-var int&lt;0, max&gt;     *\/    private int $size = 0;    \/**     * @phpstan-var LruNodePool     *\/    private readonly LruNodePool $pool;    \/**     * @phpstan-var LruNodeKeys     *\/    private readonly LruNodeKeys $keys;    \/**     * @phpstan-var LruNodeLinks     *\/    private readonly LruNodeLinks $links;    \/**     * @phpstan-param int&lt;1, max&gt; $capacity     * @throws \\InvalidArgumentException     *\/    public function __construct(        private readonly int $capacity    ) {        if ($capacity &lt; 1) {            throw new \\InvalidArgumentException(                message: 'Capacity must be at least 1.'            );        }        $this-&gt;pool = new LruNodePool(            capacity: $capacity        );        $this-&gt;keys = new LruNodeKeys();        $this-&gt;links = new LruNodeLinks();    }    \/**     * @phpstan-param non-empty-string $key     * @phpstan-return non-empty-string|null     *\/    #[\\NoDiscard]    public function touch(string $key): ?string    {        $node = $this-&gt;nodes[$key] ?? null;        if ($node !== null) {            if ($node !== $this-&gt;links-&gt;tail) {                $this-&gt;links-&gt;touch(node: $node);            }            return null;        }        $evicted = $this-&gt;size &gt;= $this-&gt;capacity            ? $this-&gt;evict()            : null;        $node = $this-&gt;pool-&gt;allocate();                $this-&gt;keys-&gt;set(node: $node, key: $key);        $this-&gt;nodes[$key] = $node;        $this-&gt;links-&gt;push(node: $node);        $this-&gt;size++;        return $evicted;    }    \/**     * @phpstan-param iterable&lt;non-empty-string&gt; $keys     * @phpstan-return list&lt;non-empty-string&gt;     *\/    #[\\NoDiscard]    public function touchMany(iterable $keys): array    {        $evicted = [];        foreach ($keys as $key) {            $result = $this-&gt;touch(key: $key);            if ($result !== null) {                $evicted[] = $result;            }        }        return $evicted;    }    \/**     * @phpstan-return non-empty-string|null     * @throws \\AssertionError     *\/    #[\\NoDiscard]    public function evict(): ?string    {        if ($this-&gt;links-&gt;head === LruNodePool::NIL) {            return null;        }        \/** @phpstan-var int&lt;0, max&gt; $node *\/        $node = $this-&gt;links-&gt;head;        $key = $this-&gt;keys-&gt;get(node: $node);        if ($key === null) {            throw new \\AssertionError(                message: 'LRU head has null key.'            );        }        $this-&gt;links-&gt;detach(node: $node);        unset($this-&gt;nodes[$key]);        $this-&gt;pool-&gt;release(node: $node);        $this-&gt;size--;        return $key;    }    \/**     * @phpstan-return \\Generator&lt;int, non-empty-string&gt;     * @throws \\AssertionError     *\/    public function getIterator(): \\Generator    {        $node = $this-&gt;links-&gt;head;        while ($node !== LruNodePool::NIL) {            \/** @phpstan-var int&lt;0, max&gt; $node *\/            $key = $this-&gt;keys-&gt;get(node: $node);            if ($key === null) {                throw new \\AssertionError(                    message: 'LRU list node has null key.'                );            }            $next = $this-&gt;links-&gt;next[$node]                ?? LruNodePool::NIL;            yield $key;            $node = $next;        }    }    \/**     * @phpstan-return int&lt;0, max&gt;     *\/    public function count(): int    {        return $this-&gt;size;    }    \/**     * @phpstan-param string $key     * @phpstan-return void     *\/    public function remove(string $key): void    {        $node = $this-&gt;nodes[$key] ?? null;        if ($node === null) {            return;        }        $this-&gt;links-&gt;detach(node: $node);        unset($this-&gt;nodes[$key]);        $this-&gt;pool-&gt;release(node: $node);        $this-&gt;size--;    }    \/**     * @phpstan-return void     *\/    public function clear(): void    {        $this-&gt;links-&gt;clear();        $this-&gt;pool-&gt;clear();        $this-&gt;keys-&gt;clear();        $this-&gt;nodes = [];        $this-&gt;size = 0;    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><strong>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438: <code>LruNodePool<\/code>, <code>LruNodeKeys<\/code>, <code>LruNodeLinks<\/code> \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u0432\u043e\u044e \u043f\u043b\u043e\u0441\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e \u043d\u0435 \u00ab<em>\u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 = \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435<\/em>\u00bb, \u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f JIT inlining. \u041c\u0435\u043b\u043a\u0438\u0439 <code>final<\/code>-\u043c\u0435\u0442\u043e\u0434 JIT \u0438\u043d\u043b\u0430\u0439\u043d\u0438\u0442 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u0443\u0435\u0442 \u0434\u043e\u043b\u0433\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u043e\u0441\u043a\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b (<em>Integer ID maps<\/em>):<code> $nodes<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u043c\u0443 ID \u0443\u0437\u043b\u0430 (<code>$keyString =&gt; $nodeId<\/code>), \u0430 \u043d\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u041c\u0435\u043d\u044c\u0448\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439 GC, \u043b\u0443\u0447\u0448\u0435 locality \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f CPU-\u043a\u044d\u0448\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u043b (<em>Object Pooling<\/em>): <code>LruNodePool<\/code> \u0432\u044b\u0434\u0430\u0451\u0442 ID \u0438\u0437 \u043f\u0443\u043b\u0430 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0430 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 0 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0441\u043b\u0435 initial population.<\/p>\n<\/li>\n<li>\n<p>Readonly-\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430: <code>$pool<\/code>, <code>$keys<\/code>, <code>$links<\/code>,<code> $capacity<\/code> \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u043a\u0430\u043a <code>readonly<\/code>. JIT-\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u0435\u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0435\u0442 \u2014 \u043f\u043e\u043b\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441: \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0431\u0438\u0440\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (<em>vtable check<\/em>). \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 JIT \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u0438\u043d\u043b\u0430\u0439\u043d\u0438\u043d\u0433 \u0433\u043e\u0440\u044f\u0447\u0438\u0445 \u043f\u0443\u0442\u0435\u0439 (<code>$this-&gt;links-&gt;touch(\u2026)<\/code>).<\/p>\n<\/li>\n<\/ul>\n<h2>\u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b<\/h2>\n<p><code>LruNodeKeys<\/code><\/p>\n<pre><code class=\"php\">&lt;?php declare(strict_types=1);namespace App\\Orm\\IdentityMap\\Lru;\/** * @internal *\/final class LruNodeKeys{    \/**     * @phpstan-var array&lt;int&lt;0, max&gt;, non-empty-string|null&gt;     *\/    private array $keys = [];    \/**     * @phpstan-param int&lt;0, max&gt; $node     * @phpstan-param non-empty-string $key     *     * @phpstan-return void     *\/    final public function set(int $node, string $key): void    {        $this-&gt;keys[$node] = $key;    }    \/**     * @phpstan-param int&lt;0, max&gt; $node     * @phpstan-return non-empty-string|null     *\/    final public function get(int $node): ?string    {        return $this-&gt;keys[$node] ?? null;    }    \/**     * @phpstan-param int&lt;0, max&gt; $node     * @phpstan-return void     *\/    final public function reset(int $node): void    {        $this-&gt;keys[$node] = null;    }    \/**     * @phpstan-return void     *\/    final public function clear(): void    {        $this-&gt;keys = [];    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 <code>node_id \u2192 key<\/code>. \u041a\u0440\u043e\u0448\u0435\u0447\u043d\u044b\u0439 <code>final<\/code>-\u043a\u043b\u0430\u0441\u0441 = JIT \u0438\u043d\u043b\u0430\u0439\u043d\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u0434\u043e \u043e\u0434\u043d\u043e\u0433\u043e <code>MOV<\/code>-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a \u043c\u0430\u0441\u0441\u0438\u0432\u0443. \u0415\u0441\u043b\u0438 \u0431\u044b \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0431\u044b\u043b \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e <code>LruCache<\/code>, JIT \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u0430\u043b \u0431\u044b \u0432\u0435\u0441\u044c \u043e\u0431\u044a\u0435\u043c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0440\u0430\u0434\u0438 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u2014 \u043b\u0438\u0448\u043d\u0438\u0435 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f, \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p><code>LruNodeLinks<\/code><\/p>\n<pre><code class=\"php\">&lt;?php declare(strict_types=1);namespace App\\Orm\\IdentityMap\\Lru;\/** * @internal *\/final class LruNodeLinks{    \/**     * @phpstan-var int&lt;0, max&gt;|int&lt;-1, -1&gt;     *\/    public int $head = LruNodePool::NIL;    \/**     * @phpstan-var int&lt;0, max&gt;|int&lt;-1, -1&gt;     *\/    public int $tail = LruNodePool::NIL;    \/**     * @phpstan-var array&lt;int&lt;0, max&gt;, int&lt;0, max&gt;|int&lt;-1, -1&gt;&gt;     *\/    private array $prev = [];    \/**     * @phpstan-var array&lt;int&lt;0, max&gt;, int&lt;0, max&gt;|int&lt;-1, -1&gt;&gt;     *\/    private array $next = [];    \/**     * @phpstan-param int&lt;0, max&gt; $node     * @phpstan-return void     *\/    final public function touch(int $node): void    {        if ($node === $this-&gt;tail) {            return;        }        $prev = $this-&gt;prev[$node] ?? LruNodePool::NIL;        $next = $this-&gt;next[$node] ?? LruNodePool::NIL;        if ($prev !== LruNodePool::NIL) {            $this-&gt;next[$prev] = $next;        } else {            $this-&gt;head = $next;        }        if ($next !== LruNodePool::NIL) {            $this-&gt;prev[$next] = $prev;        } else {            $this-&gt;tail = $prev;        }        $this-&gt;prev[$node] = $this-&gt;tail;        $this-&gt;next[$node] = LruNodePool::NIL;        if ($this-&gt;tail !== LruNodePool::NIL) {            $this-&gt;next[$this-&gt;tail] = $node;        } else {            $this-&gt;head = $node;        }        $this-&gt;tail = $node;    }    \/**     * @phpstan-param int&lt;0, max&gt; $node     * @phpstan-return void     *\/    final public function detach(int $node): void    {        $prev = $this-&gt;prev[$node] ?? LruNodePool::NIL;        $next = $this-&gt;next[$node] ?? LruNodePool::NIL;        if ($prev !== LruNodePool::NIL) {            $this-&gt;next[$prev] = $next;        } else {            $this-&gt;head = $next;        }        if ($next !== LruNodePool::NIL) {            $this-&gt;prev[$next] = $prev;        } else {            $this-&gt;tail = $prev;        }    }    \/**     * @phpstan-param int&lt;0, max&gt; $node     * @phpstan-return void     *\/    final public function push(int $node): void    {        $this-&gt;prev[$node] = $this-&gt;tail;        $this-&gt;next[$node] = LruNodePool::NIL;        if ($this-&gt;tail !== LruNodePool::NIL) {            $this-&gt;next[$this-&gt;tail] = $node;        } else {            $this-&gt;head = $node;        }        $this-&gt;tail = $node;    }    \/**     * @phpstan-return void     *\/    final public function reset(): void    {        $this-&gt;head = LruNodePool::NIL;        $this-&gt;tail = LruNodePool::NIL;    }    \/**     * @phpstan-return void     *\/    final public function clear(): void    {        $this-&gt;head = LruNodePool::NIL;        $this-&gt;tail = LruNodePool::NIL;                $this-&gt;prev = [];        $this-&gt;next = [];    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Doubly linked list \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445 (<code>$prev<\/code>, <code>$next<\/code>). \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0442\u043e\u043b\u044c\u043a\u043e <strong>integer IDs<\/strong>. \u042d\u0442\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b: \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 PHP \u2014 \u044d\u0442\u043e \u0434\u043e\u0440\u043e\u0433\u0430\u044f \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u044f \u0438 \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u0447\u0435\u0440\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0430 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a <code>$this-&gt;prev[$node]<\/code> JIT \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432 \u043f\u0440\u044f\u043c\u043e\u0439 \u043e\u0444\u0444\u0441\u0435\u0442\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p><code>LruNodePool<\/code><\/p>\n<pre><code class=\"php\">&lt;?php declare(strict_types=1);namespace App\\Orm\\IdentityMap\\Lru;\/** * @internal *\/final class LruNodePool{    \/**     * @phpstan-var int&lt;-1, -1&gt;     *\/    public const int NIL = -1;    \/**     * @phpstan-var list&lt;int&lt;0, max&gt;&gt;     *\/    private array $releasedIds = [];    \/**     * @phpstan-var int&lt;0, max&gt;     *\/    private int $nextNewId = 0;    \/**     * @phpstan-param int&lt;1, max&gt; $capacity     * @throws \\InvalidArgumentException     *\/    public function __construct(        private readonly int $capacity    ) {        if ($capacity &lt; 1) {            throw new \\InvalidArgumentException(                message: 'Capacity must be at least 1.'            );        }    }    \/**     * @phpstan-return int&lt;0, max&gt;     * @throws \\RuntimeException     *\/    final public function allocate(): int    {        return match (true) {            $this-&gt;releasedIds !== []                =&gt; array_pop(array: $this-&gt;releasedIds),            $this-&gt;nextNewId &lt; $this-&gt;capacity                =&gt; $this-&gt;nextNewId++,            default =&gt; throw new \\RuntimeException(                message: sprintf(                    'LruNodePool exhausted: capacity %d.',                    $this-&gt;capacity                )            ),        };    }    \/**     * @phpstan-param int&lt;0, max&gt; $node     * @phpstan-return void     *\/    final public function release(int $node): void    {        $this-&gt;releasedIds[] = $node;    }    \/**     * @phpstan-return void     *\/    final public function clear(): void    {        $this-&gt;releasedIds = [];        $this-&gt;nextNewId = 0;    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0443\u043b ID \u0434\u043b\u044f \u0443\u0437\u043b\u043e\u0432. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0434\u0430\u0435\u0442 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0451\u043d\u043d\u044b\u0435 <strong>ID<\/strong> \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 <code>$releasedIds<\/code>, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0435 <code>$nextNewId<\/code>. \u041a\u043e\u0433\u0434\u0430 \u0435\u043c\u043a\u043e\u0441\u0442\u044c \u0438\u0441\u0447\u0435\u0440\u043f\u0430\u043d\u0430 \u2014 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u041a\u043b\u044e\u0447\u0435\u0432\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f: 0 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0443\u043b\u0430. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <code>array_pop() <\/code>\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043a\u043e\u043d\u0435\u0446 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>[]<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0437\u0430 <strong>O(1)<\/strong> \u0431\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>match(true)<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0438 <code>if<\/code>\/<code>elseif<\/code>\/<code>else<\/code> \u0434\u0430\u0435\u0442 \u0442\u0443 \u0436\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c (<em>JIT \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e<\/em>), \u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u044b\u0434\u0430\u0447\u0438 <strong>ID<\/strong> \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c\u0438.<\/p>\n<h2>\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438<\/h2>\n<p><strong>\u0421\u0440\u0435\u0434\u0430<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 \u043d\u043e\u0443\u0442\u0431\u0443\u043a (<em>\u0441\u0430\u043c\u044b\u0439 \u043e\u0431\u044b\u0447\u043d\u044b\u0439<\/em>).<\/p>\n<\/li>\n<li>\n<p>Docker + highload (<em>\u043a\u0443\u0447\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432<\/em>).<\/p>\n<\/li>\n<li>\n<p>PHP 8.5-FPM + JIT 1255 + 64M buffer.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/strong>:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0422\u0435\u0441\u0442<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>ops\/sec<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>ns\/op<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Warm touch (100% hits)<\/p>\n<\/td>\n<td>\n<p align=\"left\">15.4 \u043c\u043b\u043d.<\/p>\n<\/td>\n<td>\n<p align=\"left\">64 \u043d\u0441.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Cold insert + eviction<\/p>\n<\/td>\n<td>\n<p align=\"left\">7.7 \u043c\u043b\u043d.<\/p>\n<\/td>\n<td>\n<p align=\"left\">130 \u043d\u0441.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Random access<\/p>\n<\/td>\n<td>\n<p>10.1 \u043c\u043b\u043d.<\/p>\n<\/td>\n<td>\n<p align=\"left\">99 \u043d\u0441.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Hot-set access<\/p>\n<\/td>\n<td>\n<p align=\"left\">13.5 \u043c\u043b\u043d.<\/p>\n<\/td>\n<td>\n<p align=\"left\">74 \u043d\u0441.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>15+ \u043c\u043b\u043d. ops\/sec \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0435 \u0432 \u0442\u044f\u0436\u0435\u043b\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438 Docker. \u041d\u0430 bare metal \u0436\u0435\u043b\u0435\u0437\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0443\u0431\u0435\u0440\u0435\u0442 \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0435 L3-\u043a\u044d\u0448\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u043f\u0440\u043e\u0433\u043b\u043e\u0442\u044f\u0442 \u0432\u0430\u0448\u0438 flat-\u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0431\u0435\u0437 \u043f\u0440\u043e\u043c\u0430\u0445\u043e\u0432, \u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 Huge Pages \u0443\u0441\u043a\u043e\u0440\u044f\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 JIT-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0432 OPCache. \u041f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0439 throughput \u043d\u0430 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435 \u2014 25\u201330+ \u043c\u043b\u043d. ops\/sec. \u042d\u0442\u043e\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u0430\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f: \u0431\u0443\u0442\u044b\u043b\u043e\u0447\u043d\u044b\u043c \u0433\u043e\u0440\u043b\u044b\u0448\u043a\u043e\u043c \u0441\u043d\u043e\u0432\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u043d\u0435 \u0432\u0430\u0448 <strong>Identity Map<\/strong>.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1081482\/\">https:\/\/habr.com\/ru\/articles\/1081482\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>LRU \u043d\u0430 PHP \u2014 \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e, \u0432\u0440\u043e\u0434\u0435 \u0431\u044b, \u0443\u0436\u0435 \u0432\u0441\u0435 \u043a\u043e\u043c\u0443 \u043d\u0435 \u043b\u0435\u043d\u044c \u0440\u0435\u0448\u0438\u043b\u0438 \u0432\u0434\u043e\u043b\u044c \u0438 \u043f\u043e\u043f\u0435\u0440\u0451\u043a.\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0445\u0435\u043c\u0430: O(1)-\u043f\u043e\u0438\u0441\u043a \u043f\u043e \u043a\u043b\u044e\u0447\u0443 + \u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u2014 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0432\u0441\u0435\u043c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0448\u044c \u043c\u0435\u0440\u0438\u0442\u044c, \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0432\u044b\u0434\u0430\u044e\u0442 2\u20135 \u043c\u043b\u043d ops\/sec. \u0414\u043b\u044f \u0432\u0435\u0431\u0430 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u0430 \u0432\u043e\u0442 \u0434\u043b\u044f highload \u2014 \u0443\u0436\u0435 \u043d\u0435\u0442. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 LRU \u2014 \u044d\u0442\u043e \u043d\u0435 \u00ab\u0433\u0434\u0435-\u0442\u043e \u0432 \u043a\u044d\u0448\u0435 Redis\u00bb, \u0430 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442 Identity Map, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0438\u0434\u0438\u0442 \u043f\u0440\u044f\u043c\u043e \u0432 hot path \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u042f \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u043e\u0439 \u043f\u0435\u0440\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0432\u0435\u0440\u0445 Eloquent \u2014 \u0441 Identity Map, Unit of Work \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b LRU \u2014 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0439. \u0415\u0441\u043b\u0438 \u0435\u0433\u043e \u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0438\u0436\u0435 2\u20133 \u043c\u043b\u043d ops\/sec, \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u043a\u044d\u0448\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u0441\u043e\u0442\u043d\u044f\u043c\u0438 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441. \u042d\u0442\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c\u043e \u0441\u043e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0411\u0414. \u0412 \u0438\u0442\u043e\u0433\u0435 Identity Map \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u043e\u043a\u0443\u043f\u0430\u0442\u044c\u0441\u044f: \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0438\u0441\u0442\u0443\u044e \u0434\u0435\u0433\u0440\u0430\u0434\u0430\u0446\u0438\u044e latency \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0445\u0438\u0442\u0430.\u042f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u044e LRU, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0437\u043a\u0438\u043c \u043c\u0435\u0441\u0442\u043e\u043c \u0432\u043e\u043e\u0431\u0449\u0435.\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439: \u0432\u0437\u044f\u0442\u044c \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e (HashMap + doubly linked list), \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0443\u0447\u0435\u0441\u0442\u044c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 JIT. \u041d\u0430 \u0434\u0435\u043b\u0435 \u2014 10 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439, \u043a\u0430\u0436\u0434\u0430\u044f \u0441 \u0437\u0430\u043c\u0435\u0440\u043e\u043c. \u0413\u0434\u0435-\u0442\u043e \u044f \u0442\u0435\u0440\u044f\u043b 50% \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 property hooks, \u0430 \u0433\u0434\u0435-\u0442\u043e, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 \u0434\u0430\u0432\u0430\u043b\u043e +25%.\u0418\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u0446\u0438\u0444\u0440\u0430: 15.4 \u043c\u043b\u043d ops\/sec \u043d\u0430 touch \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0438 \u044d\u0442\u043e \u0432\u0441\u0451 \u043d\u0430 \u0441\u043b\u0430\u0431\u043e\u043c \u043d\u043e\u0443\u0442\u0435, \u0434\u0430 \u0435\u0449\u0451 \u0438 \u0432 Docker \u0441 \u043a\u0443\u0447\u0435\u0439 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041d\u0430 \u043f\u0440\u043e\u0434\u0435, \u043f\u0440\u0430\u0432\u0434\u0430, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u043b.\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441&lt;?php declare(strict_types=1);namespace App\\Orm\\IdentityMap\\Lru;\/** * @phpstan-extends \\IteratorAggregate&lt;int, non-empty-string&gt; *\/interface LruCacheInterface extends \\Countable, \\IteratorAggregate{    \/**     * @phpstan-param non-empty-string $key     * @phpstan-return non-empty-string|null     *\/    public function touch(string $key): ?string;    \/**     * @phpstan-param iterable&lt;non-empty-string&gt; $keys     * @phpstan-return list&lt;non-empty-string&gt;     *\/    public function touchMany(iterable $keys): array;    \/**     * @phpstan-return non-empty-string|null     * @throws \\AssertionError     *\/    public function evict(): ?string;    \/**     * @phpstan-param string $key     * @phpstan-return void     *\/    public function remove(string $key): void;    \/**     * @phpstan-return void     *\/    public function clear(): void;}\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b:touch() \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043b\u044e\u0447 \u0438\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u044e. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 evicted key (\u0435\u0441\u043b\u0438 \u0431\u044b\u043b).touchMany() \u2014 \u043c\u0430\u0441\u0441\u043e\u0432\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u044b\u0442\u0435\u0441\u043d\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439.evict() \u2014 \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u0442\u0435\u0441\u043d\u0435\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430.remove() \u2014 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430.clear() \u2014 \u043f\u043e\u043b\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440.\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f&lt;?php declare(strict_types=1);namespace App\\Orm\\IdentityMap\\Lru;\/** * @implements LruCacheInterface *\/final class LruCache implements LruCacheInterface{    \/**     * @phpstan-var array&lt;non-empty-string, int&lt;0, max&gt;&gt;     *\/    private array $nodes = [];    \/**     * @phpstan-var int&lt;0, max&gt;     *\/    private int $size = 0;    \/**     * @phpstan-var LruNodePool     *\/    private readonly LruNodePool $pool;    \/**     * @phpstan-var LruNodeKeys     *\/    private readonly LruNodeKeys $keys;    \/**     * @phpstan-var LruNodeLinks     *\/    private readonly LruNodeLinks $links;    \/**     * @phpstan-param int&lt;1, max&gt; $capacity     * @throws \\InvalidArgumentException     *\/    public function __construct(        private readonly int $capacity    ) {        if ($capacity &lt; 1) {            throw new \\InvalidArgumentException(                message: &#8216;Capacity must be at least 1.&#8217;            );        }        $this-&gt;pool = new LruNodePool(            capacity: $capacity        );        $this-&gt;keys = new LruNodeKeys();        $this-&gt;links = new LruNodeLinks();    }    \/**     * @phpstan-param non-empty-string $key     * @phpstan-return non-empty-string|null     *\/    #[\\NoDiscard]    public function touch(string $key): ?string    {        $node = $this-&gt;nodes[$key] ?? null;        if ($node !== null) {            if ($node !== $this-&gt;links-&gt;tail) {                $this-&gt;links-&gt;touch(node: $node);            }            return null;        }        $evicted = $this-&gt;size &gt;= $this-&gt;capacity            ? $this-&gt;evict()            : null;        $node = $this-&gt;pool-&gt;allocate();                $this-&gt;keys-&gt;set(node: $node, key: $key);        $this-&gt;nodes[$key] = $node;        $this-&gt;links-&gt;push(node: $node);        $this-&gt;size++;        return $evicted;    }    \/**     * @phpstan-param iterable&lt;non-empty-string&gt; $keys     * @phpstan-return list&lt;non-empty-string&gt;     *\/    #[\\NoDiscard]    public function touchMany(iterable $keys): array    {        $evicted = [];        foreach ($keys as $key) {            $result = $this-&gt;touch(key: $key);            if ($result !== null) {                $evicted[] = $result;            }        }        return $evicted;    }    \/**     * @phpstan-return non-empty-string|null     * @throws \\AssertionError     *\/    #[\\NoDiscard]    public function evict(): ?string    {        if ($this-&gt;links-&gt;head === LruNodePool::NIL) {            return null;        }        \/** @phpstan-var int&lt;0, max&gt; $node *\/        $node = $this-&gt;links-&gt;head;        $key = $this-&gt;keys-&gt;get(node: $node);        if ($key === null) {            throw new \\AssertionError(                message: &#8216;LRU head has null key.&#8217;            );        }        $this-&gt;links-&gt;detach(node: $node);        unset($this-&gt;nodes[$key]);        $this-&gt;pool-&gt;release(node: $node);        $this-&gt;size&#8212;;        return $key;    }    \/**     * @phpstan-return \\Generator&lt;int, non-empty-string&gt;     * @throws \\AssertionError     *\/    public function getIterator(): \\Generator    {        $node = $this-&gt;links-&gt;head;        while ($node !== LruNodePool::NIL) {            \/** @phpstan-var int&lt;0, max&gt; $node *\/            $key = $this-&gt;keys-&gt;get(node: $node);            if ($key === null) {                throw new \\AssertionError(                    message: &#8216;LRU list node has null key.&#8217;                );            }            $next = $this-&gt;links-&gt;next[$node]                ?? LruNodePool::NIL;            yield $key;            $node = $next;        }    }    \/**     * @phpstan-return int&lt;0, max&gt;     *\/    public function count(): int    {        return $this-&gt;size;    }    \/**     * @phpstan-param string $key     * @phpstan-return void     *\/    public function remove(string $key): void    {        $node = $this-&gt;nodes[$key] ?? null;        if ($node === null) {            return;        }        $this-&gt;links-&gt;detach(node: $node);        unset($this-&gt;nodes[$key]);        $this-&gt;pool-&gt;release(node: $node);        $this-&gt;size&#8212;;    }    \/**     * @phpstan-return void     *\/    public function clear(): void    {        $this-&gt;links-&gt;clear();        $this-&gt;pool-&gt;clear();        $this-&gt;keys-&gt;clear();        $this-&gt;nodes = [];        $this-&gt;size = 0;    }}\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f:\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438: LruNodePool, LruNodeKeys, LruNodeLinks \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u0432\u043e\u044e \u043f\u043b\u043e\u0441\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e \u043d\u0435 \u00ab\u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 = \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435\u00bb, \u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f JIT inlining. \u041c\u0435\u043b\u043a\u0438\u0439 final-\u043c\u0435\u0442\u043e\u0434 JIT \u0438\u043d\u043b\u0430\u0439\u043d\u0438\u0442 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u0443\u0435\u0442 \u0434\u043e\u043b\u0433\u043e.\u041f\u043b\u043e\u0441\u043a\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b (Integer ID maps): $nodes \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u043c\u0443 ID \u0443\u0437\u043b\u0430 ($keyString =&gt; $nodeId), \u0430 \u043d\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u041c\u0435\u043d\u044c\u0448\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439 GC, \u043b\u0443\u0447\u0448\u0435 locality \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f CPU-\u043a\u044d\u0448\u0430.\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u043b (Object Pooling): LruNodePool \u0432\u044b\u0434\u0430\u0451\u0442 ID \u0438\u0437 \u043f\u0443\u043b\u0430 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0430 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 0 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0441\u043b\u0435 initial population.Readonly-\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430: $pool, $keys, $links, $capacity \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u043a\u0430\u043a readonly. JIT-\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u0435\u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0435\u0442 \u2014 \u043f\u043e\u043b\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430.\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441: \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0431\u0438\u0440\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (vtable check). \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 JIT \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u0438\u043d\u043b\u0430\u0439\u043d\u0438\u043d\u0433 \u0433\u043e\u0440\u044f\u0447\u0438\u0445 \u043f\u0443\u0442\u0435\u0439 ($this-&gt;links-&gt;touch(\u2026)).\u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044bLruNodeKeys&lt;?php declare(strict_types=1);namespace App\\Orm\\IdentityMap\\Lru;\/** * @internal *\/final class LruNodeKeys{    \/**     * @phpstan-var array&lt;int&lt;0, max&gt;, non-empty-string|null&gt;     *\/    private array $keys = [];    \/**     * @phpstan-param int&lt;0, max&gt; $node     * @phpstan-param non-empty-string $key     *     * @phpstan-return void     *\/    final public function set(int $node, string $key): void    {        $this-&gt;keys[$node] = $key;    }    \/**     * @phpstan-param int&lt;0, max&gt; $node     * @phpstan-return non-empty-string|null     *\/    final public function get(int $node): ?string    {        return $this-&gt;keys[$node] ?? null;    }    \/**     * @phpstan-param int&lt;0, max&gt; $node     * @phpstan-return void     *\/    final public function reset(int $node): void    {        $this-&gt;keys[$node] = null;    }    \/**     * @phpstan-return void     *\/    final public function clear(): void    {        $this-&gt;keys = [];    }}\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 node_id \u2192 key. \u041a\u0440\u043e\u0448\u0435\u0447\u043d\u044b\u0439 final-\u043a\u043b\u0430\u0441\u0441 = JIT \u0438\u043d\u043b\u0430\u0439\u043d\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u0434\u043e \u043e\u0434\u043d\u043e\u0433\u043e MOV-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a \u043c\u0430\u0441\u0441\u0438\u0432\u0443. \u0415\u0441\u043b\u0438 \u0431\u044b \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0431\u044b\u043b \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e LruCache, JIT \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u0430\u043b \u0431\u044b \u0432\u0435\u0441\u044c \u043e\u0431\u044a\u0435\u043c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0440\u0430\u0434\u0438 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u2014 \u043b\u0438\u0448\u043d\u0438\u0435 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f, \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u043e\u0432.LruNodeLinks&lt;?php declare(strict_types=1);namespace App\\Orm\\IdentityMap\\Lru;\/** * @internal *\/final class LruNodeLinks{    \/**     * @phpstan-var int&lt;0, max&gt;|int&lt;-1, -1&gt;     *\/    public int $head = LruNodePool::NIL;    \/**     * @phpstan-var int&lt;0, max&gt;|int&lt;-1, -1&gt;     *\/    public int $tail = LruNodePool::NIL;    \/**     * @phpstan-var array&lt;int&lt;0, max&gt;, int&lt;0, max&gt;|int&lt;-1, -1&gt;&gt;     *\/    private array $prev = [];    \/**     * @phpstan-var array&lt;int&lt;0, &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-494436","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/494436","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=494436"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/494436\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=494436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=494436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=494436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}