-
Notifications
You must be signed in to change notification settings - Fork 370
Perf: Massively improved the performance of the replayMilestones method #1197
Perf: Massively improved the performance of the replayMilestones method #1197
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
src/main/java/com/iota/iri/service/snapshot/impl/SnapshotImpl.java
Outdated
Show resolved
Hide resolved
Objects.equals(metaData, ((SnapshotImpl) obj).metaData) && | ||
Objects.equals(skippedMilestones, ((SnapshotImpl) obj).skippedMilestones); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will also be nice to have a toString()
here.
The toString()
may only print SnapshotMetadata` toString() to not make it a reasonable size (index, hash, hasSolidEntryPoints). You can also decide to have it print the state, but it will be long.
Whatever you think will help with debugging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add that in another PR - maybe create an issue to check if all models have these toString methods.
src/main/java/com/iota/iri/service/snapshot/impl/SnapshotServiceImpl.java
Show resolved
Hide resolved
src/main/java/com/iota/iri/service/snapshot/impl/SnapshotServiceImpl.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great PR and clever idea!
src/main/java/com/iota/iri/service/snapshot/impl/SnapshotServiceImpl.java
Outdated
Show resolved
Hide resolved
@@ -112,6 +113,10 @@ public void applyStateDiff(SnapshotStateDiff diff) throws SnapshotException { | |||
if (balances.computeIfPresent(addressHash, (hash, aLong) -> balance + aLong) == null) { | |||
balances.putIfAbsent(addressHash, balance); | |||
} | |||
|
|||
if (balances.get(addressHash) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…t/iri into merge_replaymilestonesrefactor
Description
This PR refactors the replayMilestones method to first accumulate all changes and then apply them in a single call. This allows us to modify the milestone without having to create a copy of the state first. Since the Snapshot and its corresponding SnapshotState are huge datastructures, this change reduces the time required for a rebuild of the ledger state after a IRI restart from a few hours to a few seconds (for a non-snapshotted database).
Type of change
Checklist: