Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Logger.BeginScope with IncludeScopes = false gets performance hit #894

@snakefoot

Description

@snakefoot

Normally one can have very fast logging when registering a single LoggerProvider with IncludeScopes = false, where BeginScope returns a NullScope.

Now because of #723 then extra allocation occurs because the following optimization was removed:

if (loggers.Length == 1)
    return loggers[0].Logger.BeginScope(state);

If the LoggerProvider attempts to implement ISupportExternalScope (And has IncludeScopes = false), then the LoggerFactory will generate even more garbage-allocation because it forces creation of AsyncLocal-state that must be transferred when using async-threading-tasks.

Again if the above optimization was used, then one could skip the external-scope-provider-logic when only a single LoggerProvider (IncludeScopes = false would continue to work).

See also #714

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions