Skip to content

Cache JSON stats in memory instead of per-request file I/O #1

Description

@lbedogni

Problem
RequestHandler.handle_device_inference_result() reads device_inference_times.json and edge_inference_times.json on every request, then writes them back after EMA updates.

Impact

  • Throughput bottleneck, especially with many concurrent devices.
  • Increased latency per request.

Proposed Fix

  • Keep the inference time dictionaries in memory (module-level or singleton).
  • Flush to disk periodically (every N updates or X seconds) with atomic writes (write to temp file then rename).
  • Consider file locking if multiple processes, or consolidate to single process.

Files: src/server/communication/request_handler.py Labels: performance, P2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions