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

Add parallel processing mode #44

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion tools/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func init() {
CheckCmd.AddCommand(checkMergedBlocksCmd)

CheckCmd.PersistentFlags().StringP("range", "r", "", "Block range to use for the check")
CheckCmd.PersistentFlags().IntP("workers", "w", 1, "Number of workers")
CheckCmd.PersistentFlags().IntP("batch", "b", 25000, "batch size")

checkMergedBlocksCmd.Flags().BoolP("print-stats", "s", false, "Natively decode each block in the segment and print statistics about it, ensuring it contains the required blocks")
checkMergedBlocksCmd.Flags().BoolP("print-full", "f", false, "Natively decode each block and print the full JSON representation of the block, should be used with a small range only if you don't want to be overwhelmed")
Expand All @@ -71,7 +73,14 @@ func checkMergedBlocksE(cmd *cobra.Command, args []string) error {
printDetails = sftools.PrintFull
}

return sftools.CheckMergedBlocks(cmd.Context(), zlog, storeURL, fileBlockSize, blockRange, blockPrinter, printDetails)
batchSize := viper.GetInt("batch")
workers := viper.GetInt("workers")

if workers == 1 {
return sftools.CheckMergedBlocks(cmd.Context(), zlog, storeURL, fileBlockSize, blockRange, blockPrinter, printDetails)
} else {
return sftools.CheckMergedBlocksBatch(cmd.Context(), zlog, storeURL, fileBlockSize, blockRange, blockPrinter, printDetails, batchSize, workers)
}
}

func blockPrinter(block *bstream.Block) {
Expand Down