Skip to content

Fix cache keys of the metadata factories - #220

Merged
DanielBadura merged 1 commit into
1.24.xfrom
fix-metadata-cache-keys-1x
Oct 7, 2026
Merged

DanielBadura merged 1 commit into
1.24.xfrom
fix-metadata-cache-keys-1x

Conversation

@DanielBadura

Copy link
Copy Markdown
Member

The PSR-6 and PSR-16 metadata factories used the class name as cache key. Class names contain a backslash, which is a reserved character in PSR-6 and PSR-16, so the factories failed with any compliant cache like symfony/cache. The class name is now hashed and prefixed, and a cache hit is only accepted if the cached metadata really belongs to the requested class.

Unserialized metadata also missed some values, so metadata loaded from a cache failed as soon as they were accessed: the class name of the class metadata, and the property name, type and personal data fallback callable of the property metadata.

The PSR-6 and PSR-16 metadata factories used the class name as cache key.
Class names contain a backslash, which is a reserved character in PSR-6 and
PSR-16, so the factories failed with any compliant cache like symfony/cache.
The class name is now hashed and prefixed, and a cache hit is only accepted
if the cached metadata really belongs to the requested class.

Unserialized metadata also missed some values, so metadata loaded from a
cache failed as soon as they were accessed: the class name of the class
metadata, and the property name, type and personal data fallback callable
of the property metadata.
@DanielBadura DanielBadura added this to the 1.24.3 milestone Oct 6, 2026
@DanielBadura DanielBadura added the bug Something isn't working label Oct 6, 2026
@DanielBadura DanielBadura self-assigned this Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Hello 👋

here is the most recent benchmark result:

StackHydratorBench
==================

+-------------------------------+--------------------+--------------------+-----------------+------------+
|                               | time (kde mode)                         | memory                       |
+-------------------------------+--------------------+--------------------+-----------------+------------+
| subject                       | Tag: <current>     | Tag: base          | Tag: <current>  | Tag: base  |
+-------------------------------+--------------------+--------------------+-----------------+------------+
| benchHydrate1Object ()        | 2.800μs (±0.00%)   | 2.600μs (±0.00%)   | 2.771mb         | 3.270mb    |
| benchExtract1Object ()        | 59.600μs (±0.00%)  | 3.000μs (±0.00%)   | 2.771mb         | 3.270mb    |
| benchHydrate1000Objects ()    | 2.037ms (±0.00%)   | 2.047ms (±0.00%)   | 3.018mb         | 3.484mb    |
| benchExtract1000Objects ()    | 1.777ms (±0.00%)   | 1.755ms (±0.00%)   | 2.941mb         | 3.407mb    |
| benchHydrate1000000Objects () | 1.062s (±0.00%)    | 1.056s (±0.00%)    | 3.018mb         | 3.484mb    |
| benchExtract1000000Objects () | 993.350ms (±0.00%) | 989.485ms (±0.00%) | 2.941mb         | 2.941mb    |
+-------------------------------+--------------------+--------------------+-----------------+------------+

HydratorWithLazyBench
=====================

+------------------------------------------+--------------------+--------------------+-----------------+------------+
|                                          | time (kde mode)                         | memory                       |
+------------------------------------------+--------------------+--------------------+-----------------+------------+
| subject                                  | Tag: <current>     | Tag: base          | Tag: <current>  | Tag: base  |
+------------------------------------------+--------------------+--------------------+-----------------+------------+
| benchHydrate1Object ()                   | 0.800μs (±0.00%)   | 0.800μs (±0.00%)   | 2.771mb         | 2.771mb    |
| benchHydrate1ObjectTriggerInit ()        | 3.000μs (±0.00%)   | 3.000μs (±0.00%)   | 2.771mb         | 2.771mb    |
| benchHydrate1000Objects ()               | 344.333μs (±0.00%) | 348.000μs (±0.00%) | 2.810mb         | 2.810mb    |
| benchHydrate1000ObjectsTriggerInit ()    | 2.578ms (±0.00%)   | 2.596ms (±0.00%)   | 2.934mb         | 2.934mb    |
| benchHydrate1000000Objects ()            | 200.224ms (±0.00%) | 200.799ms (±0.00%) | 2.810mb         | 2.810mb    |
| benchHydrate1000000ObjectsTriggerInit () | 1.480s (±0.00%)    | 1.482s (±0.00%)    | 2.934mb         | 2.934mb    |
+------------------------------------------+--------------------+--------------------+-----------------+------------+

StackHydratorWithCryptographyBench
==================================

+-------------------------------+------------------+------------------+-----------------+------------+
|                               | time (kde mode)                     | memory                       |
+-------------------------------+------------------+------------------+-----------------+------------+
| subject                       | Tag: <current>   | Tag: base        | Tag: <current>  | Tag: base  |
+-------------------------------+------------------+------------------+-----------------+------------+
| benchHydrate1Object ()        | 3.800μs (±0.00%) | 3.800μs (±0.00%) | 2.798mb         | 2.798mb    |
| benchExtract1Object ()        | 3.800μs (±0.00%) | 4.200μs (±0.00%) | 2.798mb         | 2.798mb    |
| benchHydrate1000Objects ()    | 2.972ms (±0.00%) | 3.057ms (±0.00%) | 3.088mb         | 3.088mb    |
| benchExtract1000Objects ()    | 2.604ms (±0.00%) | 2.635ms (±0.00%) | 2.977mb         | 2.977mb    |
| benchHydrate1000000Objects () | 1.529s (±0.00%)  | 1.532s (±0.00%)  | 3.089mb         | 3.089mb    |
| benchExtract1000000Objects () | 1.506s (±0.00%)  | 1.505s (±0.00%)  | 2.974mb         | 2.974mb    |
+-------------------------------+------------------+------------------+-----------------+------------+

HydratorBench
=============

+-------------------------------+--------------------+--------------------+-----------------+------------+
|                               | time (kde mode)                         | memory                       |
+-------------------------------+--------------------+--------------------+-----------------+------------+
| subject                       | Tag: <current>     | Tag: base          | Tag: <current>  | Tag: base  |
+-------------------------------+--------------------+--------------------+-----------------+------------+
| benchHydrate1Object ()        | 3.000μs (±0.00%)   | 3.000μs (±0.00%)   | 2.771mb         | 2.771mb    |
| benchExtract1Object ()        | 2.800μs (±0.00%)   | 2.600μs (±0.00%)   | 2.771mb         | 2.771mb    |
| benchHydrate1000Objects ()    | 2.106ms (±0.00%)   | 2.137ms (±0.00%)   | 2.936mb         | 2.936mb    |
| benchExtract1000Objects ()    | 1.790ms (±0.00%)   | 1.818ms (±0.00%)   | 2.839mb         | 2.839mb    |
| benchHydrate1000000Objects () | 1.007s (±0.00%)    | 997.067ms (±0.00%) | 2.936mb         | 2.936mb    |
| benchExtract1000000Objects () | 928.949ms (±0.00%) | 927.800ms (±0.00%) | 2.839mb         | 2.839mb    |
+-------------------------------+--------------------+--------------------+-----------------+------------+

HydratorWithCryptographyBench
=============================

+-------------------------------+-------------------+-------------------+-----------------+------------+
|                               | time (kde mode)                       | memory                       |
+-------------------------------+-------------------+-------------------+-----------------+------------+
| subject                       | Tag: <current>    | Tag: base         | Tag: <current>  | Tag: base  |
+-------------------------------+-------------------+-------------------+-----------------+------------+
| benchHydrate1Object ()        | 81.200μs (±0.00%) | 86.400μs (±0.00%) | 2.888mb         | 2.888mb    |
| benchExtract1Object ()        | 7.200μs (±0.00%)  | 6.800μs (±0.00%)  | 2.803mb         | 2.803mb    |
| benchHydrate1000Objects ()    | 3.486ms (±0.00%)  | 3.511ms (±0.00%)  | 3.082mb         | 3.082mb    |
| benchExtract1000Objects ()    | 4.477ms (±0.00%)  | 4.554ms (±0.00%)  | 2.984mb         | 2.984mb    |
| benchHydrate1000000Objects () | 1.803s (±0.00%)   | 1.799s (±0.00%)   | 3.082mb         | 3.082mb    |
| benchExtract1000000Objects () | 2.939s (±0.00%)   | 2.924s (±0.00%)   | 2.984mb         | 2.984mb    |
+-------------------------------+-------------------+-------------------+-----------------+------------+

This comment gets update everytime a new commit comes in!

@DanielBadura
DanielBadura merged commit b0c79d2 into 1.24.x Oct 7, 2026
16 of 17 checks passed
@DanielBadura
DanielBadura deleted the fix-metadata-cache-keys-1x branch October 7, 2026 10:27
@DanielBadura DanielBadura modified the milestones: 1.24.3, 2.0.3 Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants