Skip to content
This repository has been archived by the owner on Feb 7, 2020. It is now read-only.

Introduce fragment caching #77

Merged
merged 7 commits into from
Jun 13, 2014
Merged

Introduce fragment caching #77

merged 7 commits into from
Jun 13, 2014

Conversation

robolson
Copy link
Collaborator

Start with two areas:

  • build_time_history json endpoint
  • recent project performance stats in top right of project show page

The project show page is the slowest page because of these two areas. The stats stuff generates a ton of sql queries and build_time_history is one big slow query.

Open question: what should the cache store be? Right now I am using the default which is disk but we have Redis available.

A downside to adding this caching is I had to add touch to the project -> build -> build_part -> build_artifact chain. The updated_ats are going to be changing frequently in order to make cache expiration easy.

@tamird
Copy link

tamird commented May 22, 2014

how about the in-memory cache?

@tamird
Copy link

tamird commented May 22, 2014

disk is generally a bad idea because you end up with a huge number of files which is a pain to remove (think hoist prune)

@robolson
Copy link
Collaborator Author

in-memory cache is not very efficient when used with Phusion Passenger where you have many processes responding to requests.

On disk is actually not that bad if you have a single server. Cleaning up just means removing the cache directory inside #{Rails.root}/tmp/.

@tamird
Copy link

tamird commented May 22, 2014

Removing the directory requires you to unlink every inode, which means it is an O(n) operation, where n is the number of files. very very slow.

@jeversmann
Copy link
Contributor

I've stuck with the file store since we're using Passenger; the speed of clearing the cache shouldn't be a problem if we have a nightly job for it while traffic on the server is low anyway.

The extra javascript code to reformat the elapsed time column in the tables allows fragment caching to be applied to several other pages, and the update_time endpoints allow the page to be more selective about when it triggers a refresh.

= link_to("Rebuild", rebuild_project_build_part_path(@project, @build, @build_part), :method => :post)
- if attempt.running?
= link_to("Abandon", finish_build_attempt_path(attempt, :state => :errored), :method => :post)
- cache("build-attempt-#{attempt.id}-#{attempt.updated_at.to_i}") do
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cache(attempt) will automatically expand to a cache key which includes the id and updated_at.

= link_to("Rebuild", rebuild_project_build_part_path(@project, @build, @build_part), :method => :post)
- if attempt.running?
= link_to("Abandon", finish_build_attempt_path(attempt, :state => :errored), :method => :post)
- cache(attempt) do
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would like to place the entire BuildPart#show page in a cache rather than 1 individual cache for each row.

robolson added a commit that referenced this pull request Jun 13, 2014
@robolson robolson merged commit 4b01bef into master Jun 13, 2014
@robolson robolson deleted the rob/lil-caching branch June 13, 2014 21:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants