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

fix(taskprocessing): More caching #50331

Merged
merged 6 commits into from
Jan 25, 2025

Conversation

marcelklehr
Copy link
Member

@marcelklehr marcelklehr commented Jan 23, 2025

Summary

Shave off some miliseconds.

Checklist

@marcelklehr marcelklehr force-pushed the fix/perf/cache-avilable-taskt-types branch from 59e1551 to 258df9e Compare January 23, 2025 08:54
@marcelklehr marcelklehr requested a review from kyteinsky January 23, 2025 09:00
) {
$this->appData = $appDataFactory->get('core');
$this->cache = $cacheFactory->createLocal('task_processing::');
Copy link
Contributor

Choose a reason for hiding this comment

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

distributed cache would be good here too, it falls back to local cache if unavailable

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe we can't use distributed cache here because it uses json_encode to serialize the values and that breaks stuff

Copy link
Member Author

Choose a reason for hiding this comment

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

apcu will serialize faithfully, afaik

Copy link
Contributor

Choose a reason for hiding this comment

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

we can probably handle the json_encode ourselves and pass the validated result only to the cache but feel free to use local only, won't affect it much

Copy link
Member

Choose a reason for hiding this comment

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

At least the result of getAvailableTaskTypes( should be string-array only? So should be totally fine?

Copy link
Member

Choose a reason for hiding this comment

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

Small comment regarding local vs distributed cache.

Local cache should typically be better for performance because it has lower latency. The distributed cache leaves the machine, at least for clustered setups with a dedicated Redis node.

Copy link
Member Author

Choose a reason for hiding this comment

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

At least the result of getAvailableTaskTypes( should be string-array only?

It's not, sadly

@marcelklehr marcelklehr changed the title fix(taskrpocessing): Cache result of getAvailableTaskTypes between requests fix(taskprocessing): More cachingCache result of getAvailableTaskTypes between requests Jan 23, 2025
@marcelklehr marcelklehr changed the title fix(taskprocessing): More cachingCache result of getAvailableTaskTypes between requests fix(taskprocessing): More caching Jan 23, 2025
lib/private/TaskProcessing/Manager.php Outdated Show resolved Hide resolved
@marcelklehr marcelklehr enabled auto-merge January 23, 2025 11:01
@marcelklehr
Copy link
Member Author

/backport to stable31

@marcelklehr
Copy link
Member Author

/backport to stable30

@marcelklehr
Copy link
Member Author

Cypress failure seems unrelated

cc @AndyScherzinger

@marcelklehr
Copy link
Member Author

Together with nextcloud/app_api#500 this shaves 150ms off getNextScheduledTask on my machine

@marcelklehr marcelklehr force-pushed the fix/perf/cache-avilable-taskt-types branch from 0c393bf to 028e6e2 Compare January 24, 2025 09:40
@oleksandr-nc
Copy link
Contributor

Together with nextcloud/app_api#500 this shaves 150ms off getNextScheduledTask on my machine

Quite a serious figure, excellent optimization!

@marcelklehr marcelklehr disabled auto-merge January 24, 2025 10:45
@marcelklehr marcelklehr force-pushed the fix/perf/cache-avilable-taskt-types branch from 028e6e2 to fa4bd44 Compare January 24, 2025 11:19
@marcelklehr marcelklehr force-pushed the fix/perf/cache-avilable-taskt-types branch from fa4bd44 to a610002 Compare January 24, 2025 15:45
@marcelklehr marcelklehr merged commit b0d1f2c into master Jan 25, 2025
190 checks passed
@marcelklehr marcelklehr deleted the fix/perf/cache-avilable-taskt-types branch January 25, 2025 08:11
@AndyScherzinger AndyScherzinger added this to the Nextcloud 32 milestone Jan 25, 2025
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.

7 participants