Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tom
crown-core
Commits
02ae417d
Commit
02ae417d
authored
9 years ago
by
Pieter Wuille
Committed by
Alastair Clark
7 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Cache tweak and logging improvements
parent
a643bddf
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/init.cpp
+11
-9
src/init.cpp
src/main.cpp
+2
-2
src/main.cpp
src/txdb.h
+1
-1
src/txdb.h
with
14 additions
and
12 deletions
+14
-12
src/init.cpp
View file @
02ae417d
...
...
@@ -1139,18 +1139,20 @@ bool AppInit2(boost::thread_group& threadGroup)
}
// cache size calculations
size_t
nTotalCache
=
(
GetArg
(
"-dbcache"
,
nDefaultDbCache
)
<<
20
);
if
(
nTotalCache
<
(
nMinDbCache
<<
20
))
nTotalCache
=
(
nMinDbCache
<<
20
);
// total cache cannot be less than nMinDbCache
else
if
(
nTotalCache
>
(
nMaxDbCache
<<
20
))
nTotalCache
=
(
nMaxDbCache
<<
20
);
// total cache cannot be greater than nMaxDbCache
size_t
nBlockTreeDBCache
=
nTotalCache
/
8
;
if
(
nBlockTreeDBCache
>
(
1
<<
21
)
&&
!
GetBoolArg
(
"-txindex"
,
true
))
int64_t
nTotalCache
=
(
GetArg
(
"-dbcache"
,
nDefaultDbCache
)
<<
20
);
nTotalCache
=
std
::
max
(
nTotalCache
,
nMinDbCache
<<
20
);
// total cache cannot be less than nMinDbCache
nTotalCache
=
std
::
min
(
nTotalCache
,
nMaxDbCache
<<
20
);
// total cache cannot be greated than nMaxDbcache
int64_t
nBlockTreeDBCache
=
nTotalCache
/
8
;
if
(
nBlockTreeDBCache
>
(
1
<<
21
)
&&
!
GetBoolArg
(
"-txindex"
,
false
))
nBlockTreeDBCache
=
(
1
<<
21
);
// block tree db cache shouldn't be larger than 2 MiB
nTotalCache
-=
nBlockTreeDBCache
;
size
_t
nCoinDBCache
=
nTotalCache
/
2
;
// use
half
of the remain
ing cache for coindb
cache
int64
_t
nCoinDBCache
=
std
::
min
(
nTotalCache
/
2
,
(
nTotalCache
/
4
)
+
(
1
<<
23
))
;
// use
25%-50%
of the remain
der for disk
cache
nTotalCache
-=
nCoinDBCache
;
nCoinCacheUsage
=
nTotalCache
;
nCoinCacheUsage
=
nTotalCache
;
// the rest goes to in-memory cache
LogPrintf
(
"Cache configuration:
\n
"
);
LogPrintf
(
"* Using %.1fMiB for block index database
\n
"
,
nBlockTreeDBCache
*
(
1.0
/
1024
/
1024
));
LogPrintf
(
"* Using %.1fMiB for chain state database
\n
"
,
nCoinDBCache
*
(
1.0
/
1024
/
1024
));
LogPrintf
(
"* Using %.1fMiB for in-memory UTXO set
\n
"
,
nCoinCacheUsage
*
(
1.0
/
1024
/
1024
));
bool
fLoaded
=
false
;
while
(
!
fLoaded
)
{
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
View file @
02ae417d
...
...
@@ -2277,10 +2277,10 @@ void static UpdateTip(CBlockIndex *pindexNew) {
nTimeBestReceived = GetTime();
mempool.AddTransactionsUpdated(1);
LogPrintf("UpdateTip: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%
u
\n",
LogPrintf("UpdateTip: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%
.1fMiB(%utx)
\n",
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
Checkpoints::GuessVerificationProgress(chainActive.Tip()),
(unsigned int)
pcoinsTip->GetCacheSize());
Checkpoints::GuessVerificationProgress(chainActive.Tip()),
pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)),
pcoinsTip->GetCacheSize());
cvBlockChange.notify_all();
...
...
This diff is collapsed.
Click to expand it.
src/txdb.h
View file @
02ae417d
...
...
@@ -20,7 +20,7 @@ class uint256;
//! -dbcache default (MiB)
static
const
int64_t
nDefaultDbCache
=
100
;
//! max. -dbcache in (MiB)
static
const
int64_t
nMaxDbCache
=
sizeof
(
void
*
)
>
4
?
4096
:
1024
;
static
const
int64_t
nMaxDbCache
=
sizeof
(
void
*
)
>
4
?
16384
:
1024
;
//! min. -dbcache in (MiB)
static
const
int64_t
nMinDbCache
=
4
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help