-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce file system and implement streaming encoding #91
Conversation
@tabokie Please fill the description, it is not friendly for others want to know more about this PR with no full description. |
self.buf.encode_u64(0)?; | ||
self.buf.encode_u64(0)?; | ||
} else if self.buf_state != BufState::EntriesFilled { | ||
// return error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIXME
enum BufState { | ||
Uninitialized, | ||
EntriesFilled, | ||
Sealed(usize), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting the meaning for this counter.
ftruncate(self.0, offset as i64).map_err(|e| from_nix_error(e, "ftruncate")) | ||
} | ||
|
||
pub fn allocate(&self, offset: usize, size: usize) -> IoResult<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test that an allocated file reads out 0.
Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
1. Append compressed entries to log batch buffer instead of replacing the buffer. 2. Avoid allocate twice when creating `protobuf::Message` from decompressed slice 3. Use entry reference for log batch append Bench results: ``` Patched: test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench: 136,299 ns/iter (+/- 44,912) test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench: 131,405 ns/iter (+/- 82,630) Master: test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench: 199,314 ns/iter (+/- 95,954) test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench: 197,948 ns/iter (+/- 16,842) Without streaming encoding (#91): test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench: 407,738 ns/iter (+/- 142,417) test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench: 411,079 ns/iter (+/- 111,409) ``` Signed-off-by: tabokie <xy.tao@outlook.com>
Replace file system (#91) with an Allocator-like type `FileBuilder`. File builder is better, it's strongly typed with our own file writer/reader, so that 1) we don't need to propagate `Send` and `Sync` trait bound outside of this library, 2) user writers or readers are promised to use our writer/reader as a backend. There still are some reasonable requirements on user types, such as no buffering and no length altering, which are documented in trait definition. Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie xy.tao@outlook.com
This PR rearranges internal data access around a standard reader/writer. This way external IO logic can be embedded through the new interface
FileSystem
, which allows for building wrapper around said reader/writer.This interface is not ideal as it doesn't ensure implementation to actually leverage the raw IO object. More work needs to be done to factor out code dependence on
LogFd
and severFileSystem
as a standalone abstraction.This PR also implements streaming encoding.
LogBatch
now encodes user data immediately instead of keeping a copy and encode before actual writing.Stress results: