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

Commit

Permalink
prefetcher: don't hold block in memory in request
Browse files Browse the repository at this point in the history
All we need it for is to generate a new block, so just keep the
function for making the new block instead.

Issue: #1958
  • Loading branch information
strib committed Dec 20, 2018
1 parent c6096af commit bcc1be9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libkbfs/prefetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type prefetcherConfig interface {

type prefetchRequest struct {
ptr BlockPointer
block Block
newBlock func() Block
kmd KeyMetadata
priority int
lifetime BlockCacheLifetime
Expand Down Expand Up @@ -264,7 +264,7 @@ func (p *blockPrefetcher) completePrefetch(
p.clearRescheduleState(blockID)
delete(p.rescheduled, blockID)
defer pp.Close()
b := pp.req.block.NewEmpty()
b := pp.req.newBlock()
err := <-p.retriever.Request(
pp.ctx, defaultOnDemandRequestPriority, pp.req.kmd, pp.req.ptr,
b, pp.req.lifetime, BlockRequestSolo)
Expand Down Expand Up @@ -360,7 +360,7 @@ func (p *blockPrefetcher) request(ctx context.Context, priority int,
if !isPrefetchWaiting {
// If the block isn't in the tree, we add it with a block count of 1 (a
// later TriggerPrefetch will come in and decrement it).
req := &prefetchRequest{ptr, block, kmd, priority, lifetime,
req := &prefetchRequest{ptr, block.NewEmpty, kmd, priority, lifetime,
NoPrefetch, action, nil}
pre = p.newPrefetch(1, false, req)
p.prefetches[ptr.ID] = pre
Expand Down Expand Up @@ -726,7 +726,7 @@ func (p *blockPrefetcher) run(testSyncCh <-chan struct{}) {
req.ptr, req.action)

// Ensure the block is in the right cache.
b := req.block.NewEmpty()
b := req.newBlock()
err := <-p.retriever.Request(
ctx, defaultOnDemandRequestPriority, req.kmd,
req.ptr, b, req.lifetime, req.action.SoloAction())
Expand Down Expand Up @@ -971,7 +971,7 @@ func (p *blockPrefetcher) ProcessBlockForPrefetch(ctx context.Context,
ptr BlockPointer, block Block, kmd KeyMetadata, priority int,
lifetime BlockCacheLifetime, prefetchStatus PrefetchStatus,
action BlockRequestAction) {
req := &prefetchRequest{ptr, block.NewEmpty(), kmd, priority, lifetime,
req := &prefetchRequest{ptr, block.NewEmpty, kmd, priority, lifetime,
prefetchStatus, action, nil}
if prefetchStatus == FinishedPrefetch {
// Finished prefetches can always be short circuited.
Expand Down

0 comments on commit bcc1be9

Please sign in to comment.