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

Package Eviction #225

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Package Eviction #225

wants to merge 23 commits into from

Conversation

pt-07
Copy link

@pt-07 pt-07 commented Mar 6, 2024

Added code to correctly output package sizes

Copy link
Member

@tylerharter tylerharter left a comment

Choose a reason for hiding this comment

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

Great progress!

@@ -175,6 +179,29 @@ func (pp *PackagePuller) sandboxInstall(p *Package) (err error) {
return err
}
}
//gets the size of the current package
Copy link
Member

Choose a reason for hiding this comment

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

let's have a separate function for computing the directory size recursively

@@ -175,6 +179,29 @@ func (pp *PackagePuller) sandboxInstall(p *Package) (err error) {
return err
}
}
//gets the size of the current package
cmd := exec.Command("du", "-sb", scratchDir)
Copy link
Member

Choose a reason for hiding this comment

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

let's compute the size without running an external program

cmd.Stdout = &out
err = cmd.Run()
if err != nil {
log.Fatal(err)
Copy link
Member

Choose a reason for hiding this comment

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

Fatal will kill the server. I don't think that's a proportionate response to an error. Better to return it back.

@@ -12,7 +12,9 @@ import (
"strings"
"sync"
"sync/atomic"

"regexp"
"strconv"
Copy link
Member

Choose a reason for hiding this comment

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

spacing

@@ -36,8 +38,10 @@ type Package struct {
Meta PackageMeta
installMutex sync.Mutex
installed uint32
Size int
Copy link
Member

Choose a reason for hiding this comment

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

Will need to be protected by some lock. Perhaps with installMutex? Which would then need to be renamed to reflect the broader usage

}

var totalPackageSize = 0
Copy link
Member

Choose a reason for hiding this comment

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

If we have a total size variable like this, it will need to be lock protected. Perhaps we can keep this PR simple, and figure out those details in a future PR that actually implements eviction?

@@ -175,6 +179,29 @@ func (pp *PackagePuller) sandboxInstall(p *Package) (err error) {
return err
}
}
//gets the size of the current package
Copy link
Member

Choose a reason for hiding this comment

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

let's have a config option so we don't compute/log size unless doing so is enabled

@tylerharter tylerharter self-requested a review May 21, 2024 13:10
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.

None yet

2 participants