Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tfsdklog: Introduce outside context level checks for logging functions #149

Merged
merged 1 commit into from
May 31, 2023

Commits on Apr 19, 2023

  1. tfsdklog: Introduce outside context level checks for logging functions

    Reference: hashicorp/terraform-plugin-framework#721
    
    This change introduces log level checks outside the `context.Context` of a request to improve the performance of logging functions when logs would not be emitted at the configured level. Almost exclusively, logging levels are not expected to change during provider (and therefore SDK) runtime since they are environment variable driven. Even if they did, this level check will either immediately constrict logging to match an updated higher level or cause additional `context.Context` reads with an updated lower level, which is no different than the current behavior.
    
    The following benchmark was ran prior to the introduction of the level checks and mutexes:
    
    ```
    BenchmarkSubsystemTraceDisabled-10            4616656               258.0 ns/op
    BenchmarkSubsystemTraceEnabled-10              936865              1138 ns/op
    ```
    
    After the addition of level checks and mutexes:
    
    ```
    BenchmarkSubsystemTraceDisabled-10           86043471                13.78 ns/op
    BenchmarkSubsystemTraceEnabled-10              906649              1137 ns/op
    ```
    
    This enhancement could also be considered for provider loggers, however SDK logging tends to be more prevalent in practice, so this only targets the `tfsdklog` package handling.
    bflad committed Apr 19, 2023
    Configuration menu
    Copy the full SHA
    8b54451 View commit details
    Browse the repository at this point in the history