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

[performance] add caching of status fave, boost of, in reply to ID lists #2060

Conversation

NyaaaWhatsUpDoc
Copy link
Member

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc commented Aug 3, 2023

Description

  • updates go-cache library to use more fine-grained zero value detection
  • adds caching of status fave, boost of and in reply to ID slices
  • adds caching of fetching a boosted status
  • updates wipeStatus() to use a multierror, to ensure full wipe

The diff for this ended up shorter than I thought for the amount of work that went in... This PR is only as short as it is as a culmination of other efforts I put into #2049 #2027.

Checklist

  • I/we have read the GoToSocial contribution guidelines.
  • I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
  • I/we have performed a self-review of added code.
  • I/we have written code that is legible and maintainable by others.
  • I/we have commented the added code, particularly in hard-to-understand areas.
  • I/we have made any necessary changes to documentation.
  • I/we have added tests that cover new code.
  • I/we have run tests and they pass locally with the changes.
  • I/we have run go fmt ./... and golangci-lint run.

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc force-pushed the performance/cache-status-metadata branch from 600525e to a92224c Compare August 3, 2023 09:37
@NyaaaWhatsUpDoc NyaaaWhatsUpDoc force-pushed the performance/cache-status-metadata branch from 9291527 to 44e6942 Compare August 3, 2023 12:02
@NyaaaWhatsUpDoc NyaaaWhatsUpDoc marked this pull request as ready for review August 3, 2023 14:21
Copy link
Contributor

@tsmethurst tsmethurst left a comment

Choose a reason for hiding this comment

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

Looking good!

Just to check, when a new status is put in the database, does it also invalidate the boost IDs and reply IDs cache? Likewise for faves: does a new fave invalidate the faves/likes cache entries for that status ID?

I didn't see it in the code anywhere, so just wanted to verify that that's happening as expected.

Signed-off-by: kim <[email protected]>
@NyaaaWhatsUpDoc
Copy link
Member Author

NyaaaWhatsUpDoc commented Aug 4, 2023

Looking good!

Just to check, when a new status is put in the database, does it also invalidate the boost IDs and reply IDs cache? Likewise for faves: does a new fave invalidate the faves/likes cache entries for that status ID?

I didn't see it in the code anywhere, so just wanted to verify that that's happening as expected.

When a new status or favourite is put in the database, it's wrapped in the cache.Store() function, which calls all the required invalidate hooks :)

…se of multiple entries by same author

Signed-off-by: kim <[email protected]>
@tsmethurst
Copy link
Contributor

Feel free to squerge when you're happy!

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc merged commit 9a291de into superseriousbusiness:main Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants