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

Improve linkage cache linkage_cache_performance #8695

Merged
merged 1 commit into from Sep 14, 2020

Conversation

MikeMcQuaid
Copy link
Member

  • Use reference counting so nested CacheStoreDatabase.use share the same underlying database (rather than rereading it every time).
  • Only write out the cache database file when it has changed.
  • Cleanup cache database entries on formula or full brew cleanup.

Fixes #8690

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

- Use reference counting so nested `CacheStoreDatabase.use` share the
  same underlying database (rather than rereading it every time).
- Only write out the cache database file when it has changed.
- Cleanup cache database entries on formula or full `brew cleanup`.

Fixes #8690
@mistydemeo
Copy link
Member

mistydemeo commented Sep 11, 2020

With this branch, performance of brew install improved to about 45 seconds total; we shaved off 1/3 of the total time. brew cleanup shrunk the linkage cache to under 500KB, so that's looking like a good longterm solution here. Notably, that's significantly larger than the size I'd get from deleting the linkage cache entirely and letting it be recreated, but at this size we're spending at most a second in the linkage checker - much more reasonable.

I do notice that the performance at this stage is still moderately worse than having no cache at all - I wonder if we've got more gains to be made. It could also be that the way we're handling this means that we have performance gains from caching with small numbers of formulae installed, but at certain cache sizes performance ends up actually being better without a cache.

return_value
end

# Sets a value in the underlying database (and creates it if necessary).
def set(key, value)
dirty!
Copy link
Contributor

Choose a reason for hiding this comment

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

@MikeMcQuaid MikeMcQuaid merged commit 05d6498 into Homebrew:master Sep 14, 2020
@MikeMcQuaid MikeMcQuaid deleted the linkage_cache_performance branch September 14, 2020 07:37
@claui
Copy link
Contributor

claui commented Sep 14, 2020

Thank you @MikeMcQuaid. That performance gain is immensely helpful!

@MikeMcQuaid
Copy link
Member Author

Thanks for testing @mistydemeo!

I do notice that the performance at this stage is still moderately worse than having no cache at all - I wonder if we've got more gains to be made. It could also be that the way we're handling this means that we have performance gains from caching with small numbers of formulae installed, but at certain cache sizes performance ends up actually being better without a cache.

Yeh, there's definitely improvement to be had here although it's likely very dependent on your disk IO (doing this on an spinning platter HDD will take a lot longer to be slower, from previous measurements). The reference counting I've added here should mean you can wrap multiple calls to e.g. undeclared_runtime_dependencies with a top-level CacheStoreDatabase.use(:linkage) which should avoid reading the file from disk multiple times when not necessary.

@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 12, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linkage cache can grow to gargantuan sizes, causing poor post-install linkage checker performance
4 participants