Skip to content

[Bug] : Duplicate Model Training Optimization: Implement Caching for Calibration Validation #73

@sohampirale

Description

@sohampirale

Issue Description

Currently, the calibration validation endpoint (/api/session/calib_validation) performs the same expensive model training computation for both requests with from_ruxailab: false and from_ruxailab: true. This results in unnecessary duplicate computation since both requests use identical input parameters and should produce identical results.


Current Flow

  1. Frontend sends first request with from_ruxailab: false
  2. Backend calls gaze_tracker.predict() → performs full model training
  3. Frontend sends second request with from_ruxailab: true
  4. Backend calls gaze_tracker.predict() again → performs identical model training
  5. Second request additionally sends results to Firebase webhook
Image

Impact

  • Performance: Double the computational cost for identical operations
  • Resource Usage: Unnecessary CPU cycles and memory consumption

Proposed Solution

Implement a caching mechanism to store the results of gaze_tracker.predict() and reuse them for subsequent requests with identical parameters.

Image

Caching Options Under Discussion

There are ongoing discussions about the best caching approach:

  1. In-memory caching (LRU cache, file-based)
  2. Shared memory solutions for multi-process environments
  3. External caching services (Redis, etc.)

Related Discussions

Related Issue : #61
Related PR : #68


Request for Input

Appreciate the guidance from maintainers on:

  1. Preferred caching mechanism for this use case
  2. Configuration parameters (cache size, TTL, etc.)
  3. Multi-process deployment considerations

Expected Benefits

  • Significant reduction in computational overhead
  • Faster response times for calibration validation
  • Better resource utilization
  • Improved user experience during calibration process

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions