Skip to content

_LOCK_LOCALE causes unavoidable multi-threaded contention on most basic_ostream functionality #1831

Open

Description

Various operations within locale code use _LOCK_LOCALE to take a global lock. Because most basic_ostream methods hit this locale code (e.g. via use_facet), this means that most basic_ostream operations also end up taking a global lock.

The net effect of this as we discovered in our heavily multithreaded code base is that basic_ostream is completely non performant. It doesn't matter if you carefully manage your output streams (e.g. one per thread), you end up hitting contention on this global lock across all threads.

Is there a solution to this other than avoiding basic_ostream in multi threaded code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    performanceMust go fastervNextBreaks binary compatibility

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions