Speed up DAO state monitor view load #4035
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Compute height cells lazily to speed up
DaoStateMonitorView
Avoid a bottleneck computing the cycle index & calling
Res.get(..)
for every block since genesis in the DAO state monitor view, when building theDaoStateBlockListItem
objects, by making theheight
field lazy. To do this, pass the cycle index into the constructor using anIntSupplier
and make the height a memoisedSupplier<String>
with a custom getter.Also add a unit test to check that the auto-generated
equals
&hashCode
methods still work as expected, as it isn't totally clear what Lombok would do when a field type differs from its getter return type.--
Flippling back and forth between the Network monitor tab and the Governance tab revealed the following call tree in JProfiler:
As can be seen above, most of the time is spent in the stream pipeline collecting new
DaoStateBlockListItem
objects, inDaoStateMonitorView.onDataUpdate
. After the change, the main bottleneck appeared to be from internal JavaFX code, in thelistItems.setAll
call inonDataUpdate
(perhaps from one of the listeners onDaoStateMonitorView.sortedList
). However, I believe there was a noticeable speedup. Also, the slowdown over time is likely to be quadratic without the change, as the number of cycles and block grows linearly. (The main bottleneck appears to be computing the cycle index of each block.)