Skip to main content
Version: Latest

Logging Performance Guide

Performance Impactโ€‹

The Brobot logging system is designed for minimal performance impact:

  • Disabled logging: ~0 overhead (early filtering)
  • INFO level logging: ~1-2ms per action
  • DEBUG level with enrichment: ~3-5ms per action
  • With screenshots: ~50-100ms per failed action

Optimization Strategiesโ€‹

1. Early Filteringโ€‹

The system checks log levels before building log entries:

import io.github.jspinak.brobot.logging.BrobotLogger;
import io.github.jspinak.brobot.logging.LogCategory;
import io.github.jspinak.brobot.logging.LogLevel;

public class PerformanceExample {
private final BrobotLogger logger;

public void performAction() {
// Level check happens first - no object creation if disabled
if (logger.isLoggingEnabled(LogCategory.ACTIONS, LogLevel.DEBUG)) {
// Only build the log entry if it will be logged
logger.debug(LogCategory.ACTIONS,
"Expensive operation: " + generateExpensiveReport());
}
}

private String generateExpensiveReport() {
// Expensive operation
return "Report data";
}
}

Note: The isLoggingEnabled() method in Brobot currently delegates all level checking to SLF4J/Logback. This means actual filtering happens at the SLF4J level based on logging.level.* properties. The pattern above is still recommended to avoid expensive string building operations when logging is disabled.

2. Async Loggingโ€‹

Enable async logging for production:

# Async logging improves throughput
brobot.logging.performance.async=true
brobot.logging.performance.buffer-size=16384

Benefits:

  • Non-blocking log writes
  • Better application throughput
  • Reduced I/O contention

Trade-offs:

  • Potential log loss on crash
  • Slightly delayed log visibility
  • Additional memory usage

3. Selective Enrichmentโ€‹

Only enable enrichment you need:

# Minimal enrichment for production
brobot.logging.enrichment.include-screenshots=false
brobot.logging.enrichment.include-timing-breakdown=false
brobot.logging.enrichment.include-memory-usage=false
brobot.logging.enrichment.include-similarity-scores=true # Low overhead

Note: include-timing-breakdown defaults to true in source code, but is typically disabled in production for optimal performance. The default enables comprehensive timing data during development, which can then be selectively disabled for deployment.

4. Category-Specific Levelsโ€‹

Reduce noise by setting appropriate levels per package:

# Production configuration
logging.level.io.github.jspinak.brobot.action=INFO # Only success/failure
logging.level.io.github.jspinak.brobot.matching=WARN # Only problems
logging.level.io.github.jspinak.brobot.performance=INFO # Key metrics only
logging.level.io.github.jspinak.brobot.validation=ERROR # Only errors

Available Log Levels (in order of severity):

  • OFF - Disable all logging (maximum performance)
  • ERROR - Only errors requiring attention
  • WARN - Warnings and potential issues
  • INFO - Key events and action results
  • DEBUG - Detailed debugging information
  • TRACE - Most detailed information (highest overhead)

Memory Managementโ€‹

Buffer Sizesโ€‹

Configure buffer sizes based on load:

# Light load (< 100 actions/min)
brobot.logging.performance.buffer-size=8192

# Medium load (100-1000 actions/min)
brobot.logging.performance.buffer-size=32768

# Heavy load (> 1000 actions/min)
brobot.logging.performance.buffer-size=65536

Memory Usage Estimatesโ€‹

ConfigurationMemory per ThreadBuffer MemoryTotal (10 threads)
Minimal~1KB8KB~18KB
Standard~2KB32KB~52KB
Full Enrichment~5KB64KB~114KB

Benchmarksโ€‹

Action Logging Performanceโ€‹

Test setup: 1000 find operations, averaged over 10 runs

Log LevelSync (ms/action)Async (ms/action)
OFF0.00.0
ERROR0.10.05
INFO1.20.3
DEBUG2.50.8
TRACE4.11.5

With Enrichmentโ€‹

FeatureAdditional Overhead
Similarity scores+0.1ms
Timing breakdown+0.5ms
Memory usage+1.0ms
Screenshots (on failure)+50-100ms

Best Practices for Performanceโ€‹

1. Production Configurationโ€‹

# Optimized for production
logging.level.root=WARN
logging.level.io.github.jspinak.brobot.action=INFO
logging.level.io.github.jspinak.brobot.performance=INFO
brobot.logging.output.format=JSON
brobot.logging.performance.async=true
brobot.logging.performance.buffer-size=32768
brobot.logging.enrichment.include-screenshots=false
brobot.logging.enrichment.include-timing-breakdown=false

2. Development Configurationโ€‹

# Full visibility for development
logging.level.root=DEBUG
logging.level.io.github.jspinak.brobot=DEBUG
brobot.logging.output.format=SIMPLE
brobot.logging.performance.async=false
brobot.logging.enrichment.include-screenshots=true
brobot.logging.enrichment.include-timing-breakdown=true

3. High-Performance Configurationโ€‹

# Maximum performance
logging.level.root=ERROR
brobot.logging.performance.async=true
brobot.logging.performance.buffer-size=65536
brobot.logging.output.format=JSON
# Disable all enrichment
brobot.logging.enrichment.include-screenshots=false
brobot.logging.enrichment.include-similarity-scores=false
brobot.logging.enrichment.include-timing-breakdown=false
brobot.logging.enrichment.include-memory-usage=false

Monitoring Logging Performanceโ€‹

Enable Performance Loggingโ€‹

To monitor application performance (not logging system overhead):

logging.level.io.github.jspinak.brobot.performance=DEBUG
brobot.logging.enrichment.include-timing-breakdown=true

This enables logging of:

  • Action execution times
  • State transition durations
  • Pattern matching performance
  • Memory usage statistics

Note: Brobot currently logs application performance metrics (action durations, memory usage) but does not yet track logging system overhead itself (log formatting time, write time, etc.). The performance benchmarks in this document are based on external measurements.

Troubleshooting Performance Issuesโ€‹

Symptoms: High CPU Usageโ€‹

Cause: Too much DEBUG/TRACE logging Solution: Reduce log levels

logging.level.root=INFO
logging.level.io.github.jspinak.brobot=WARN

Symptoms: Memory Growthโ€‹

Cause: Large async buffers with slow I/O Solution: Reduce buffer size or disable async

brobot.logging.performance.async=false
# OR
brobot.logging.performance.buffer-size=8192

Symptoms: Slow Action Executionโ€‹

Cause: Screenshot capture on every action Solution: Disable screenshots

brobot.logging.enrichment.include-screenshots=false

Symptoms: Log File Growthโ€‹

Cause: TRACE level or JSON format Solution: Use appropriate levels and consider log rotation

logging.level.root=INFO
# Configure logback for rotation

Logging Systemโ€‹

  • Logging Overview - Introduction to Brobot's transparent, configuration-driven logging system
  • Logging Configuration Guide - Comprehensive configuration options for output formats, enrichment, and performance settings
  • Logging Usage Guide - How to use custom logging with ActionConfig methods and session management
  • Output Formats - Detailed guide to SIMPLE, STRUCTURED, and JSON output formats with performance implications

Configuration & Propertiesโ€‹

Testing & Debuggingโ€‹

Action Configurationโ€‹

Getting Startedโ€‹

Advanced Topicsโ€‹

Integrationโ€‹