Skip to content

Severe lock contention in BlockingCollection in BinLogReader #684

@rolfbjarne

Description

@rolfbjarne

The BlockingCollection in BinLogReader suffers from severe lock contention:

// Use a producer-consumer queue so that IO can happen on one thread
// while processing can happen on another thread decoupled. The speed
// up is from 4.65 to 4.15 seconds.
var queue = new BlockingCollection<BuildEventArgs>(boundedCapacity: 5000);

I added some debug code, and the initial results were:

Read 24924 records in 00:00:06.8023352 = 6802.3352 ms

raising the bounded capacity from 5000 to 50000, I get:

Read 24924 records in 00:00:00.3312354 = 331.2354 ms

which means that >95% of the time spent loading the binlog is spent waiting for a lock.

This is on macOS with the Avalonia version, but I'm guessing something similar would happen elsewhere as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions