-
Notifications
You must be signed in to change notification settings - Fork 3
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
Adding a bitset implementation to manage usage of disk space #12
base: master
Are you sure you want to change the base?
Conversation
src/bitset.ml
Outdated
let get_ptr_size () = | ||
let pointer_size = Sector.ptr_size in | ||
let id_size = Sector.id_size in | ||
((pointer_size + id_size) / 8) + 8 |
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.
This looks complicated! (and I'm afraid it'll break with different disk sizes) Any reasons why Sector.ptr_size
isn't enough? :)
src/bitset.ml
Outdated
|
||
let get_nb_children page_size = | ||
let incr = get_ptr_size () in | ||
(page_size - 4) / incr (* 4 bytes for the sector id*) |
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.
Can you expand on the reserved 4 bytes? (which sector id is that?)
src/queue.ml
Outdated
match B.acquire_discarded () with | ||
| [] -> Lwt_result.return (t, quantity) | ||
| lst -> | ||
let* t = push_back_list t lst in | ||
push_discarded ~quantity:(quantity + List.length lst) t | ||
let* () = free lst in |
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.
(leaving a note to remember that we need the bitset and the queue to be disjoint in the future)
src/root.ml
Outdated
else Lwt_result.return queue | ||
in | ||
let* queue = | ||
let* queue = Queue.push_back queue [ B.Id.of_int (Int64.to_int B.nb_sectors + 1), 1 ] in |
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.
Nice! If you are looking for other constants to delimit the generations, I believe there are other impossible values that could be used as a separator to make it super obvious that this is not a valid element of the queue (... eg with a sector id in the reserved root area and/or a weird range length)
else | ||
let* () = Bitset.free_range q.bitset range in | ||
pop queue | ||
in |
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.
Yes this works! If you have time, we shouldn't need pop_front
to pop a specific quantity anymore so it should be possible to specialize it for "pop until the generation separator is encountered" :)
src/root.ml
Outdated
else Lwt_result.return queue | ||
in | ||
let* queue = | ||
let* queue = Queue.push_back queue [ B.Id.of_int (Int64.to_int B.nb_sectors + 1), 1 ] in | ||
let* queue = Queue.push_back queue [ previous_generation, 1 ] in |
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.
The two push_back
could be done in one call :)
We use a bitset to manage the free space within the disk. The bitset uses 1 bit per sector to represent a sector is free or being used. Currently, the bitset manipulates only a single bit at a time but eventually it is expected to handle contiguous bits at a time. The bitset should work for up till
O(nb of bits in a sector ^ 2)
number of sectors but is still under testing.