Skip to content

Fork choice write lock held during database write #8147

@michaelsproul

Description

@michaelsproul

Description

Currently we hold the fork choice write lock while writing to disk:

// The fork choice write-lock is dropped *after* the on-disk database has been updated.
// This prevents inconsistency between the two at the expense of concurrency.
drop(fork_choice);

This poses a potential problem for fork choice lock readers, which will be blocked while waiting for this write to complete. We expect that writing to disk takes hundreds of milliseconds several seconds due to diff computation and overhead due to database I/O.

Metrics

Metrics seem to indicate that this is not a significant performance issue:

# HELP beacon_fork_choice_read_lock_aquire_seconds Time taken to aquire the fork-choice read lock
# TYPE beacon_fork_choice_read_lock_aquire_seconds histogram
beacon_fork_choice_read_lock_aquire_seconds_bucket{le="0.0001"} 1025501427
beacon_fork_choice_read_lock_aquire_seconds_bucket{le="0.0004"} 1086019739
beacon_fork_choice_read_lock_aquire_seconds_bucket{le="0.0016"} 1254510271
beacon_fork_choice_read_lock_aquire_seconds_bucket{le="0.0064"} 1313781698
beacon_fork_choice_read_lock_aquire_seconds_bucket{le="0.0256"} 1316301315
beacon_fork_choice_read_lock_aquire_seconds_bucket{le="0.1024"} 1316615602
beacon_fork_choice_read_lock_aquire_seconds_bucket{le="0.4096"} 1316673956
beacon_fork_choice_read_lock_aquire_seconds_bucket{le="+Inf"} 1316682131
beacon_fork_choice_read_lock_aquire_seconds_sum 378137.6061273879
beacon_fork_choice_read_lock_aquire_seconds_count 1316682131

TODO: more analysis here

Steps to resolve

Please describe the steps required to resolve this issue, if known.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fork_choiceoptimizationSomething to make Lighthouse run more efficiently.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions