sifive / wake

The SiFive wake build tool
Other
86 stars 28 forks source link

rsc: Add json route that returns stats #1598

Closed V-FEXrt closed 1 month ago

V-FEXrt commented 2 months ago

This PR adds another route to the rsc GET /dashboard which returns a json object summarizing basic stats about the cache.

A follow up PR will be added that renders it (somewhat) nicely as an HTML page

Example response:

{
  "job_count": 1234,
  "blob_count": 9999,
  "size": 1000000000,
  "savings": 5432,
  "oldest_jobs": [
    {
      "label": "echo foo",
      "created_at": "2024-07-16T18:02:01.083651",
      "savings": 5
    }
  ],
  "most_reused_jobs": [
    {
      "label": "echo foo",
      "reuses": 2,
      "savings": 5
    }
  ],
  "most_space_efficient_jobs": [
    {
      "label": "foo bar",
      "runtime": 1,
      "disk_usage": 50,
      "ms_saved_per_byte": 50
    }
  ],
  "most_space_use_jobs": [
    {
      "label": "foo bar",
      "runtime": 1,
      "disk_usage": 50,
      "ms_saved_per_byte": 50
    }
  ],
  "lost_opportunity_jobs": [
    {
      "label": "foo bar",
      "reuses": 1,
      "misses": 50,
      "real_savings": 1,
      "potential_savings": 51
    }
  ]
}