Commit graph

57 commits

Author SHA1 Message Date
Calin Culianu
b799dfb2a8
Scripthash history fix. Oops!
we weren't adding the right txidx to the history.  Good thing I also
added debug code to this commit to check history.

Fixed!

Also various other nits and tweaks.  Added the /debug endpoint for
sending params for debugging to the server.
2019-12-12 12:15:06 +02:00
Calin Culianu
f130c0450d Compile fixups for linux; rebuilt rocksdb for linux with USE_RTTI 2019-12-12 01:28:27 +02:00
Calin Culianu
608ba22231
added stats for merge calls for debugging 2019-12-12 00:23:19 +02:00
Calin Culianu
4dbc8e1b7d
Added scripthash_history update during sync
Requires the "merge operator" for performance. This ends up requiring a
lib recompile to use RTTI.
2019-12-12 00:07:29 +02:00
Calin Culianu
deda9fe583
Added preliminary BlkInfo saving to db
And checking on startup
2019-12-11 19:57:01 +02:00
Calin Culianu
90511e4f14
refactor nit in Storage.cpp 2019-12-11 18:52:33 +02:00
Calin Culianu
a68e9a5d86
More simplification in Storage.cpp templates
yay
2019-12-11 18:39:19 +02:00
Calin Culianu
e94bbbfd52
Nits and refactoring in Storage.cpp templates
Made the GenericDBGet and GenericDBPut more generic.  They rely on a new
C++17 stytle 'auto' return type template, ToSlice, which is very
generic. :)
2019-12-11 18:25:24 +02:00
Calin Culianu
c1d01fb029
Reduced CPU usage in addBlock -- we mark outputs spent in PreProcessedBlock now
This reduces the building of a set for each hashX in addBlock. Now we
flag the outputs that are safe to ignore for adding to utxo set (because
they were already spent) by flagging the OutPt directly in
PreProcessedBlock fill().

Should improve performance slightly as no more nested loops in
addBlock()
2019-12-11 17:02:42 +02:00
Calin Culianu
e4a723ccc3
Refactorings and nits in RecordFile.cpp code 2019-12-11 16:35:22 +02:00
Calin Culianu
07934e52cb
renamed file TxNum2TxHash to lowercase txnum2txhash 2019-12-11 12:28:01 +02:00
Calin Culianu
91b504b92a
comment nits 2019-12-11 12:13:47 +02:00
Calin Culianu
bfd697f9a2 nits 2019-12-11 11:49:45 +02:00
Calin Culianu
a4ca204dc9 Added recordfile use in storage.cpp, got rid of txnums table from db. this should be faster. 2019-12-11 11:32:46 +02:00
Calin Culianu
5cf40f5d20
nit 2019-12-11 08:52:38 +02:00
Calin Culianu
b6d248dfa7
Got rid of txHash -> txnum reverse mapping from db
this wasted gigs of space and likely won't be used.

Also refactored/optimized the db serialize to slice stuff to do less
copying when it's serializing a temporary to a slice.
2019-12-11 08:26:53 +02:00
Calin Culianu
8c3b42f1c5
Tweaks and fixups in storage class -- refactored some stuff
We no longer store the headers in memory. We keep them in the db.  We
don't need them that often and clients can just read them from the db
if/when needed. Hopefully rocksdb is peppy enough.  We can cache them if
it's a problem.

Also refactored some stuff around and simplified the storage code a
little bit.
2019-12-11 00:05:16 +02:00
Calin Culianu
262349f4ab
Test different maxBackLog backoff strategy, re-enabled write batching
Write batching reenabled for txnum <-> hash disk write
2019-12-09 15:39:39 +02:00
Calin Culianu
1ec001d95e
Save txNumNext to db, turn off batched writes in addBlock
batched writes in addBlock may be the reason we are seeing huge memory
consumption spikes when synching mainnet.  Turned off for now.
2019-12-09 13:42:11 +02:00
Calin Culianu
01f1ebd62c
Got rid of in-memory utxo set.. will rely on db
RocksDB is super fast. Keeping it in memory was a waste of memory.  This
is much faster and reduced memory consumption significantly.

TODO: Maybe do the same thing for headers as well!

Also: We need to save txNum to DB. We're not saving it now resulting in
correctness errors on subsequent reloads of same db.
2019-12-09 12:10:59 +02:00
Calin Culianu
4c6cc629ca addBlock: fix to prevent redundant add/removal of txo's spent in same block 2019-12-09 10:04:30 +02:00
Calin Culianu
a61beb1f35 tweak 2019-12-09 01:11:34 +02:00
Calin Culianu
a749f16582 use robin hood flat map instead of set in compactifyUtxoSet 2019-12-08 23:48:58 +02:00
Calin Culianu
c6243c489d
some tweaks to conserve memory 2019-12-08 23:15:42 +02:00
Calin Culianu
cb2233c09e msg tweak when closing db and it's busy saving 2019-12-08 22:53:50 +02:00
Calin Culianu
8bb60fcb0d tweak 2019-12-08 22:48:48 +02:00
Calin Culianu
83e11bfd0b
Added some logic to cut down on cost of saving on first synch
On first synch we don't keep track of the difference set for the utxo
set. This should reduce memory consumption.  We just build the working
set.  After first save we then need to keep track of the difference set.

We also reduced the save interval to be infrequent -- every 500000
blocks.  This should also hopefully keep the controller task from
falling behind.

We do save on task end / ctrl-c though.
2019-12-08 22:31:17 +02:00
Calin Culianu
d982252adf nits 2019-12-08 22:16:52 +02:00
Calin Culianu
0c35c4a9fc
Added 'setSaveInterval' to specify save interval, redid backoff logic
The backoff logic on backlogs now favors the closer blocks to present
and delays the father away ones more.

Added the save interval as a programmable constant to storage.  We set
it to 100,000 on full downloads.
2019-12-08 22:07:01 +02:00
Calin Culianu
a9408e1bf6
Some tweaks for correctness and memory consumption + lru cache perf
- Added compactifyUtxoSet to periodically reduce all instances of dupe
QByteArrays to point to the same underlying shared object. This runs
every 33,000 blocks on synch.

- Merged the Hdr and UtxoSet save flags into a single flag, "Blocks"
which means they get saved together. This is crucial for correctness.
Before it could be the case that a different height would be saved for
headers vs utxo set because of the way it worked.

- made the two lru caches try and keep the same key/value pairs
(hopefully shared copies)

- made the LRU::Cache class not use an exception internally on tryGet()
-- this seems to have a positive impact on performance as this function
is called a lot.  Instead, it calls into an internal common function now
called get_nolock_nothrow, upon which everything else is based.

It appears these efforts have reduced memory consumption a bit.  Our
UTXOSet is still pretty heavy.  More work to be done...
2019-12-08 17:21:39 +02:00
Calin Culianu
509a7253c7 testing 2019-12-08 11:45:57 +02:00
Calin Culianu
8e4bed2817 more stabs at rocksdb memory usage 2019-12-08 05:20:40 +02:00
Calin Culianu
00d8139032 tweaks to rocksdb in an attempt to reduce memory usage 2019-12-08 05:02:46 +02:00
Calin Culianu
56dcd08781 reduced lru cache elasticity size in storage.cpp 2019-12-08 03:45:45 +02:00
Calin Culianu
ae3321f882 nit 2019-12-08 03:06:36 +02:00
Calin Culianu
de3f9716d9 added lru cache shrink method 2019-12-08 02:55:45 +02:00
Calin Culianu
96b3b49748 added lru cache for txhash, misc other fixes 2019-12-08 02:36:46 +02:00
Calin Culianu
22b477b34e wip utxo set load 2019-12-08 01:00:40 +02:00
Calin Culianu
8b3f67cd32 wip 2019-12-07 23:30:07 +02:00
Calin Culianu
fa504bd6fb wip 2019-12-07 20:34:19 +02:00
Calin Culianu
ae753e22fc
Refactor the chaintip/chainheight stuff into a single call in the storage
Just a little bit cleaner...
2019-12-07 15:54:56 +02:00
Calin Culianu
c2c17f5e36 nits 2019-12-03 22:47:03 +02:00
Calin Culianu
7f6d025be2 nit: made GetBlockHeaderSize() return int because that's more useful to us 2019-12-03 21:53:32 +02:00
Calin Culianu
c0184427d2 nits 2019-12-03 21:48:10 +02:00
Calin Culianu
8d65e77e2a nits 2019-12-03 19:52:46 +02:00
Calin Culianu
48e5f116d8
More nits in Storage.cpp and other places 2019-12-03 19:09:38 +02:00
Calin Culianu
1d1b681523 nits 2019-12-03 16:02:53 +02:00
Calin Culianu
69f15fa5a4 comment nit 2019-12-03 15:59:36 +02:00
Calin Culianu
4bb5eb0949 wip 2019-12-03 15:41:09 +02:00
Calin Culianu
4d1c7f91ea wip 2019-12-03 13:57:02 +02:00