Skip to content

Commit

Permalink
folder_branch_ops: disable edit history prefetching by default
Browse files Browse the repository at this point in the history
Now that we have explicit per-device syncing, we no longer need to
pre-emptively prefetch recent files.
  • Loading branch information
strib committed Apr 24, 2020
1 parent d90401a commit 7b0bbf1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
5 changes: 5 additions & 0 deletions go/kbfs/libkbfs/folder_branch_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,7 @@ func (fbo *folderBranchOps) kickOffPartialSyncIfNeeded(
// using the recently-edited files list, storing the blocks in
// the working set cache.
if !fbo.config.Mode().TLFEditHistoryEnabled() ||
!fbo.config.Mode().EditHistoryPrefetchingEnabled() ||
fbo.config.Mode().DefaultBlockRequestAction() == BlockRequestSolo {
return
}
Expand Down Expand Up @@ -9708,6 +9709,10 @@ func (fbo *folderBranchOps) recomputeEditHistory(
func (fbo *folderBranchOps) kickOffEditActivityPartialSync(
ctx context.Context, lState *kbfssync.LockState,
rmd ImmutableRootMetadata) (err error) {
if !fbo.config.Mode().EditHistoryPrefetchingEnabled() {
return
}

defer func() {
if err != nil {
fbo.log.CDebugf(
Expand Down
3 changes: 3 additions & 0 deletions go/kbfs/libkbfs/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,9 @@ type InitMode interface {
// DiskCacheCompactionEnabled indicates whether the local disk
// block cache should trigger compaction automatically.
DiskCacheCompactionEnabled() bool
// EditHistoryPrefetchingEnabled indicates whether we should
// auto-prefetch the most recently-edited files.
EditHistoryPrefetchingEnabled() bool

ldbutils.DbWriteBufferSizeGetter
}
Expand Down
14 changes: 12 additions & 2 deletions go/kbfs/libkbfs/kbfs_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4929,12 +4929,21 @@ func TestKBFSOpsPartialSync(t *testing.T) {
checkStatus(fNode, NoPrefetch)
}

type modeTestWithPrefetch struct {
modeTest
}

func (mtwp modeTestWithPrefetch) EditHistoryPrefetchingEnabled() bool {
return true
}

func TestKBFSOpsRecentHistorySync(t *testing.T) {
var u1 kbname.NormalizedUsername = "u1"
config, _, ctx, cancel := kbfsOpsConcurInit(t, u1)
defer kbfsConcurTestShutdown(ctx, t, config, cancel)
// kbfsOpsConcurInit turns off notifications, so turn them back on.
config.SetMode(modeTest{NewInitModeFromType(InitDefault)})
config.SetMode(
modeTestWithPrefetch{modeTest{NewInitModeFromType(InitDefault)}})
config.SetVLogLevel(libkb.VLog2String)

name := "u1"
Expand All @@ -4954,7 +4963,8 @@ func TestKBFSOpsRecentHistorySync(t *testing.T) {
// config2 is the writer.
config2 := ConfigAsUser(config, u1)
defer CheckConfigAndShutdown(ctx, t, config2)
config2.SetMode(modeTest{NewInitModeFromType(InitDefault)})
config2.SetMode(
modeTestWithPrefetch{modeTest{NewInitModeFromType(InitDefault)}})
kbfsOps2 := config2.KBFSOps()

config.SetBlockServer(bserverPutToDiskCache{config.BlockServer(), dbc})
Expand Down
8 changes: 8 additions & 0 deletions go/kbfs/libkbfs/modes.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ func (md modeDefault) DiskCacheCompactionEnabled() bool {
return true
}

func (md modeDefault) EditHistoryPrefetchingEnabled() bool {
return false
}

// Minimal mode:

type modeMinimal struct {
Expand Down Expand Up @@ -397,6 +401,10 @@ func (mm modeMinimal) DiskCacheCompactionEnabled() bool {
return false
}

func (mm modeMinimal) EditHistoryPrefetchingEnabled() bool {
return false
}

// Single op mode:

type modeSingleOp struct {
Expand Down

0 comments on commit 7b0bbf1

Please sign in to comment.