Skip to content

Cache Dictionary in OPCache #1

@alexander-schranz

Description

@alexander-schranz

We lately did some optimization on Sulu Metadata which could maybe be interesting for this library specially read the builded .bin files.

We got some reports where somebody was on a slow Cloud System (think it was Azure App Server) where file access really is slow as hell. To improve on such Systems the performance we now generating .php file via Symfony Var Exporter, which makes the file being part of the OpCache which is kept in memory.

The simplified version of it looks like this:

$formMetadata = @include $path;
if ($formMetadata instanceof FormMetadata) {
    return $formMetadata;
}

file_put_content($path, '<?php return ' . VarExporter::export($this->generateFormMetadata()) . ';');

$formMetadata = @include $path;

return $formMetadata;

It is used @include as also doing file_exists before would be bad for the performance in such system.

Sure the question is if a additional dependency like symfony/var-exporter is good here. But wanted to share our optimization with you. Maybe you can also implement your own similar mechanic for this library or anything else in Loupe. If the file is / can be changed a \opcache_invalidate($path, true) can be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions