Performance Optimization

This guide covers techniques to maximize UESynth performance for different use cases, from simple data collection to high-throughput real-time simulations.

Performance Overview

UESynth performance varies significantly based on client type and usage patterns:

Client Type
Typical Performance
Best Use Case

Sync Client

10-50 requests/sec

Simple scripts, prototyping

Async Client (Direct)

50-200 requests/sec

Medium-scale batch processing

Async Client (Streaming)

100-1000+ requests/sec

High-performance real-time sims

Async Client Optimization

1. Choose the Right Mode

from uesynth import AsyncUESynthClient

# ๐Ÿš€ Streaming mode - highest performance
async def streaming_mode():
    async with AsyncUESynthClient() as client:
        # Non-blocking operations
        request_id = await client.capture.rgb()  # Returns immediately
        frame = await client.get_latest_frame()  # Get when ready

# ๐Ÿ“Š Direct mode - medium performance, easier to use
async def direct_mode():
    async with AsyncUESynthClient() as client:
        # Blocking operations
        frame = await client.capture.rgb_direct()  # Waits for result

2. Optimize Buffer Settings

3. Batch Operations

Network Optimization

1. Compression

2. Image Resolution

3. Network Configuration

Memory Optimization

1. Frame Management

2. Capture Only What You Need

CPU Optimization

1. Concurrent Processing

2. Optimize Frame Processing

Real-Time Optimization

1. Frame Rate Management

2. Predictive Frame Requests

Benchmarking and Monitoring

1. Performance Measurement

2. Resource Monitoring

Configuration Recommendations

Development Environment

Production Environment

High-Throughput Scenarios

Troubleshooting Performance

Common Issues and Solutions

  1. Low FPS / High Latency

    • Use async streaming mode instead of direct mode

    • Increase buffer sizes

    • Enable compression

    • Reduce image resolution

  2. Memory Usage Growing

    • Process frames immediately instead of accumulating

    • Use smaller capture resolutions

    • Reduce buffer sizes

  3. Network Bottlenecks

    • Enable compression

    • Optimize image formats (JPEG vs PNG)

    • Use appropriate resolution for use case

  4. CPU Bottlenecks

    • Use thread pools for processing

    • Optimize frame processing algorithms

    • Reduce capture frequency

By following these optimization techniques, you can achieve maximum performance for your specific UESynth use case, whether it's simple data collection or high-throughput real-time simulation.

Next Steps

Last updated