Skip to content
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

LMDB storage #16274

Merged
merged 14 commits into from
Nov 18, 2024
Merged

LMDB storage #16274

merged 14 commits into from
Nov 18, 2024

Conversation

dkijania
Copy link
Member

Cherry picked @georgeee commits regarding src/lib/lmdb_storage project.

@dkijania dkijania changed the base branch from develop to compatible October 22, 2024 19:35
@dkijania
Copy link
Member Author

!ci-build-me

(* increase to 1000000 to reach past mmap size of 256 MiB*)
Base_quickcheck.quickcheck_generator_char ) ~trials:n
~f:(fun _ ->
let body = Breadcrumb.block breadcrumb |> Mina_block.body in
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used already created breadcrumb instead of generated string, is there any way to convert string to ~body ?

@dkijania dkijania marked this pull request as ready for review October 22, 2024 22:06
@dkijania dkijania requested a review from a team as a code owner October 22, 2024 22:06
georgeee and others added 3 commits November 11, 2024 12:07
…1ae44c067984cdcb20c4274278ced9c2b418""

This reverts commit 10a63d13640e909b02875b10a6504a9bab29e4ef.
Revert "Auxiliary commit to revert individual files from 9fb91ae44c067984cdcb20c4274278ced9c2b418"

This reverts commit 2038250076ccd685aaaeb17bc691c551d5b5a9d4.
Add generic implementation of LMDB storage
This reverts commit 90c88b38dd997fa22ecbfe93523f175276e5f01e.
@dkijania dkijania force-pushed the dkijania/cache_keys_with_lmdb branch from a779250 to 053a80e Compare November 11, 2024 11:07
@dkijania
Copy link
Member Author

!ci-build-me

@dkijania
Copy link
Member Author

!ci-build-me

Copy link
Member

@georgeee georgeee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a Revert changes to block.ml commit to the branch.

It breaks compilation to be sure, but I insist on using that version. We need to update interface of send_add_resource and move Bitsawp_tag module to Mina_net2 (from Staged_ledger_diff).

For a moment I considered whether we want block.ml and header.ml right in this PR. And maybe the answer is "no", but I still think it's ok to have them for purpose of introducing some tests that were written for block.ml (and both files are needed for bitswap work, so they are likely to be cherry-picked soon).

@dkijania
Copy link
Member Author

!ci-build-me

@@ -0,0 +1,43 @@
open Core_kernel

let uint32_be =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is how int32_be defined in

let int32_be =
    { flags =
        if Sys.big_endian && is_int_size 4
        then Flags.(integer_key + integer_dup + dup_fixed)
        else Flags.(dup_fixed)
    ; serialise = begin fun alloc x ->
        let a = alloc 4 in
        Bigstring.set_int32_be a 0 x;
        a
      end
    ; deserialise = begin fun a ->
        Bigstring.get_int32_be a 0
      end
    }

Notice the difference in flags. Specification of LMDB prescribes a certain pattern of usage for the flags: http://www.lmdb.tech/doc/group__mdb.html.

It seems like the check for Sys.big_endian && is_int_size 4 might actually be needed to ensure the code behaves well under all circumstances.

src/lib/lmdb_storage/conv.ml Outdated Show resolved Hide resolved
src/lib/lmdb_storage/conv.ml Outdated Show resolved Hide resolved
src/lib/lmdb_storage/conv.ml Outdated Show resolved Hide resolved
network_peer
pipe_lib
timeout_lib
mina_metrics
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these dependencies are redundant to be sure

@dkijania
Copy link
Member Author

!ci-build-me

@dkijania dkijania requested a review from georgeee November 15, 2024 18:49
Lmdb.Conv.make
~flags:
Lmdb.Conv.Flags.(
if Sys.big_endian && Int.equal Sys.int_size 4 then
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@georgeee I used Sys.int_size instead of is_int_size, since i cannot find it anywhere. I'm not sure if the 4 is right here. Sys.int_size is measuring int size in bits (so it will be 63 on majority of os). Is is_int_size expressed in bits too ? in that case 4 looks very suspicious

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought a bit. It's unlikely that integer will be 4 bytes on any modern server. So let's just drop the edge case and have ~flags:Lmdb.Conv.Flags.dup_fixed

@dkijania
Copy link
Member Author

!ci-build-me

@dkijania
Copy link
Member Author

!ci-build-me

@dkijania dkijania merged commit 0e83ede into compatible Nov 18, 2024
45 checks passed
@dkijania dkijania deleted the dkijania/cache_keys_with_lmdb branch November 18, 2024 17:37
@dkijania dkijania mentioned this pull request Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants