go-spacemesh icon indicating copy to clipboard operation
go-spacemesh copied to clipboard

database: improve performance for proposal handling

Open countvonzero opened this issue 2 years ago • 3 comments

Description

current when a proposal arrives, we do the following steps: 0. decode and initialize

  1. db lookup for duplicate proposal
  2. register fetch cache with the peer->hashes in the proposal
  3. process ballot 3.0 db lookup for duplicate ballot 3.1 check ballot has correct data 3.2 fetch referenced data in ballot (atxs/ballots/blocks) 3.3 check votes are consistent 3.4 check ballot is eligible 3.5 save ballot to db
  4. fetch txs in proposal
  5. save proposal to db
  6. link each tx to the proposal in db

currently on GCP, a proposal can take 800-1200ms, this should be optimized to as little as possible, since proposal propagation and processing time directly affect consensus input to hare.

here is the metrics for time spent on proposal handling step.one can see its dominated by db writes. in the steps described above:

  • db lookup: step 1, 3.0, 3.2, 3.3, 4
  • db writes: 3.5, 5, 6

Screenshot from 2022-07-19 16-06-57

countvonzero avatar Jul 20 '22 23:07 countvonzero

why do we save proposals to database at all? can they be kept in memory for a couple of layers?

dshulyak avatar Jul 25 '22 05:07 dshulyak

why do we save proposals to database at all? can they be kept in memory for a couple of layers?

that's potentially something we can change once we have the all the block generation logic is in place.

countvonzero avatar Jul 26 '22 16:07 countvonzero

this measurement is done with GCP default disk. need to measure with 10GB ssd.

countvonzero avatar Jul 30 '22 04:07 countvonzero