Skip to content

Commit

Permalink
Moved hard coded settings to config
Browse files Browse the repository at this point in the history
  • Loading branch information
allada committed Jan 19, 2021
1 parent 99d170c commit 0f7b2d0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
3 changes: 0 additions & 3 deletions cas/grpc_service/ac_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ impl AcServer {
let action_result = ActionResult::decode(Cursor::new(&store_data))
.err_tip_with_code(|e| (Code::NotFound, format!("Stored value appears to be corrupt: {}", e)))?;

// if store_data.len() != digest.size_bytes as usize {
// return Err(make_err!(Code::NotFound, "Found item, but size does not match"));
// }
Ok(Response::new(action_result))
}

Expand Down
9 changes: 3 additions & 6 deletions cas/grpc_service/bytestream_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,9 @@ impl ByteStreamServer {
// TODO(allada) We don't yet support instance_name.
return Ok(ByteStreamServer {
store: store.clone(),
// TODO(allada) Make this configurable.
// This value was choosen only because it is a common mem page size.
write_buffer_stream_size: 2 << 20, // 2Mb.
read_buffer_stream_size: 2 << 20, // 2Mb.
// According to https://github.com/grpc/grpc.github.io/issues/371 16KiB - 64KiB is optimal.
max_bytes_per_stream: 2 << 15, // 64Kb.
write_buffer_stream_size: bytestream_cfg.write_buffer_stream_size,
read_buffer_stream_size: bytestream_cfg.read_buffer_stream_size,
max_bytes_per_stream: bytestream_cfg.max_bytes_per_stream,
});
}
Err(make_input_err!("No configuration configured for 'cas' service"))
Expand Down
3 changes: 3 additions & 0 deletions cas/grpc_service/tests/bytestream_server_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ fn make_bytestream_server(store_manager: &mut StoreManager) -> Result<ByteStream
&hashmap! {
"main".to_string() => config::cas_server::ByteStreamConfig{
cas_store: "main_cas".to_string(),
max_bytes_per_stream: 1024,
read_buffer_stream_size: 1024,
write_buffer_stream_size: 1024,
}
},
&store_manager,
Expand Down
12 changes: 10 additions & 2 deletions config/cas_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ pub struct CasStoreConfig {
}

#[derive(Deserialize, Debug)]
pub struct CapabilitiesConfig {
}
pub struct CapabilitiesConfig {}

#[derive(Deserialize, Debug)]
pub struct ExecutionConfig {
Expand All @@ -44,6 +43,15 @@ pub struct ExecutionConfig {
pub struct ByteStreamConfig {
/// Name of the store in the "stores" configuration.
pub cas_store: StoreRefName,

// Buffer size for transferring data between grpc endpoint and store.
pub write_buffer_stream_size: usize,

// Buffer size for transferring data between store and grpc endpoint.
pub read_buffer_stream_size: usize,

// Max number of bytes to send on each grpc stream chunk.
pub max_bytes_per_stream: usize,
}

#[derive(Deserialize, Debug)]
Expand Down
7 changes: 6 additions & 1 deletion config/examples/basic_cas.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
"execution": {},
"bytestream": {
"main": {
"cas_store": "CAS_MAIN_STORE"
"cas_store": "CAS_MAIN_STORE",
// This value was choosen only because it is a common mem page size.
"write_buffer_stream_size": 2e6, // 2mb.
"read_buffer_stream_size": 2e6, // 2mb.
// According to https://github.com/grpc/grpc.github.io/issues/371 16KiB - 64KiB is optimal.
"max_bytes_per_stream": 64000, // 64kb.
}
}
}
Expand Down

0 comments on commit 0f7b2d0

Please sign in to comment.