github.com/swiftstack/ProxyFS@v0.0.0-20210203235616-4017c267d62f/evtlog/benchmark_test.go (about)

     1  // Copyright (c) 2015-2021, NVIDIA CORPORATION.
     2  // SPDX-License-Identifier: Apache-2.0
     3  
     4  package evtlog
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/swiftstack/ProxyFS/conf"
    10  	"github.com/swiftstack/ProxyFS/transitions"
    11  )
    12  
    13  var (
    14  	benchmarkConfMap conf.ConfMap
    15  )
    16  
    17  func benchmarkSetup(b *testing.B, enable bool) {
    18  	var (
    19  		benchmarkConfMapStrings []string
    20  		err                     error
    21  	)
    22  
    23  	if enable {
    24  		benchmarkConfMapStrings = []string{
    25  			"Logging.LogFilePath=/dev/null",
    26  			"Logging.TraceLevelLogging=none",
    27  			"Logging.DebugLevelLogging=none",
    28  			"Logging.LogToConsole=false",
    29  			"Cluster.WhoAmI=nobody",
    30  			"FSGlobals.VolumeGroupList=",
    31  			"FSGlobals.CheckpointHeaderConsensusAttempts=5",
    32  			"FSGlobals.MountRetryLimit=6",
    33  			"FSGlobals.MountRetryDelay=1s",
    34  			"FSGlobals.MountRetryExpBackoff=2",
    35  			"FSGlobals.LogCheckpointHeaderPosts=true",
    36  			"FSGlobals.TryLockBackoffMin=10ms",
    37  			"FSGlobals.TryLockBackoffMax=50ms",
    38  			"FSGlobals.TryLockSerializationThreshhold=5",
    39  			"FSGlobals.SymlinkMax=32",
    40  			"FSGlobals.CoalesceElementChunkSize=16",
    41  			"EventLog.Enabled=true",
    42  			"EventLog.BufferKey=1234",
    43  			"EventLog.BufferLength=65536", //64KiB
    44  			"EventLog.MinBackoff=1us",
    45  			"EventLog.MaxBackoff=2us",
    46  		}
    47  	} else {
    48  		benchmarkConfMapStrings = []string{
    49  			"Logging.LogFilePath=/dev/null",
    50  			"Logging.TraceLevelLogging=none",
    51  			"Logging.DebugLevelLogging=none",
    52  			"Logging.LogToConsole=false",
    53  			"Cluster.WhoAmI=nobody",
    54  			"FSGlobals.VolumeGroupList=",
    55  			"FSGlobals.CheckpointHeaderConsensusAttempts=5",
    56  			"FSGlobals.MountRetryLimit=6",
    57  			"FSGlobals.MountRetryDelay=1s",
    58  			"FSGlobals.MountRetryExpBackoff=2",
    59  			"FSGlobals.LogCheckpointHeaderPosts=true",
    60  			"FSGlobals.TryLockBackoffMin=10ms",
    61  			"FSGlobals.TryLockBackoffMax=50ms",
    62  			"FSGlobals.TryLockSerializationThreshhold=5",
    63  			"FSGlobals.SymlinkMax=32",
    64  			"FSGlobals.CoalesceElementChunkSize=16",
    65  			"EventLog.Enabled=false",
    66  		}
    67  	}
    68  
    69  	benchmarkConfMap, err = conf.MakeConfMapFromStrings(benchmarkConfMapStrings)
    70  	if nil != err {
    71  		b.Fatal(err)
    72  	}
    73  
    74  	err = transitions.Up(benchmarkConfMap)
    75  	if nil != err {
    76  		b.Fatal(err)
    77  	}
    78  
    79  	MarkForDeletion()
    80  }
    81  
    82  func benchmarkTeardown(b *testing.B) {
    83  	var (
    84  		err error
    85  	)
    86  
    87  	err = transitions.Down(benchmarkConfMap)
    88  	if nil != err {
    89  		b.Fatal(err)
    90  	}
    91  }
    92  
    93  func Benchmark1KRecordTestPatternFixedWhileDisabled(b *testing.B) {
    94  	benchmarkSetup(b, false)
    95  	b.ResetTimer()
    96  	for i := 0; i < b.N; i++ {
    97  		for j := 0; j < 1000; j++ {
    98  			Record(FormatTestPatternFixed)
    99  		}
   100  	}
   101  	b.StopTimer()
   102  	benchmarkTeardown(b)
   103  }
   104  
   105  func Benchmark1KRecordTestPatternSWhileDisabled(b *testing.B) {
   106  	benchmarkSetup(b, false)
   107  	b.ResetTimer()
   108  	for i := 0; i < b.N; i++ {
   109  		for j := 0; j < 1000; j++ {
   110  			Record(FormatTestPatternS, "arg0")
   111  		}
   112  	}
   113  	b.StopTimer()
   114  	benchmarkTeardown(b)
   115  }
   116  
   117  func Benchmark1KRecordTestPatternS03DWhileDisabled(b *testing.B) {
   118  	benchmarkSetup(b, false)
   119  	b.ResetTimer()
   120  	for i := 0; i < b.N; i++ {
   121  		for j := 0; j < 1000; j++ {
   122  			Record(FormatTestPatternS03D, "arg0", uint32(1))
   123  		}
   124  	}
   125  	b.StopTimer()
   126  	benchmarkTeardown(b)
   127  }
   128  
   129  func Benchmark1KRecordTestPatternS08XWhileDisabled(b *testing.B) {
   130  	benchmarkSetup(b, false)
   131  	b.ResetTimer()
   132  	for i := 0; i < b.N; i++ {
   133  		for j := 0; j < 1000; j++ {
   134  			Record(FormatTestPatternS03D, "arg0", uint32(1))
   135  		}
   136  	}
   137  	b.StopTimer()
   138  	benchmarkTeardown(b)
   139  }
   140  
   141  func Benchmark1KRecordTestPatternS016XWhileDisabled(b *testing.B) {
   142  	benchmarkSetup(b, false)
   143  	b.ResetTimer()
   144  	for i := 0; i < b.N; i++ {
   145  		for j := 0; j < 1000; j++ {
   146  			Record(FormatTestPatternS016X, "arg0", uint64(1))
   147  		}
   148  	}
   149  	b.StopTimer()
   150  	benchmarkTeardown(b)
   151  }
   152  
   153  func Benchmark1KRecordTestPatternS016X016XWhileDisabled(b *testing.B) {
   154  	benchmarkSetup(b, false)
   155  	b.ResetTimer()
   156  	for i := 0; i < b.N; i++ {
   157  		for j := 0; j < 1000; j++ {
   158  			Record(FormatTestPatternS016X016X, "arg0", uint64(1), uint64(2))
   159  		}
   160  	}
   161  	b.StopTimer()
   162  	benchmarkTeardown(b)
   163  }
   164  
   165  func Benchmark1KRecordTestPatternS016XsliceWhileDisabled(b *testing.B) {
   166  	benchmarkSetup(b, false)
   167  	b.ResetTimer()
   168  	for i := 0; i < b.N; i++ {
   169  		for j := 0; j < 1000; j++ {
   170  			Record(FormatTestPatternS016Xslice, "arg0", []uint64{uint64(0x101), uint64(0x102), uint64(0x103)})
   171  		}
   172  	}
   173  	b.StopTimer()
   174  	benchmarkTeardown(b)
   175  }
   176  
   177  func Benchmark1KRecordTestPatternS016XSWhileDisabled(b *testing.B) {
   178  	benchmarkSetup(b, false)
   179  	b.ResetTimer()
   180  	for i := 0; i < b.N; i++ {
   181  		for j := 0; j < 1000; j++ {
   182  			Record(FormatTestPatternS016XS, "arg0", uint64(1), "arg..2")
   183  		}
   184  	}
   185  	b.StopTimer()
   186  	benchmarkTeardown(b)
   187  }
   188  
   189  func Benchmark1KRecordTestPatternSSWhileDisabled(b *testing.B) {
   190  	benchmarkSetup(b, false)
   191  	b.ResetTimer()
   192  	for i := 0; i < b.N; i++ {
   193  		for j := 0; j < 1000; j++ {
   194  			Record(FormatTestPatternSS, "arg0", "arg.1")
   195  		}
   196  	}
   197  	b.StopTimer()
   198  	benchmarkTeardown(b)
   199  }
   200  
   201  func Benchmark1KRecordTestPatternSS03DWhileDisabled(b *testing.B) {
   202  	benchmarkSetup(b, false)
   203  	b.ResetTimer()
   204  	for i := 0; i < b.N; i++ {
   205  		for j := 0; j < 1000; j++ {
   206  			Record(FormatTestPatternSS03D, "arg0", "arg.1", uint32(2))
   207  		}
   208  	}
   209  	b.StopTimer()
   210  	benchmarkTeardown(b)
   211  }
   212  
   213  func Benchmark1KRecordTestPatternSSSWhileDisabled(b *testing.B) {
   214  	benchmarkSetup(b, false)
   215  	b.ResetTimer()
   216  	for i := 0; i < b.N; i++ {
   217  		for j := 0; j < 1000; j++ {
   218  			Record(FormatTestPatternSSS, "arg0", "arg.1", "arg..2")
   219  		}
   220  	}
   221  	b.StopTimer()
   222  	benchmarkTeardown(b)
   223  }
   224  
   225  func Benchmark1KRecordTestPatternSSS03DWhileDisabled(b *testing.B) {
   226  	benchmarkSetup(b, false)
   227  	b.ResetTimer()
   228  	for i := 0; i < b.N; i++ {
   229  		for j := 0; j < 1000; j++ {
   230  			Record(FormatTestPatternSSS03D, "arg0", "arg.1", "arg..2", uint32(3))
   231  		}
   232  	}
   233  	b.StopTimer()
   234  	benchmarkTeardown(b)
   235  }
   236  
   237  func Benchmark1KRecordTestPatternSSS016X03DWhileDisabled(b *testing.B) {
   238  	benchmarkSetup(b, false)
   239  	b.ResetTimer()
   240  	for i := 0; i < b.N; i++ {
   241  		for j := 0; j < 1000; j++ {
   242  			Record(FormatTestPatternSSS016X03D, "arg0", "arg.1", "arg..2", uint64(3), uint32(4))
   243  		}
   244  	}
   245  	b.StopTimer()
   246  	benchmarkTeardown(b)
   247  }
   248  
   249  func Benchmark1KRecordTestPatternFixedWhileEnabled(b *testing.B) {
   250  	benchmarkSetup(b, false)
   251  	b.ResetTimer()
   252  	for i := 0; i < b.N; i++ {
   253  		for j := 0; j < 1000; j++ {
   254  			Record(FormatTestPatternFixed)
   255  		}
   256  	}
   257  	b.StopTimer()
   258  	benchmarkTeardown(b)
   259  }
   260  
   261  func Benchmark1KRecordTestPatternSWhileEnabled(b *testing.B) {
   262  	benchmarkSetup(b, true)
   263  	b.ResetTimer()
   264  	for i := 0; i < b.N; i++ {
   265  		for j := 0; j < 1000; j++ {
   266  			Record(FormatTestPatternS, "arg0")
   267  		}
   268  	}
   269  	b.StopTimer()
   270  	benchmarkTeardown(b)
   271  }
   272  
   273  func Benchmark1KRecordTestPatternS03DWhileEnabled(b *testing.B) {
   274  	benchmarkSetup(b, true)
   275  	b.ResetTimer()
   276  	for i := 0; i < b.N; i++ {
   277  		for j := 0; j < 1000; j++ {
   278  			Record(FormatTestPatternS03D, "arg0", uint32(1))
   279  		}
   280  	}
   281  	b.StopTimer()
   282  	benchmarkTeardown(b)
   283  }
   284  
   285  func Benchmark1KRecordTestPatternS08XWhileEnabled(b *testing.B) {
   286  	benchmarkSetup(b, true)
   287  	b.ResetTimer()
   288  	for i := 0; i < b.N; i++ {
   289  		for j := 0; j < 1000; j++ {
   290  			Record(FormatTestPatternS03D, "arg0", uint32(1))
   291  		}
   292  	}
   293  	b.StopTimer()
   294  	benchmarkTeardown(b)
   295  }
   296  
   297  func Benchmark1KRecordTestPatternS016XWhileEnabled(b *testing.B) {
   298  	benchmarkSetup(b, true)
   299  	b.ResetTimer()
   300  	for i := 0; i < b.N; i++ {
   301  		for j := 0; j < 1000; j++ {
   302  			Record(FormatTestPatternS016X, "arg0", uint64(1))
   303  		}
   304  	}
   305  	b.StopTimer()
   306  	benchmarkTeardown(b)
   307  }
   308  
   309  func Benchmark1KRecordTestPatternS016X016XWhileEnabled(b *testing.B) {
   310  	benchmarkSetup(b, true)
   311  	b.ResetTimer()
   312  	for i := 0; i < b.N; i++ {
   313  		for j := 0; j < 1000; j++ {
   314  			Record(FormatTestPatternS016X016X, "arg0", uint64(1), uint64(2))
   315  		}
   316  	}
   317  	b.StopTimer()
   318  	benchmarkTeardown(b)
   319  }
   320  
   321  func Benchmark1KRecordTestPatternS016XsliceWhileEnabled(b *testing.B) {
   322  	benchmarkSetup(b, true)
   323  	b.ResetTimer()
   324  	for i := 0; i < b.N; i++ {
   325  		for j := 0; j < 1000; j++ {
   326  			Record(FormatTestPatternS016Xslice, "arg0", []uint64{uint64(0x101), uint64(0x102), uint64(0x103)})
   327  		}
   328  	}
   329  	b.StopTimer()
   330  	benchmarkTeardown(b)
   331  }
   332  
   333  func Benchmark1KRecordTestPatternS016XSWhileEnabled(b *testing.B) {
   334  	benchmarkSetup(b, true)
   335  	b.ResetTimer()
   336  	for i := 0; i < b.N; i++ {
   337  		for j := 0; j < 1000; j++ {
   338  			Record(FormatTestPatternS016XS, "arg0", uint64(1), "arg..2")
   339  		}
   340  	}
   341  	b.StopTimer()
   342  	benchmarkTeardown(b)
   343  }
   344  
   345  func Benchmark1KRecordTestPatternSSWhileEnabled(b *testing.B) {
   346  	benchmarkSetup(b, true)
   347  	b.ResetTimer()
   348  	for i := 0; i < b.N; i++ {
   349  		for j := 0; j < 1000; j++ {
   350  			Record(FormatTestPatternSS, "arg0", "arg.1")
   351  		}
   352  	}
   353  	b.StopTimer()
   354  	benchmarkTeardown(b)
   355  }
   356  
   357  func Benchmark1KRecordTestPatternSS03DWhileEnabled(b *testing.B) {
   358  	benchmarkSetup(b, true)
   359  	b.ResetTimer()
   360  	for i := 0; i < b.N; i++ {
   361  		for j := 0; j < 1000; j++ {
   362  			Record(FormatTestPatternSS03D, "arg0", "arg.1", uint32(2))
   363  		}
   364  	}
   365  	b.StopTimer()
   366  	benchmarkTeardown(b)
   367  }
   368  
   369  func Benchmark1KRecordTestPatternSSSWhileEnabled(b *testing.B) {
   370  	benchmarkSetup(b, true)
   371  	b.ResetTimer()
   372  	for i := 0; i < b.N; i++ {
   373  		for j := 0; j < 1000; j++ {
   374  			Record(FormatTestPatternSSS, "arg0", "arg.1", "arg..2")
   375  		}
   376  	}
   377  	b.StopTimer()
   378  	benchmarkTeardown(b)
   379  }
   380  
   381  func Benchmark1KRecordTestPatternSSS03DWhileEnabled(b *testing.B) {
   382  	benchmarkSetup(b, true)
   383  	b.ResetTimer()
   384  	for i := 0; i < b.N; i++ {
   385  		for j := 0; j < 1000; j++ {
   386  			Record(FormatTestPatternSSS03D, "arg0", "arg.1", "arg..2", uint32(3))
   387  		}
   388  	}
   389  	b.StopTimer()
   390  	benchmarkTeardown(b)
   391  }
   392  
   393  func Benchmark1KRecordTestPatternSSS016X03DWhileEnabled(b *testing.B) {
   394  	benchmarkSetup(b, true)
   395  	b.ResetTimer()
   396  	for i := 0; i < b.N; i++ {
   397  		for j := 0; j < 1000; j++ {
   398  			Record(FormatTestPatternSSS016X03D, "arg0", "arg.1", "arg..2", uint64(3), uint32(4))
   399  		}
   400  	}
   401  	b.StopTimer()
   402  	benchmarkTeardown(b)
   403  }