Skip to content

Change sync::rwlock to use atomics for read_count/read_mode instead of locking #7066

Closed
@bblum

Description

@bblum

The rwlocks are implemented following the algorithm described here: http://en.wikipedia.org/wiki/Readers-writers_problem#The_third_readers-writers_problem , which has a note:

Note that sections protected by counter_mutex could be replaced by a suitable fetch-and-add atomic instruction, saving two potential context switches in reader's code.

I should implement this, convince myself that it's right, and profile its performance against the old version.

You might argue that doing this the more clever way makes the code less maintainable, that it might accidentally have a bug that would be a lot harder to find. This is possible, although I might argue in response that the logic should never need to be changed, so if I get it right, it will be right forever. We'll have to see how much of a performance improvement it is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-concurrencyArea: ConcurrencyI-slowIssue: Problems and improvements with respect to performance of generated code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions