- Notifications
You must be signed in to change notification settings - Fork925
chore: increase fileCache hit rate in autobuilds lifecycle#18507
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -5,6 +5,8 @@ import ( | ||
"database/sql" | ||
"fmt" | ||
"net/http" | ||
"slices" | ||
"strings" | ||
"sync" | ||
"sync/atomic" | ||
"time" | ||
@@ -155,6 +157,22 @@ func (e *Executor) runOnce(t time.Time) Stats { | ||
returnstats | ||
} | ||
// Sort the workspaces by build template version ID so that we can group | ||
// identical template versions together. This is a slight (and imperfect) | ||
// optimization. | ||
// | ||
// `wsbuilder` needs to load the terraform files for a given template version | ||
// into memory. If 2 workspaces are using the same template version, they will | ||
// share the same files in the FileCache. This only happens if the builds happen | ||
// in parallel. | ||
// TODO: Actually make sure the cache has the files in the cache for the full | ||
// set of identical template versions. Then unload the files when the builds | ||
// are done. Right now, this relies on luck for the 10 goroutine workers to | ||
// overlap and keep the file reference in the cache alive. | ||
Comment on lines +164 to +171 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. yeah, it could be nice if we did more of a "mark and sweep" style release strategy. or maybe generational... oh no, am I about to build a general purpose garbage collector for this? Oh No MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yea, I had a similar set of thoughts and decided this was a good enough idea for this release. There is a better way to do this for sure, and I wonder where else in the codebase we will have similar things going on (prebuilds?). That being a large set of workspaces that have some work to be done in bulk. | ||
slices.SortFunc(workspaces,func(a,b database.GetWorkspacesEligibleForTransitionRow)int { | ||
returnstrings.Compare(a.BuildTemplateVersionID.UUID.String(),b.BuildTemplateVersionID.UUID.String()) | ||
}) | ||
// We only use errgroup here for convenience of API, not for early | ||
// cancellation. This means we only return nil errors in th eg.Go. | ||
eg:= errgroup.Group{} | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.