mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
Add performance test capability in C with scaling.
Scaling allows the starting values to be increased from the command-line without code changes. Also suppress valgrind and assertions when running performance testing. Optimization is left at -O0 because we should not be depending on compiler optimizations to make our code performant, and it makes profiling more informative.
This commit is contained in:
parent
004ff99a2d
commit
f1ba428fb0
@ -59,6 +59,8 @@ use constant TESTDEF_INDIVIDUAL => 'individu
|
||||
push @EXPORT, qw(TESTDEF_INDIVIDUAL);
|
||||
use constant TESTDEF_TOTAL => 'total';
|
||||
push @EXPORT, qw(TESTDEF_TOTAL);
|
||||
use constant TESTDEF_TYPE => 'type';
|
||||
push @EXPORT, qw(TESTDEF_TYPE);
|
||||
use constant TESTDEF_PERL_REQ => 'perlReq';
|
||||
push @EXPORT, qw(TESTDEF_PERL_REQ);
|
||||
use constant TESTDEF_VM => 'vm';
|
||||
@ -137,6 +139,7 @@ sub testDefLoad
|
||||
}
|
||||
|
||||
# Set module type variables
|
||||
$hTestDefHash->{$strModule}{$strTest}{&TESTDEF_TYPE} = $strModuleType;
|
||||
$hTestDefHash->{$strModule}{$strTest}{&TESTDEF_C} =
|
||||
$strModuleType ne TESTDEF_INTEGRATION && $strTest !~ /perl$/ ? true : false;
|
||||
$hTestDefHash->{$strModule}{$strTest}{&TESTDEF_INTEGRATION} = $strModuleType eq TESTDEF_INTEGRATION ? true : false;
|
||||
|
@ -75,6 +75,7 @@ sub new
|
||||
$self->{bOptimize},
|
||||
$self->{bBackTrace},
|
||||
$self->{bProfile},
|
||||
$self->{iScale},
|
||||
$self->{bDebug},
|
||||
$self->{bDebugTestTrace},
|
||||
$self->{iBuildMax},
|
||||
@ -105,6 +106,7 @@ sub new
|
||||
{name => 'bOptimize'},
|
||||
{name => 'bBackTrace'},
|
||||
{name => 'bProfile'},
|
||||
{name => 'iScale'},
|
||||
{name => 'bDebug'},
|
||||
{name => 'bDebugTestTrace'},
|
||||
{name => 'iBuildMax'},
|
||||
@ -254,7 +256,8 @@ sub run
|
||||
'docker exec -i -u ' . TEST_USER . " ${strImage} bash -l -c '" .
|
||||
"cd $self->{strGCovPath} && " .
|
||||
"make -j $self->{iBuildMax} -s 2>&1 &&" .
|
||||
($self->{oTest}->{&TEST_VM} ne VM_CO6 && $self->{bValgrindUnit}?
|
||||
($self->{oTest}->{&TEST_VM} ne VM_CO6 && $self->{bValgrindUnit} &&
|
||||
$self->{oTest}->{&TEST_TYPE} ne TESTDEF_PERFORMANCE ?
|
||||
" valgrind -q --gen-suppressions=all --suppressions=$self->{strGCovPath}/test/valgrind.suppress" .
|
||||
" --leak-check=full --leak-resolution=high --error-exitcode=25" : '') .
|
||||
" ./test.bin 2>&1'";
|
||||
@ -344,7 +347,16 @@ sub run
|
||||
|
||||
# Update C test file with test module
|
||||
my $strTestC = ${$self->{oStorageTest}->get("$self->{strGCovPath}/test/test.c")};
|
||||
|
||||
if (defined($strCInclude))
|
||||
{
|
||||
$strTestC =~ s/\{\[C\_INCLUDE\]\}/$strCInclude/g;
|
||||
}
|
||||
else
|
||||
{
|
||||
$strTestC =~ s/\{\[C\_INCLUDE\]\}//g;
|
||||
}
|
||||
|
||||
$strTestC =~ s/\{\[C\_TEST\_INCLUDE\]\}/\#include \"$strTestFile\"/g;
|
||||
$strTestDepend .= " ${strTestFile}";
|
||||
|
||||
@ -364,6 +376,7 @@ sub run
|
||||
$strTestC =~ s/\{\[C\_TEST\_PATH\]\}/$strVmTestPath/g;
|
||||
$strTestC =~ s/\{\[C\_TEST\_EXPECT_PATH\]\}/$self->{strExpectPath}/g;
|
||||
$strTestC =~ s/\{\[C\_TEST\_REPO_PATH\]\}/$self->{strBackRestBase}/g;
|
||||
$strTestC =~ s/\{\[C\_TEST\_SCALE\]\}/$self->{iScale}/g;
|
||||
|
||||
# Set default log level
|
||||
my $strLogLevelTestC = "logLevel" . ucfirst($self->{strLogLevelTest});
|
||||
@ -417,7 +430,7 @@ sub run
|
||||
(vmWithBackTrace($self->{oTest}->{&TEST_VM}) && $self->{bBackTrace} ? ' -DWITH_BACKTRACE' : '') .
|
||||
($self->{oTest}->{&TEST_CDEF} ? " $self->{oTest}->{&TEST_CDEF}" : '') .
|
||||
(vmCoverageC($self->{oTest}->{&TEST_VM}) && $self->{bCoverageUnit} ? ' -DDEBUG_COVERAGE' : '') .
|
||||
($self->{bDebug} ? '' : ' -DNDEBUG') .
|
||||
($self->{bDebug} && $self->{oTest}->{&TEST_TYPE} ne TESTDEF_PERFORMANCE ? '' : ' -DNDEBUG') .
|
||||
($self->{bDebugTestTrace} && $self->{bDebug} ? ' -DDEBUG_TEST_TRACE' : '');
|
||||
|
||||
# Flags used to build harness files
|
||||
|
@ -46,6 +46,8 @@ use constant TEST_PGSQL_BIN => 'pgsql-bi
|
||||
push @EXPORT, qw(TEST_PGSQL_BIN);
|
||||
use constant TEST_INTEGRATION => 'integration';
|
||||
push @EXPORT, qw(TEST_INTEGRATION);
|
||||
use constant TEST_TYPE => 'type';
|
||||
push @EXPORT, qw(TEST_TYPE);
|
||||
use constant TEST_RUN => 'run';
|
||||
push @EXPORT, qw(TEST_RUN);
|
||||
use constant TEST_VM => 'os';
|
||||
@ -150,6 +152,7 @@ sub testListGet
|
||||
|
||||
my $oTestRun =
|
||||
{
|
||||
&TEST_TYPE => $hTest->{&TESTDEF_TYPE},
|
||||
&TEST_VM => $strTestOS,
|
||||
&TEST_C => coalesce($hTest->{&TESTDEF_C}, $hModule->{&TESTDEF_C}, false),
|
||||
&TEST_CDEF => $hTest->{&TESTDEF_DEFINE},
|
||||
|
@ -141,6 +141,30 @@ testExpectPathSet(const char *testExpectPath)
|
||||
FUNCTION_HARNESS_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get and set scale for performance testing
|
||||
***********************************************************************************************************************************/
|
||||
static uint64_t testScaleData = 1;
|
||||
|
||||
uint64_t
|
||||
testScale(void)
|
||||
{
|
||||
FUNCTION_HARNESS_VOID();
|
||||
FUNCTION_HARNESS_RESULT(UINT64, testScaleData);
|
||||
}
|
||||
|
||||
void
|
||||
testScaleSet(uint64_t testScale)
|
||||
{
|
||||
FUNCTION_HARNESS_BEGIN();
|
||||
FUNCTION_HARNESS_PARAM(UINT64, testScale);
|
||||
FUNCTION_HARNESS_END();
|
||||
|
||||
testScaleData = testScale;
|
||||
|
||||
FUNCTION_HARNESS_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get test user/group
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -37,6 +37,9 @@ void testRepoPathSet(const char *testRepoPath);
|
||||
const char *testUser(void);
|
||||
const char *testGroup(void);
|
||||
|
||||
// For scaling performance tests
|
||||
uint64_t testScale(void);
|
||||
|
||||
// Read a file (max 256k) into a buffer
|
||||
void hrnFileRead(const char *fileName, unsigned char *buffer, size_t bufferSize);
|
||||
|
||||
|
@ -30,6 +30,8 @@ The test code is included directly so it can freely interact with the included C
|
||||
#include "common/harnessDebug.h"
|
||||
#include "common/harnessTest.h"
|
||||
|
||||
extern void testScaleSet(uint64_t testScale);
|
||||
|
||||
#ifndef NO_LOG
|
||||
#include "common/harnessLog.h"
|
||||
void harnessLogLevelDefaultSet(LogLevel logLevel);
|
||||
@ -81,6 +83,7 @@ main(int argListSize, const char *argList[])
|
||||
testPathSet("{[C_TEST_PATH]}");
|
||||
testRepoPathSet("{[C_TEST_REPO_PATH]}");
|
||||
testExpectPathSet("{[C_TEST_EXPECT_PATH]}");
|
||||
testScaleSet({[C_TEST_SCALE]});
|
||||
|
||||
// Set default test log level
|
||||
#ifndef NO_LOG
|
||||
|
@ -96,6 +96,7 @@ test.pl [options]
|
||||
--backtrace enable backtrace when available (adds stack trace line numbers -- very slow)
|
||||
--profile generate profile info
|
||||
--no-debug don't generate a debug build
|
||||
--scale scale performance tests
|
||||
--debug-test-trace test stack trace for low-level functions (slow, esp w/valgrind, may cause timeouts)
|
||||
|
||||
Report Options:
|
||||
@ -164,6 +165,7 @@ my $bExpect = false;
|
||||
my $bNoValgrind = false;
|
||||
my $bNoOptimize = false;
|
||||
my $bNoDebug = false;
|
||||
my $iScale = 1;
|
||||
my $bDebugTestTrace = false;
|
||||
my $iRetry = 0;
|
||||
|
||||
@ -210,6 +212,7 @@ GetOptions ('q|quiet' => \$bQuiet,
|
||||
'no-valgrind' => \$bNoValgrind,
|
||||
'no-optimize' => \$bNoOptimize,
|
||||
'no-debug', => \$bNoDebug,
|
||||
'scale=s' => \$iScale,
|
||||
'debug-test-trace', => \$bDebugTestTrace,
|
||||
'retry=s' => \$iRetry)
|
||||
or pod2usage(2);
|
||||
@ -1301,7 +1304,7 @@ eval
|
||||
$oStorageTest, $strBackRestBase, $strTestPath, $strCoveragePath, $$oyTestRun[$iTestIdx], $bDryRun, $bVmOut,
|
||||
$iVmIdx, $iVmMax, $iTestIdx, $iTestMax, $strLogLevel, $strLogLevelTest, $bLogForce, $bShowOutputAsync,
|
||||
$bNoCleanup, $iRetry, !$bNoValgrind, !$bNoCoverage, $bCoverageSummary, !$bNoOptimize, $bBackTrace,
|
||||
$bProfile, !$bNoDebug, $bDebugTestTrace, $iBuildMax / $iVmMax < 1 ? 1 : int($iBuildMax / $iVmMax));
|
||||
$bProfile, $iScale, !$bNoDebug, $bDebugTestTrace, $iBuildMax / $iVmMax < 1 ? 1 : int($iBuildMax / $iVmMax));
|
||||
$iTestIdx++;
|
||||
|
||||
if ($oJob->run())
|
||||
|
Loading…
x
Reference in New Issue
Block a user