Description
BaseCondition.ToString() serializes on every log-message construction (BaseCondition.cs):
public override string ToString() => JsonConvert.SerializeObject(this, Formatting.None);
It's used inside interpolated strings like $@"Audience condition {this} evaluated to UNKNOWN...", which C# evaluates eagerly before logger.Log(LogLevel.DEBUG, ...) is called. So even with logging disabled, you pay a JsonConvert.SerializeObject per condition on many paths (Evaluate, ExactEvaluator, NumberEvaluator, SubstringEvaluator, ...). This is a real hot-path cost.
Consider gating the log calls behind a level check so the interpolation doesn't run, or cache the serialized condition.
Benefits
Less allocations and resource utilization and feature flags can be used in hot paths.
Detail
No response
Examples
No response
Risks/Downsides
No response
Description
BaseCondition.ToString()serializes on every log-message construction (BaseCondition.cs):It's used inside interpolated strings like
$@"Audience condition {this} evaluated to UNKNOWN...", which C# evaluates eagerly beforelogger.Log(LogLevel.DEBUG, ...)is called. So even with logging disabled, you pay aJsonConvert.SerializeObjectper condition on many paths (Evaluate,ExactEvaluator,NumberEvaluator,SubstringEvaluator, ...). This is a real hot-path cost.Consider gating the log calls behind a level check so the interpolation doesn't run, or cache the serialized condition.
Benefits
Less allocations and resource utilization and feature flags can be used in hot paths.
Detail
No response
Examples
No response
Risks/Downsides
No response