ordinals / ord

👁‍🗨 Rare and exotic sats
https://ordinals.com
Creative Commons Zero v1.0 Universal
3.82k stars 1.36k forks source link

Initial sync time doesn't include the final commit time #3868

Open gmart7t2 opened 2 months ago

gmart7t2 commented 2 months ago

Maybe consider switching the order of these two blocks:

    if starting_index_height == 0 && self.height > 0 {
      wtx.open_table(STATISTIC_TO_COUNT)?.insert(
        Statistic::InitialSyncTime.key(),
        &u64::try_from(start.elapsed().as_micros())?,
      )?;
    }

    if uncommitted > 0 {
      self.commit(wtx, utxo_cache)?;
    }

That final commit can take a long time, and should be included in the initial sync time.

casey commented 1 month ago

Good find! One issue though is that after the commit, the write transaction doesn't exist, so we would have to create a new write transaction, se the statistic, and commit again. How long does the final commit usually take?

raphjaph commented 1 month ago

It can take like 30mins sometimes I think

casey commented 1 month ago

I think we should just double-commit if it's the first commit. I.e., if it's the first commit and we just comitted, set the statistic and re-commit. The second commit should be very quick.

raphjaph commented 1 month ago

yes, the second one is negligable