Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

chunk, storage: chunk.Store multiple chunk Put #1681

Merged
merged 3 commits into from
Aug 22, 2019
Merged

Conversation

janos
Copy link
Member

@janos janos commented Aug 20, 2019

This PR adds support for multiple chunks to be Put by localstore. This is a performance improvement by using one leveldb batch for multiple chunks, instead to have a separate batch for every chunk.

All localstore Put tests are changed to validate functionality with multiple chunks.

This PR addresses only the Put method for easier review. If this approach is approved, other methods will be changed in a similar way. This change is targeted for master, but new stream package should use it. This way the diff on new stream PR should not get even larger.

@janos janos requested review from zelig and acud August 20, 2019 14:56
@janos janos self-assigned this Aug 20, 2019
Copy link
Member

@zelig zelig left a comment

Choose a reason for hiding this comment

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

log.Trace("netstore.put slow chunk delivery", "ref", ch.Address().String())
}
for _, ch := range chs {
// notify RemoteGet (or SwarmSyncerClient) about a chunk delivery and it being stored
Copy link
Member

Choose a reason for hiding this comment

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

shall we just use the exist bool array?

for i, ch := range chs {
   if exist[i] {
      continue
   }
   fi, ok := n.fetchers.Get(ch.Address().String())
   if !ok { panic("fetcher should exist") }

}

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a nice proposal, but I am not sure if we should change the netstore so much in this PR. I have just added multi chunks while preserving the same individual chunk logic as before. Can we address this later or maybe in new stream package?

return exists, gcSizeChange, nil
}

// putRequest adds an Item to the batch by updating required indexes:
Copy link
Member

Choose a reason for hiding this comment

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

wrong func name in comment

return false, nil
}

// putRequest adds an Item to the batch by updating required indexes:
Copy link
Member

Choose a reason for hiding this comment

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

wrong func name in comment

storage/localstore/mode_put.go Show resolved Hide resolved
@janos
Copy link
Member Author

janos commented Aug 21, 2019

Thank, @zelig. Yes, the next would be to do the same thing for Set method. Also it can be beneficial for Get and Has as every get or has on leveldb creates a new snapshot and getting multiple chunks from the same snapshot may be better.

I think that this PR is not ready to be merged until duplicate chunks scenario in Put arguments is handled properly.

@janos janos requested a review from zelig August 21, 2019 12:57
Copy link
Member

@zelig zelig left a comment

Choose a reason for hiding this comment

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

LGTM

@janos janos merged commit 5e982b6 into master Aug 22, 2019
@janos janos deleted the localstore-multi-put branch August 22, 2019 08:24
@skylenet skylenet added this to the 0.5.0 milestone Aug 23, 2019
@zelig zelig mentioned this pull request Aug 27, 2019
26 tasks
chadsr added a commit to chadsr/swarm that referenced this pull request Sep 23, 2019
* 'master' of github.com:ethersphere/swarm:
  chunk, storage: chunk.Store multiple chunk Put (ethersphere#1681)
  storage: fix pyramid chunker and hasherstore possible deadlocks (ethersphere#1679)
  pss: Use distance to determine single guaranteed recipient (ethersphere#1672)
  storage: fix possible hasherstore deadlock on waitC channel (ethersphere#1674)
  network: Add adaptive capabilities message (ethersphere#1619)
  p2p/protocols, p2p/testing; conditional propagation of context (ethersphere#1648)
  api/http: remove unnecessary conversion (ethersphere#1673)
  storage: fix LazyChunkReader.join potential deadlock (ethersphere#1670)
  HTTP API support for pinning contents (ethersphere#1658)
  pot: Add Distance methods with tests (ethersphere#1621)
  README.md: Update Vendored Dependencies section (ethersphere#1667)
  network, p2p, vendor: move vendored p2p/testing under swarm (ethersphere#1647)
  build, vendor: use go modules for vendoring (ethersphere#1532)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants