Skip to content

cache: reduce contention in load_or_fetch by removing write lock from slow I/O paths #7

@blackopsrepl

Description

@blackopsrepl

Problem

load_or_fetch currently holds the global cache write lock while checking files, reading disk, fetching from Overpass, and writing cache files.

Why this matters

This serializes unrelated callers and can create poor concurrency under load.

Scope

  • Refactor to use double-checked insertion.
  • Consider per-key in-flight fetch deduplication.
  • Only hold the write lock for insertion/replacement.

Acceptance criteria

  • Slow I/O is performed outside the global cache write lock.
  • Concurrent callers for different regions do not block each other unnecessarily.
  • Duplicate fetches for the same region are either prevented or explicitly handled.

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