-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14897 from MinaProtocol/merge-back-to-rampup-2024…
…-01-17 Merge back to rampup
- Loading branch information
Showing
10 changed files
with
607 additions
and
152 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ $# -lt 1 ]]; then | ||
echo "Usage: $0 precomputed-log-file [output-folder]" | ||
exit 1 | ||
fi | ||
|
||
|
||
|
||
ARCHIVE_URI=${ARCHIVE_URI:-postgres://postgres@localhost:5432/archive} | ||
PRECOMPUTED_LOG_FILE=$1 | ||
|
||
while IFS= read -r line; do | ||
LEDGER_HASH=$(echo $line | jq -r '.protocol_state.body.blockchain_state.staged_ledger_hash.non_snark.ledger_hash') | ||
FILE_NAME=$(psql $ARCHIVE_URI -t -c "SELECT 'mainnet-' || height || '-' ||state_hash || '.json' FROM blocks WHERE ledger_hash = '$LEDGER_HASH'") | ||
echo $line > $FILE_NAME | ||
done < $PRECOMPUTED_LOG_FILE | ||
|
||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Ledger export benckmark | ||
======================= | ||
|
||
This package provides a couple of simple benchmarks for the most | ||
resource-consuming parts of the ledger export process, namely: | ||
* serialising and de-serialising a large runtime config; | ||
* converting accounts between runtime config format and ledger format. | ||
|
||
These benchmarks depend on a sufficiently large runtime config file | ||
supplied from outside, because creating one within a benchmark, | ||
while useful, is too involved, as it basically requires connecting | ||
to a live network. Besides, such a benchmark would be unreliable, | ||
as its results wouldn't be reproducible. | ||
|
||
Sadly, a runtime config containing realistic mainnet data is too | ||
large to store it in git (~400MB), so users of the benchmark need to | ||
provide it themselves. The file's path should be given by environment | ||
variable `RUNTIME_CONFIG` provide to the benchmark process. If that | ||
variable is absent, the benchmark will not work. | ||
|
||
In order to run the benchmark, type: | ||
|
||
$ RUNTIME_CONFIG=$HOME/mainnet.json dune exec src/app/ledger_export_bench/ledger_export_benchmark.exe |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(executable | ||
(name ledger_export_benchmark) | ||
(libraries | ||
base | ||
core | ||
core_bench | ||
core_kernel | ||
yojson | ||
; mina libraries | ||
runtime_config) | ||
; the -w list here should be the same as in src/dune | ||
(flags -short-paths -g -w @a-4-29-40-41-42-44-45-48-58-59-60) | ||
(instrumentation (backend bisect_ppx)) | ||
(preprocess (pps ppx_version ppx_jane)) | ||
(modes native)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
open Core | ||
open Core_bench | ||
|
||
let load_daemon_cfg filename () = | ||
let json = Yojson.Safe.from_file filename in | ||
match Runtime_config.of_yojson json with | ||
| Ok cfg -> | ||
cfg | ||
| Error err -> | ||
raise (Failure err) | ||
|
||
let serialize cfg () = Runtime_config.to_yojson cfg |> Yojson.Safe.to_string | ||
|
||
let convert accounts () = | ||
Runtime_config.(map_results ~f:Accounts.Single.of_account accounts) | ||
|
||
let () = | ||
let runtime_config = Sys.getenv_exn "RUNTIME_CONFIG" in | ||
let cfg = load_daemon_cfg runtime_config () in | ||
let accounts = | ||
match cfg.ledger with | ||
| None | Some { base = Named _; _ } | Some { base = Hash _; _ } -> | ||
[] | ||
| Some { base = Accounts accs; _ } -> | ||
List.map ~f:Runtime_config.Accounts.Single.to_account accs | ||
in | ||
Command.run | ||
(Bench.make_command | ||
[ Bench.Test.create ~name:"parse_runtime_config" | ||
(load_daemon_cfg runtime_config) | ||
; Bench.Test.create ~name:"serialize_runtime_config" (serialize cfg) | ||
; Bench.Test.create ~name:"convert_accounts_for_config" | ||
(convert accounts) | ||
] ) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ | |
graphql_lib | ||
block_time | ||
currency | ||
merkle_ledger | ||
mina_lib | ||
mina_commands | ||
mina_state | ||
|
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
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
Oops, something went wrong.