-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: introduce tokio #7
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We cannot have multiple mutable references to the same data for both set/remove functions, this requires a change from BTreeMap to the concurrent DashMap (or crossbeam alternative) as the insert/remove functions here do not take &mut self and therefore do not force the implementation to be mutable either
The timestamps were being set incorrectly because they were always being generated from now(), which meant that the timestamp for the keydir was always later than the entry into the WAL. During comparison this made it so that the items were never compacted
This requires some extra thinking. I believe we can remove the RwLock around the structures which are already wrapped in one to avoid extra verbosity/unnecessary locking all over the place. We need to consider how the file lock is handled across threads. Pushing to have this remotely
This was part of the name before, but it makes more sense to be the file extension
Compaction was broken because the opened file was never seeked to the offset, it was simply reading key0 every single time in the log file
By taking the positional offset to write at within the appending func, this fixes the concurrent_set function. Previously, we were writing to the same offset multiple times which caused get() to return the incorrect data. NOTE: There is still a requirement to fix a memory allocation problem. The program crashes when `cargo test` is ran altogether.
Prior to this, the bufwriter wasn't actually doing anything because flush was called after every single write, which meant that the syscall was also done. Now, the writes go into the buffer first and are then flushed at the end of the iteration
I'm removing these because it has already been done in the Rust book so I'm not wanting to rehash over it again. I'll utilise the rayon threadpool for speed and move on to the next task
Build the keydir from log files on disk. Prior to this we were serializing the entire keydir on `Drop` which was a major bottleneck. Instead we can rebuild the directory by reading from log files. If we're serializing and loading an entire key directory on disk then the WAL doesn't entirely serve a purpose since it is unused, we simply have a k-v store already on disk which we continually (de)serialize every single time we need too. With this new WIP implementation, the idea is that we should be able to crash in the middle of operations and then rebuild the index from log files that were persisted.
Enables ease of setting logging level for tests and server usage
Continue to modify this for sending/reading the size of the data before it is serialized, that way we can use read_exact etc.
By writing a u64 size hint for the incoming data, we can now use `read_exact` for the serialisation and fully implement an async server.
Commented the concurrent tests temporarily
jdockerty
force-pushed
the
feat/async-tokio
branch
from
March 27, 2024 22:33
64f7a40
to
9b5e70d
Compare
jdockerty
force-pushed
the
feat/async-tokio
branch
from
March 27, 2024 22:35
9b5e70d
to
203c1bc
Compare
Prior to this, we were inserting every single element into the keydir from scratch which meant that every item in every log file was placed into the index, we don't need to do this. Instead, we should only modify the entry if it exists and the timestamp of the log entry is greater than the one we already have, i.e. it is more up to date.
jdockerty
force-pushed
the
feat/async-tokio
branch
from
March 28, 2024 13:28
ba0718d
to
cdc3fa0
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Large conversion to utilising
tokio
and asynchronous Rust in the project.This is loosely based on the project-5 specification for the talent plan course, but it is very incomplete with minimal information so I've largely gone about this myself instead and put together what I think works.
Also includes a rename of the project from
kvs
tosqrl
(squirrel), since I'm now very much off of the beaten path and making this my own.