Skip to content

perf(files): keep the mimetype table in the local cache - #64091

Open
solracsf wants to merge 1 commit into
masterfrom
perf/mimetype-loader-local-cache
Open

perf(files): keep the mimetype table in the local cache#64091
solracsf wants to merge 1 commit into
masterfrom
perf/mimetype-loader-local-cache

Conversation

@solracsf

@solracsf solracsf commented Sep 7, 2026

Copy link
Copy Markdown
Member

Summary

OC\Files\Type\Loader loaded the whole oc_mimetypes table from the database in every PHP process that touched the filesystem: in a captured workload the SELECT id, mimetype FROM oc_mimetypes statement ran 154 times across 169 connections. The table is append-only and tiny, so keep it in the local memcache (one hour TTL) and serve lookups from there.

A cached copy can miss rows another process or host added after it was taken, so an unknown id or mimetype reloads the table from the database once per loader instance before it is reported as missing; store() and reset() drop the cached copy.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@solracsf solracsf added this to the Nextcloud 36 milestone Sep 7, 2026
@solracsf
solracsf requested a review from a team as a code owner September 7, 2026 07:45
@solracsf solracsf added 3. to review Waiting for reviews performance 🚀 labels Sep 7, 2026
@solracsf
solracsf requested review from Altahrim, leftybournes, provokateurin and salmart-dev and removed request for a team September 7, 2026 07:45
Comment thread lib/private/Files/Type/Loader.php Outdated
OC\Files\Type\Loader loaded the whole oc_mimetypes table from the database
in every PHP process that touched the filesystem: in a captured workload the
`SELECT id, mimetype FROM oc_mimetypes` statement ran 154 times across 169
connections. The table is append-only and tiny, so keep it in the local
memcache (createLocal('mimetypes'), one hour TTL) and serve lookups from
there.

A cached copy can miss rows another process or host added after it was
taken, so an unknown id or mimetype reloads the table from the database
once per loader instance before it is reported as missing; store() and
reset() drop the cached copy.

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf
solracsf force-pushed the perf/mimetype-loader-local-cache branch from 65f7577 to f4ad2f9 Compare September 7, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants