packages/brig: add performance patches
This commit is contained in:
parent
b6c3325a33
commit
29eb825e6a
4 changed files with 131 additions and 2 deletions
|
@ -1,20 +1,44 @@
|
||||||
{ lib, buildGoModule, fetchFromGitHub }:
|
{ lib, buildGoModule, fetchFromGitHub }:
|
||||||
|
|
||||||
buildGoModule rec {
|
let
|
||||||
|
vp = "github.com/sahib/brig/version";
|
||||||
|
version = {
|
||||||
|
major = "0";
|
||||||
|
minor = "5";
|
||||||
|
patch = "3";
|
||||||
|
releaseType = "develop";
|
||||||
|
gitRev = "6b7eccf8fcbd907fc759f8ca8aa814df8499e2ed";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
buildGoModule {
|
||||||
pname = "brig";
|
pname = "brig";
|
||||||
version = "0.5.3pre";
|
version = "0.5.3pre";
|
||||||
|
|
||||||
subPackages = ["."];
|
subPackages = ["."];
|
||||||
patches = [
|
patches = [
|
||||||
./default-repo-location.patch
|
./default-repo-location.patch
|
||||||
|
./info-no-check-cached.patch
|
||||||
|
./ls-no-check-cached.patch
|
||||||
./pin-ls-recursive.patch
|
./pin-ls-recursive.patch
|
||||||
|
./repin-relaxed-locking.patch
|
||||||
];
|
];
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "sahib";
|
owner = "sahib";
|
||||||
repo = "brig";
|
repo = "brig";
|
||||||
rev = "6b7eccf8fcbd907fc759f8ca8aa814df8499e2ed";
|
rev = version.gitRev;
|
||||||
sha256 = "sha256-lCXSeTIZcIcVcblm9BTUMqTfxO7+BHYQNv6/RlPq14A=";
|
sha256 = "sha256-lCXSeTIZcIcVcblm9BTUMqTfxO7+BHYQNv6/RlPq14A=";
|
||||||
};
|
};
|
||||||
vendorSha256 = "sha256-pFrrMq7VFCwt8KRgJApCq8lPYv0P8hIUOxKJMN9QR0U=";
|
vendorSha256 = "sha256-pFrrMq7VFCwt8KRgJApCq8lPYv0P8hIUOxKJMN9QR0U=";
|
||||||
|
|
||||||
|
ldflags = with version; [
|
||||||
|
"-s" "-w"
|
||||||
|
"-X ${vp}.Major=${major}"
|
||||||
|
"-X ${vp}.Minor=${minor}"
|
||||||
|
"-X ${vp}.Patch=${patch}"
|
||||||
|
"-X ${vp}.GitRev=${gitRev}"
|
||||||
|
"-X ${vp}.ReleaseType=${releaseType}"
|
||||||
|
"-X ${vp}.BuildTime=1970-01-01T01:00:01+01:00"
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
27
packages/tools/brig/info-no-check-cached.patch
Normal file
27
packages/tools/brig/info-no-check-cached.patch
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
diff --git a/cmd/fs_handlers.go b/cmd/fs_handlers.go
|
||||||
|
index d86e8d91..f894ac89 100644
|
||||||
|
--- a/cmd/fs_handlers.go
|
||||||
|
+++ b/cmd/fs_handlers.go
|
||||||
|
@@ -591,14 +591,8 @@ func handleShowFileOrDir(ctx *cli.Context, ctl *client.Client, path string) erro
|
||||||
|
return tmpl.Execute(os.Stdout, info)
|
||||||
|
}
|
||||||
|
|
||||||
|
- isCached, err := ctl.IsCached(path)
|
||||||
|
- if err != nil {
|
||||||
|
- return err
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
pinState := yesify(info.IsPinned)
|
||||||
|
explicitState := yesify(info.IsExplicit)
|
||||||
|
- cachedState := yesify(isCached)
|
||||||
|
|
||||||
|
nodeType := "file"
|
||||||
|
if info.IsDir {
|
||||||
|
@@ -627,7 +621,6 @@ func handleShowFileOrDir(ctx *cli.Context, ctl *client.Client, path string) erro
|
||||||
|
printPair("Inode", strconv.FormatUint(info.Inode, 10))
|
||||||
|
printPair("Pinned", pinState)
|
||||||
|
printPair("Explicit", explicitState)
|
||||||
|
- printPair("Cached", cachedState)
|
||||||
|
printPair("IsRaw", yesify(info.IsRaw))
|
||||||
|
printPair("ModTime", info.ModTime.Format(time.RFC3339))
|
||||||
|
printPair("Tree Hash", info.TreeHash.B58String())
|
37
packages/tools/brig/ls-no-check-cached.patch
Normal file
37
packages/tools/brig/ls-no-check-cached.patch
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
diff --git a/cmd/fs_handlers.go b/cmd/fs_handlers.go
|
||||||
|
index f1791b16..d86e8d91 100644
|
||||||
|
--- a/cmd/fs_handlers.go
|
||||||
|
+++ b/cmd/fs_handlers.go
|
||||||
|
@@ -449,7 +449,7 @@ func handleList(ctx *cli.Context, ctl *client.Client) error {
|
||||||
|
userColumn = "USER\t"
|
||||||
|
}
|
||||||
|
|
||||||
|
- fmt.Fprintf(tabW, "SIZE\tBKEND\tMODTIME\t%sPATH\tPIN\tCACHED\tHINT\n", userColumn)
|
||||||
|
+ fmt.Fprintf(tabW, "SIZE\tBKEND\tMODTIME\t%sPATH\tPIN\tHINT\n", userColumn)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, entry := range entries {
|
||||||
|
@@ -467,22 +467,15 @@ func handleList(ctx *cli.Context, ctl *client.Client) error {
|
||||||
|
userEntry = color.GreenString(userMap[entry.User]) + "\t"
|
||||||
|
}
|
||||||
|
|
||||||
|
- isCached, err := ctl.IsCached(entry.Path)
|
||||||
|
- if err != nil {
|
||||||
|
- return err
|
||||||
|
- }
|
||||||
|
- cachedState := " " + pinStateToSymbol(isCached, false)
|
||||||
|
-
|
||||||
|
fmt.Fprintf(
|
||||||
|
tabW,
|
||||||
|
- "%s\t%s\t%s\t%s%s\t%s\t%s\t%s\n",
|
||||||
|
+ "%s\t%s\t%s\t%s%s\t%s\t%s\n",
|
||||||
|
colorForSize(entry.Size)(humanize.Bytes(entry.Size)),
|
||||||
|
colorForSize(entry.Size)(humanize.Bytes(uint64(entry.CachedSize))),
|
||||||
|
entry.ModTime.Format("2006-01-02 15:04:05 MST"),
|
||||||
|
userEntry,
|
||||||
|
coloredPath,
|
||||||
|
pinState,
|
||||||
|
- cachedState,
|
||||||
|
formatHint(entry.Hint),
|
||||||
|
)
|
||||||
|
}
|
41
packages/tools/brig/repin-relaxed-locking.patch
Normal file
41
packages/tools/brig/repin-relaxed-locking.patch
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
diff --git a/catfs/repin.go b/catfs/repin.go
|
||||||
|
index 63ba711e..f8b5b9d6 100644
|
||||||
|
--- a/catfs/repin.go
|
||||||
|
+++ b/catfs/repin.go
|
||||||
|
@@ -247,9 +247,12 @@ func (fs *FS) repin(root string) error {
|
||||||
|
savedStorage := uint64(0)
|
||||||
|
parts := []*partition{}
|
||||||
|
|
||||||
|
+ fs.mu.Unlock()
|
||||||
|
log.Infof("repin started (min=%d max=%d quota=%s)", minDepth, maxDepth, quotaSrc)
|
||||||
|
|
||||||
|
err = n.Walk(fs.lkr, rootNd, true, func(child n.Node) error {
|
||||||
|
+ fs.mu.Lock()
|
||||||
|
+ defer fs.mu.Unlock()
|
||||||
|
if child.Type() == n.NodeTypeDirectory {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@@ -259,6 +262,7 @@ func (fs *FS) repin(root string) error {
|
||||||
|
return e.Wrapf(ie.ErrBadNode, "repin")
|
||||||
|
}
|
||||||
|
|
||||||
|
+ fs.mu.Unlock()
|
||||||
|
part, err := fs.partitionNodeHashes(modChild, minDepth, maxDepth)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
@@ -273,6 +277,7 @@ func (fs *FS) repin(root string) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
+ fs.mu.Lock()
|
||||||
|
|
||||||
|
totalStorage += part.PinSize
|
||||||
|
addedToStorage += pinBytes
|
||||||
|
@@ -286,6 +291,7 @@ func (fs *FS) repin(root string) error {
|
||||||
|
return e.Wrapf(err, "repin: walk")
|
||||||
|
}
|
||||||
|
|
||||||
|
+ fs.mu.Lock()
|
||||||
|
quotaUnpins, err := fs.balanceQuota(parts, totalStorage, quota)
|
||||||
|
if err != nil {
|
||||||
|
return e.Wrapf(err, "repin: quota balance")
|
Loading…
Reference in a new issue