Skip to content

[Serializer] add array cache in front of serializer cache #35079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

bastnic
Copy link
Contributor

@bastnic bastnic commented Dec 21, 2019

Q A
Branch? master
Bug fix? performance
New feature? ...
Deprecations? no
Tickets #35041
License MIT
Doc PR

This is another implementation of #35041, after #35046.

The DI solution is cleaner, but 10ms slower on my scenario (13 vs 3) and this data is not supposed to change at all (even in the original method there is a local cache).

Diff from master (without warmup):

image

Diff form master (with warmup):

image

Diff from #35046:

image

Ping @nicolas-grekas

@bastnic
Copy link
Contributor Author

bastnic commented Dec 21, 2019

ab -n 100

# local cache, warmup:

  50%     63
  66%     64
  75%     66
  80%     68
  90%     72
  95%     75
  98%     80
  99%     82
 100%     82 (longest request)


# di cache, warmup

  50%     65
  66%     66
  75%     66
  80%     67
  90%     72
  95%     76
  98%     78
  99%     82
 100%     82 (longest request)


# warmup

  50%     75
  66%     77
  75%     79
  80%     81
  90%     83
  95%     88
  98%     93
  99%    110
 100%    110 (longest request)


# no warmup

  50%    208
  66%    223
  75%    233
  80%    237
  90%    260
  95%    280
  98%    290
  99%    301
 100%    301 (longest request)

@nicolas-grekas nicolas-grekas added this to the next milestone Dec 21, 2019
@bastnic bastnic force-pushed the feature/35041-cache-CacheClassMetadataFactory2 branch from 519d26e to 6ee306b Compare December 22, 2019 09:08
@xabbuh
Copy link
Member

xabbuh commented Dec 23, 2019

Should we implement the ResettableInterface to avoid memory leaks on long running processes?

@nicolas-grekas
Copy link
Member

Should we implement the ResettableInterface to avoid memory leaks on long running processes?

I'm not sure this would qualify as a leak: the memory requirement is asymptotic, ie it won't grow once all classes used by the app have been loaded. This is the same for eg opcache.
No need to reset to me.

@@ -32,6 +32,8 @@ class CacheClassMetadataFactory implements ClassMetadataFactoryInterface
*/
private $cacheItemPool;

private $loadedClasses = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is misleading. It's actually an array of ClassMetadata.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolas-grekas nicolas-grekas changed the title [Cache] add array cache in front of serializer cache [Serializer] add array cache in front of serializer cache Dec 26, 2019
@nicolas-grekas
Copy link
Member

Thank you @bastnic.

nicolas-grekas added a commit that referenced this pull request Dec 26, 2019
…e (bastnic)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[Serializer] add array cache in front of serializer cache

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | performance
| New feature?  | ...
| Deprecations? | no
| Tickets       | #35041
| License       | MIT
| Doc PR        |

This is another implementation of #35041, after #35046.

The DI solution is cleaner, but 10ms slower on my scenario (13 vs 3) and this data is not supposed to change at all (even in the original method there is a local cache).

Diff from master (without warmup):

![image](https://user-images.githubusercontent.com/84887/71313592-2cb5be00-243b-11ea-8983-b30abb7d0698.png)

Diff form master (with warmup):

![image](https://user-images.githubusercontent.com/84887/71313633-8e762800-243b-11ea-8044-003c810d3c0b.png)

Diff from #35046:

![image](https://user-images.githubusercontent.com/84887/71313668-312ea680-243c-11ea-9768-8531f4f33f3c.png)

Ping @nicolas-grekas

Commits
-------

6ee306b [Cache] add array cache in front of serializer cache
@nicolas-grekas nicolas-grekas merged commit 6ee306b into symfony:master Dec 26, 2019
@bastnic bastnic deleted the feature/35041-cache-CacheClassMetadataFactory2 branch December 26, 2019 08:56
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants