Adding a bitset implementation to manage usage of disk space#12
Adding a bitset implementation to manage usage of disk space#12sooraj-srini wants to merge 17 commits intotarides:masterfrom
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.
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.
Can you expand on the reserved 4 bytes? (which sector id is that?)
src/queue.ml
Outdated
| | 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.
(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.
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.
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
| 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.
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.