Skip to content

Record cache statistics #19

@dimo414

Description

@dimo414

It would be nice to log statistics about cached invocations, such as execution durations and hits vs. misses. This could be used to optimize TTLs and observe unexpected cache misses.

Any such logging should be opt-in at the call site - e.g. behind a --log_statistics flag - and ideally also gated by a Cargo feature (though the feature could be enabled by default as long as it doesn't incur too much overhead).

I'm envisioning writing to an append-only file in the cache directory and using a simple schema such as a TSV. Columns might include:

  • Timestamp
  • Scope
  • Command name (i.e. argv-0)
  • Full command line
  • cwd
  • Parent PID
  • Hit / miss / force / refresh (i.e. executed asynchronously via --warm or --stale)
  • Exit status
  • Execution time (0 for hits)
  • Remaining TTL (0 for misses)
  • Remaining TTStale (0 for misses)

It would be nice to find some prior art of other CLI tools that log local statistics like this. statsd could be a reasonable choice but it requires more bootstrapping on the part of the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions