github.com/petermattis/pebble@v0.0.0-20190905164901-ab51a2166067/cmd/pebble/main.go (about) 1 // Copyright 2018 The LevelDB-Go and Pebble Authors. All rights reserved. Use 2 // of this source code is governed by a BSD-style license that can be found in 3 // the LICENSE file. 4 5 package main 6 7 import ( 8 "log" 9 "os" 10 "time" 11 12 "github.com/petermattis/pebble/internal/base" 13 "github.com/petermattis/pebble/tool" 14 "github.com/spf13/cobra" 15 ) 16 17 var ( 18 cacheSize int64 19 concurrency int 20 disableWAL bool 21 duration time.Duration 22 maxOpsPerSec string 23 rocksdb bool 24 verbose bool 25 waitCompactions bool 26 wipe bool 27 ) 28 29 func main() { 30 log.SetFlags(0) 31 32 cobra.EnableCommandSorting = false 33 34 benchCmd := &cobra.Command{ 35 Use: "bench", 36 Short: "benchmarks", 37 } 38 benchCmd.AddCommand( 39 scanCmd, 40 syncCmd, 41 ycsbCmd, 42 ) 43 44 rootCmd := &cobra.Command{ 45 Use: "pebble [command] (flags)", 46 Short: "pebble benchmarking/introspection tool", 47 } 48 rootCmd.AddCommand(benchCmd) 49 50 t := tool.New() 51 t.RegisterComparer(mvccComparer) 52 t.RegisterMerger(func() *base.Merger { 53 // TODO(peter): This isn't the actual cockroach_merge_operator, but a 54 // placeholder so we can examine cockroach generated sstables. 55 var m base.Merger 56 m = *base.DefaultMerger 57 m.Name = "cockroach_merge_operator" 58 return &m 59 }()) 60 rootCmd.AddCommand(t.Commands...) 61 62 for _, cmd := range []*cobra.Command{scanCmd, syncCmd, ycsbCmd} { 63 cmd.Flags().Int64Var( 64 &cacheSize, "cache", 1<<30, "cache size") 65 cmd.Flags().IntVarP( 66 &concurrency, "concurrency", "c", 1, "number of concurrent workers") 67 cmd.Flags().BoolVar( 68 &disableWAL, "disable-wal", false, "disable the WAL (voiding persistence guarantees)") 69 cmd.Flags().DurationVarP( 70 &duration, "duration", "d", 10*time.Second, "the duration to run (0, run forever)") 71 cmd.Flags().StringVarP( 72 &maxOpsPerSec, "rate", "m", "1000000", "max ops per second [{zipf,uniform}:]min[-max][/period (sec)]") 73 cmd.Flags().BoolVar( 74 &rocksdb, "rocksdb", false, 75 "use rocksdb storage engine instead of pebble") 76 cmd.Flags().BoolVarP( 77 &verbose, "verbose", "v", false, "enable verbose event logging") 78 cmd.Flags().BoolVar( 79 &waitCompactions, "wait-compactions", false, 80 "wait for background compactions to complete after load stops") 81 cmd.Flags().BoolVarP( 82 &wipe, "wipe", "w", false, "wipe the database before starting") 83 } 84 85 if err := rootCmd.Execute(); err != nil { 86 // Cobra has already printed the error message. 87 os.Exit(1) 88 } 89 }