clockworklabs / clockworklabs/SpacetimeDB

Some convenient interface for determining the energy cost of individual reducer runs

Open
#1,943 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
25.2k
Forks
1.1k
Avg merge
2d 7h
Merged PRs (30d)
46

Description

Whenever we run a reducer, we should give the module owner / developer some interface to determine how much energy it consumed. Note that this information is exposed via the WebSocket API (at least as of writing, pgoldman 2024-08-08), but not passed through to the SDKs. Exposing it in the SDKs is not necessarily the most useful place for it, and we should consider whether we want non-owners / anonymous clients to be able to access this information. Likely there should be some way to get this from the CLI. The simplest version is probably having the host log to the module/database's logs after each reducer run with the reducer name, arguments (truncated to some reasonable length), caller identity and address, exit status and energy consumed; then developers could use the spacetime logs CLI command to access it. A slightly better version might be to keep that data in a separate file, to be queried by a different CLI command. More interesting would be to additionally provide percentiles, averages, maximum energy values, cumulative costs, &c for individual reducers and for the whole module.

This data might be exposed via Prometheus / Grafana already for web dashboard users, but it should additionally be available via the CLI for standalone users, though that interface may be less user friendly and provide less analysis.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing WebSocket API and any Prometheus/Grafana exposure for reducer energy data. Compare those interfaces with the proposed host logging and spacetime logs approach, including access for owners, anonymous clients, and standalone users. Done requires a decided, documented interface for retrieving per-reducer energy costs.

Written by the indexing model from the issue text.

Assessment

Tech stack
grafana, prometheus, rust
Domain
backend, cli, observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.