Changeset - 0b67ddd4455a
[Not reviewed]
default
0 4 0
Laman - 7 years ago 2018-01-22 01:04:39

split batchSize parameter
4 files changed with 15 insertions and 8 deletions:
0 comments (0 inline, 0 general)
config-example.json
Show inline comments
 
{
 
	"hosts": ["127.0.0.1"],
 
	"port": 9901,
 
	"batchSize": 64
 
	"batchSize": {
 
		"hash": 256,
 
		"data": 64
 
	}
 
}
src/client.py
Show inline comments
 
@@ -74,7 +74,7 @@ class Client(NetNode):
 
		progress=Progress(localTree.leafCount)
 
		while len(nodeStack)>0:
 
			indices=[]
 
			for i in range(conf.batchSize):
 
			for i in range(conf.batchSize.hash):
 
				indices.append(nodeStack.pop())
 
				if len(nodeStack)==0: break
 
			self._outcoming.writeMsg({"command":"req", "index":indices, "dataType":"hash"})
 
@@ -111,10 +111,10 @@ class Client(NetNode):
 
		print(datetime.now(), "sending data:")
 
		progress=Progress(len(blocksToTransfer))
 

	
 
		for k in range(0,len(blocksToTransfer),conf.batchSize):
 
		for k in range(0,len(blocksToTransfer),conf.batchSize.data):
 
			indices=[]
 
			blocks=[]
 
			for j in range(conf.batchSize):
 
			for j in range(conf.batchSize.data):
 
				if k+j>=len(blocksToTransfer): break
 
				i2=blocksToTransfer[k+j]
 
				if i1+1!=i2:
 
@@ -148,8 +148,8 @@ class Client(NetNode):
 
		print(datetime.now(), "receiving data:")
 
		progress=Progress(len(blocksToTransfer))
 

	
 
		for k in range(0,len(blocksToTransfer),conf.batchSize):
 
			indices=blocksToTransfer[k:k+conf.batchSize]
 
		for k in range(0,len(blocksToTransfer),conf.batchSize.data):
 
			indices=blocksToTransfer[k:k+conf.batchSize.data]
 
			self._outcoming.writeMsg({"command":"req", "index":indices, "dataType":"data"})
 
			jsonData,binData=self._incoming.readMsg()
 
			assert jsonData["command"]=="send" and jsonData["index"]==indices and jsonData["dataType"]=="data", jsonData
src/config.py
Show inline comments
 
@@ -27,4 +27,7 @@ lowestCompatible=[0,1,0] # tuple is more
 
hosts=conf.get("hosts",["127.0.0.1"])
 
port=conf.get("port",9901)
 

	
 
batchSize=conf.get("batchSize",64)
 
bSize=conf.get("batchSize",dict())
 
class batchSize:
 
	hash=bSize.get("hash",256)
 
	data=bSize.get("data",64)
src/tests/test_overall.py
Show inline comments
 
@@ -17,7 +17,8 @@ handler=FileHandler("/tmp/morevna.log")
 
handler.setFormatter(config.formatter)
 
config.logger.addHandler(handler)
 

	
 
config.batchSize=8
 
config.batchSize.hash=8
 
config.batchSize.data=8
 

	
 
dataDir=os.path.join(config.directory,"src/tests/data")
 
filename=os.path.join(dataDir,"test.img")
0 comments (0 inline, 0 general)