Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
74be81c
init commit
ahangsu Jan 25, 2023
d616eb3
disable option
ahangsu Jan 25, 2023
4127490
disable option from config local to ledger
ahangsu Jan 25, 2023
d0ad11a
update a testcase for disabling lru cache in lrukv
ahangsu Jan 25, 2023
4e2e30e
update config.json.example
ahangsu Jan 25, 2023
a96a8fd
more coverage from unit
ahangsu Jan 26, 2023
90b874d
Merge branch 'master' into no-cache-testing
ahangsu Jan 27, 2023
1a8be94
attempting to run with cache on and cache off modes
ahangsu Jan 27, 2023
280fb3e
remove t skip in acctupdates_test.go
ahangsu Jan 27, 2023
35639af
renaming withOrWithoutLRUCache to withAndWithoutLRUCache
ahangsu Jan 27, 2023
c199c7f
poking around and set disable ledger lru cache to be true
ahangsu Jan 27, 2023
4ef03ae
higher warning threshold
ahangsu Jan 27, 2023
7a5abd1
codereading...
ahangsu Jan 30, 2023
e25556f
revert conflict commit
ahangsu Jan 30, 2023
aa7740e
an ugly attempt to pass config.Local into TestConsensusRange
ahangsu Jan 30, 2023
f5f2af3
this is a bad commit, we need to revert later, trigger no-cache test
ahangsu Jan 31, 2023
8755dd8
Revert "this is a bad commit, we need to revert later, trigger no-cac…
ahangsu Jan 31, 2023
7332a07
minor testing
ahangsu Jan 31, 2023
eae1d50
Merge branch 'master' into no-cache-testing
ahangsu Feb 2, 2023
eccd71e
per pr comment, local ver27, warning threshold 0
ahangsu Feb 2, 2023
6cf1485
per pr comment, t skip, ledger testing
ahangsu Feb 2, 2023
e88397a
barking dog
ahangsu Feb 2, 2023
aee23ab
minor
ahangsu Feb 2, 2023
1ddb62c
Merge branch 'master' into no-cache-testing
ahangsu Feb 3, 2023
f21eb07
codec '' tag for DisableLRUCache
ahangsu Feb 5, 2023
138e3f4
try to use codec:'-'
ahangsu Feb 6, 2023
210bc17
workaround fix in defaultGenerator logic to skip field codec:'-'
ahangsu Feb 6, 2023
37177c7
revert codec:'-' related commits
ahangsu Feb 9, 2023
1caa854
decrease test time by introducing randomness
ahangsu Feb 9, 2023
721a336
log message on lru cache disabling
ahangsu Feb 10, 2023
922413a
per chris comments on removing disable boolean field
ahangsu Feb 10, 2023
2b6e724
per pr comments
ahangsu Feb 15, 2023
f728363
WithAndWithout test against TestAcctUpdatesUpdatesCorrectness
ahangsu Feb 15, 2023
5954351
per review comments
ahangsu Feb 15, 2023
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
5 changes: 5 additions & 0 deletions config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,11 @@ type Local struct {
// guarantees in terms of functionality or future support.
EnableExperimentalAPI bool `version[26]:"false"`

// DisableLedgerLRUCache disables LRU caches in ledger.
// Setting it to TRUE might result in significant performance degradation
// and SHOULD NOT be used for other reasons than testing.
DisableLedgerLRUCache bool `version[27]:"false"`

// EnableFollowMode launches the node in "follower" mode. This turns off the agreement service,
// and APIs related to broadcasting transactions, and enables APIs which can retrieve detailed information
// from ledger caches and can control the ledger round.
Expand Down
1 change: 1 addition & 0 deletions config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var defaultLocal = Local{
DNSSecurityFlags: 1,
DeadlockDetection: 0,
DeadlockDetectionThreshold: 30,
DisableLedgerLRUCache: false,
DisableLocalhostConnectionRateLimit: true,
DisableNetworking: false,
DisableOutgoingConnectionThrottling: false,
Expand Down
1 change: 1 addition & 0 deletions installer/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"DNSSecurityFlags": 1,
"DeadlockDetection": 0,
"DeadlockDetectionThreshold": 30,
"DisableLedgerLRUCache": false,
Comment thread
ahangsu marked this conversation as resolved.
"DisableLocalhostConnectionRateLimit": true,
"DisableNetworking": false,
"DisableOutgoingConnectionThrottling": false,
Expand Down
10 changes: 9 additions & 1 deletion ledger/acctonline.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,16 @@ type onlineAccounts struct {

// maxAcctLookback sets the minimim deltas size to keep in memory
acctLookback uint64

// disableCache (de)activates the LRU cache use in onlineAccounts
disableCache bool
}

// initialize initializes the accountUpdates structure
func (ao *onlineAccounts) initialize(cfg config.Local) {
ao.accountsReadCond = sync.NewCond(ao.accountsMu.RLocker())
ao.acctLookback = cfg.MaxAcctLookback
ao.disableCache = cfg.DisableLedgerLRUCache
}

// loadFromDisk is the 2nd level initialization, and is required before the onlineAccounts becomes functional
Expand Down Expand Up @@ -184,7 +188,11 @@ func (ao *onlineAccounts) initializeFromDisk(l ledgerForTracker, lastBalancesRou
ao.accounts = make(map[basics.Address]modifiedOnlineAccount)
ao.deltasAccum = []int{0}

ao.baseOnlineAccounts.init(ao.log, baseAccountsPendingAccountsBufferSize, baseAccountsPendingAccountsWarnThreshold)
if !ao.disableCache {
ao.baseOnlineAccounts.init(ao.log, baseAccountsPendingAccountsBufferSize, baseAccountsPendingAccountsWarnThreshold)
} else {
ao.baseOnlineAccounts.init(ao.log, 0, 0)
}
return
}

Expand Down
17 changes: 14 additions & 3 deletions ledger/acctupdates.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ type accountUpdates struct {

// maxAcctLookback sets the minimim deltas size to keep in memory
acctLookback uint64

// disableCache (de)activates the LRU cache use in accountUpdates
disableCache bool
}

// RoundOffsetError is an error for when requested round is behind earliest stored db entry
Expand Down Expand Up @@ -296,6 +299,8 @@ func (au *accountUpdates) initialize(cfg config.Local) {
// log metrics
au.logAccountUpdatesMetrics = cfg.EnableAccountUpdatesStats
au.logAccountUpdatesInterval = cfg.AccountUpdatesStatsInterval

au.disableCache = cfg.DisableLedgerLRUCache
}

// loadFromDisk is the 2nd level initialization, and is required before the accountUpdates becomes functional
Expand Down Expand Up @@ -962,9 +967,15 @@ func (au *accountUpdates) initializeFromDisk(l ledgerForTracker, lastBalancesRou
au.creatables = make(map[basics.CreatableIndex]ledgercore.ModifiedCreatable)
au.deltasAccum = []int{0}

au.baseAccounts.init(au.log, baseAccountsPendingAccountsBufferSize, baseAccountsPendingAccountsWarnThreshold)
au.baseResources.init(au.log, baseResourcesPendingAccountsBufferSize, baseResourcesPendingAccountsWarnThreshold)
au.baseKVs.init(au.log, baseKVPendingBufferSize, baseKVPendingWarnThreshold)
if !au.disableCache {
au.baseAccounts.init(au.log, baseAccountsPendingAccountsBufferSize, baseAccountsPendingAccountsWarnThreshold)
au.baseResources.init(au.log, baseResourcesPendingAccountsBufferSize, baseResourcesPendingAccountsWarnThreshold)
au.baseKVs.init(au.log, baseKVPendingBufferSize, baseKVPendingWarnThreshold)
Comment thread
cce marked this conversation as resolved.
} else {
au.baseAccounts.init(au.log, 0, 0)
au.baseResources.init(au.log, 0, 0)
au.baseKVs.init(au.log, 0, 0)
}
return
}

Expand Down
30 changes: 15 additions & 15 deletions ledger/acctupdates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,20 +475,13 @@ func checkOnlineAcctUpdatesConsistency(t *testing.T, ao *onlineAccounts, rnd bas
}
}

func TestAcctUpdates(t *testing.T) {
partitiontest.PartitionTest(t)

if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
t.Skip("This test is too slow on ARM and causes travis builds to time out")
}

func testAcctUpdates(t *testing.T, conf config.Local) {
// The next operations are heavy on the memory.
// Garbage collection helps prevent trashing
runtime.GC()

proto := config.Consensus[protocol.ConsensusCurrentVersion]

conf := config.GetDefaultLocal()
for _, lookback := range []uint64{conf.MaxAcctLookback, proto.MaxBalLookback} {
t.Run(fmt.Sprintf("lookback=%d", lookback), func(t *testing.T) {

Expand Down Expand Up @@ -597,6 +590,13 @@ func TestAcctUpdates(t *testing.T) {
}
}

func TestAcctUpdates(t *testing.T) {
partitiontest.PartitionTest(t)

conf := config.GetDefaultLocal()
ledgertesting.WithAndWithoutLRUCache(t, conf, testAcctUpdates)
}

func BenchmarkBalancesChanges(b *testing.B) {
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
b.Skip("This test is too slow on ARM and causes travis builds to time out")
Expand Down Expand Up @@ -712,20 +712,21 @@ func BenchmarkCalibrateCacheNodeSize(b *testing.B) {
// The TestAcctUpdatesUpdatesCorrectness conduct a correctless test for the accounts update in the following way -
// Each account is initialized with 100 algos.
// On every round, each account move variable amount of funds to an accumulating account.
// The deltas for each accounts are picked by using the lookup method.
// The deltas for each account are picked by using the lookup method.
// At the end of the test, we verify that each account has the expected amount of algos.
// In addition, throughout the test, we check ( using lookup ) that the historical balances, *beyond* the
// lookback are generating either an error, or returning the correct amount.
func TestAcctUpdatesUpdatesCorrectness(t *testing.T) {
partitiontest.PartitionTest(t)

if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
Comment thread
cce marked this conversation as resolved.
t.Skip("This test is too slow on ARM and causes travis builds to time out")
}
cfgLocal := config.GetDefaultLocal()
ledgertesting.WithAndWithoutLRUCache(t, cfgLocal, testAcctUpdatesUpdatesCorrectness)
}

func testAcctUpdatesUpdatesCorrectness(t *testing.T, cfg config.Local) {
// create new protocol version, which has lower look back.
testProtocolVersion := protocol.ConsensusCurrentVersion
maxAcctLookback := config.GetDefaultLocal().MaxAcctLookback
maxAcctLookback := cfg.MaxAcctLookback
inMemory := true

testFunction := func(t *testing.T) {
Expand All @@ -750,8 +751,7 @@ func TestAcctUpdatesUpdatesCorrectness(t *testing.T) {
accts[0][addr] = accountData
}

conf := config.GetDefaultLocal()
au, _ := newAcctUpdates(t, ml, conf)
au, _ := newAcctUpdates(t, ml, cfg)
defer au.close()

// cover 10 genesis blocks
Expand Down
Loading