clockworklabs / SpacetimeDB

Multiplayer at the speed of light
https://spacetimedb.com
Other
4.36k stars 110 forks source link

Track energy for persistent database memory #667

Open joshua-spacetime opened 10 months ago

joshua-spacetime commented 10 months ago

We should track the persistent memory associated with tables and indexes for energy purposes. This means each table and index needs access to an EnergyMonitor for recording energy use.

If 1 eV is the amount of energy used to store 1 byte on disk for 1 second, then N eV is the amount of energy required to store 1 byte in memory for 1 second for some N. We should pick a suitable N and record, for every insert/delete, the amount of energy used per table, since the previous insert/delete.

As part of this ticket we should also write these energy recordings to prometheus.

cloutiertyler commented 10 months ago

100 is not so far from a suitable N (for context)

cloutiertyler commented 6 months ago

We would like to see the number of bytes per table so that we can track which tables have very large rows.

gefjon commented 6 months ago

We would like to see the number of bytes per table so that we can track which tables have very large rows.

It would be very easy to compute a conservative overestimate of this by simply tracking the number of pages per table in the committed state. A precise count is more challenging.

cloutiertyler commented 4 months ago

I split this ticket into https://github.com/orgs/clockworklabs/projects/22/views/38?pane=issue&itemId=47389802 as well