Skip to content
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

perf: optimize the permission check to use an in-memory object #889

Merged
merged 2 commits into from
Nov 6, 2024

Conversation

dkarlovi
Copy link
Contributor

@dkarlovi dkarlovi commented Sep 26, 2024

Closes #886.

Comparison current and new, fetching 100 products in a listing:
Comparison-from-Untitled-to-Untitled-Blackfire-09-26-2024_03_04_PM

Copy link

github-actions bot commented Sep 26, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@dkarlovi
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

Copy link

@mattamon
Copy link
Contributor

mattamon commented Oct 4, 2024

@dkarlovi tested it and it works fine. My only concern is that the $cacheKey does not get invalidated if you save the configuration. If the permissions change you need to call cache:clear to make it work.
Could you also please invalidate the key on config save.

Also maybe change the key to datahub_workspace_permissions_ to make it more specific.

@dkarlovi
Copy link
Contributor Author

dkarlovi commented Oct 4, 2024

@mattamon is there a cache tag which gets cleared on workspace save, like asset_ID or object_ID do when they're saved? We can then add a tag to the cache item and it gets automagically invalidated.

@mattamon
Copy link
Contributor

mattamon commented Oct 4, 2024

@mattamon is there a cache tag which gets cleared on workspace save, like asset_ID or object_ID do when they're saved? We can then add a tag to the cache item and it gets automagically invalidated.

Hmm, I checked and it does not seem like it. The configs are in general not cached, other than by the locationaware dao.
But this is a static cache.

@fashxp do you have a tag in mind? Otherwise I would introduce a tag and change the Configuration Dao save method to clear that tag.

@dkarlovi
Copy link
Contributor Author

dkarlovi commented Oct 4, 2024

The configs are in general not cached

IMO that's also an opportunity to improve: why aren't they cached, wouldn't the DAO do that by default? 🤔 This would mean we'd get cache invalidation for free here just by tagging.

@mattamon
Copy link
Contributor

mattamon commented Oct 4, 2024

The configs are in general not cached

IMO that's also an opportunity to improve: why aren't they cached, wouldn't the DAO do that by default? 🤔 This would mean we'd get cache invalidation for free here just by tagging.

Yeah I thought the same.
Like I wrote they are kind of cached here https://github.com/pimcore/pimcore/blob/11.x/lib/Model/Dao/PimcoreLocationAwareConfigDao.php but in a static cache.

@fashxp
Copy link
Member

fashxp commented Oct 4, 2024

@fashxp do you have a tag in mind? Otherwise I would introduce a tag and change the Configuration Dao save method to clear that tag.

nope, no tag in mind... let's introduce a new one.

@dkarlovi
Copy link
Contributor Author

@mattamon friendly ping, did you maybe get a chance to add the cache tag flush on save by any chance in the meantime?

@mattamon
Copy link
Contributor

@dkarlovi ahhh, I actually thought that you will introduce it, since it can be done in the same scope within your PR.
Sorry maybe there was some miscommunication on my part cause I also asked to change datahub_workspace_permissions_ and for me it was clear that you need to do that update on the PR.

So I guess, I have to ask now, can you please introduce this tag in your PR? Would be awesome!

@dkarlovi
Copy link
Contributor Author

I would introduce a tag and change the Configuration Dao save method to clear that tag.

Yes, this directly told me you'll be creating a separate PR to do this. :) OK, I'll try to do both here.

@mattamon
Copy link
Contributor

I would introduce a tag and change the Configuration Dao save method to clear that tag.

Yes, this directly told me you'll be creating a separate PR to do this. :) OK, I'll try to do both here.

Thank you! And sorry again for the confusion!

@CLAassistant
Copy link

CLAassistant commented Nov 5, 2024

CLA assistant check
All committers have signed the CLA.

@dkarlovi
Copy link
Contributor Author

dkarlovi commented Nov 6, 2024

@mattamon ready for review, should be OK now.

Copy link

sonarqubecloud bot commented Nov 6, 2024

Copy link
Contributor

@mattamon mattamon left a comment

Choose a reason for hiding this comment

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

Thank you very much! It works perfectly now!

@mattamon mattamon merged commit 05be8ab into pimcore:1.x Nov 6, 2024
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 2024
@dkarlovi dkarlovi deleted the perf/permissions branch November 6, 2024 13:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement][Perf]: WorkspaceHelper::isAllowed creating hundreds of database queries for listings
6 participants