Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tfsdklog: Introduce outside context level checks for logging functions (
#149) 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.
- Loading branch information