Top wears the skin; the refresh rate reaches every machine; bug bash 4
The process table's columns fit the box they are in, the rate control saves, curves are timed on the viewer's clock and keep to the stride, the power icon is drawn, and a young history draws in from the right instead of being stretched. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
ef3dbdf543
commit
668e716601
@@ -32,15 +32,15 @@ const (
|
||||
DefaultInterval = 2 * time.Second
|
||||
MinInterval = 100 * time.Millisecond
|
||||
MaxInterval = 10 * time.Second
|
||||
History = 300 // points kept per curve; the window below sets how far apart they are
|
||||
History = 300 // points kept per curve; the window below sets how far apart they are
|
||||
// How far back the kept history reaches. The point count is fixed, so this sets the spacing:
|
||||
// at a minute every sample is its own point, at a day each point is the average of ~5 minutes.
|
||||
DefaultWindow = 10 * time.Minute
|
||||
MinWindow = 1 * time.Minute
|
||||
MaxWindow = 24 * time.Hour
|
||||
fsEvery = 30 * time.Second // filesystem usage changes slowly and statfs on network mounts isn't free
|
||||
upsEvery = 10 * time.Second // UPS daemons are an exec each; don't hammer them at fast intervals
|
||||
sectorSize = 512 // /proc/diskstats always counts 512-byte sectors
|
||||
fsEvery = 30 * time.Second // filesystem usage changes slowly and statfs on network mounts isn't free
|
||||
upsEvery = 10 * time.Second // UPS daemons are an exec each; don't hammer them at fast intervals
|
||||
sectorSize = 512 // /proc/diskstats always counts 512-byte sectors
|
||||
)
|
||||
|
||||
type Mem struct {
|
||||
@@ -146,6 +146,7 @@ type Collector struct {
|
||||
ring []Sample // the kept history: one point per stride, each the average of its bucket
|
||||
last Sample // the newest raw sample, whatever the stride
|
||||
bucket []Sample // samples since the last point was kept
|
||||
lastKept int64 // when that was, unix ms
|
||||
interval time.Duration
|
||||
window time.Duration
|
||||
wake chan struct{} // nudges Run when the interval changes
|
||||
@@ -271,9 +272,20 @@ func (c *Collector) stride() time.Duration {
|
||||
// two-second instant happened to land on the mark.
|
||||
func (c *Collector) keep(s Sample) {
|
||||
c.bucket = append(c.bucket, s)
|
||||
if s.T-c.bucket[0].T < c.stride().Milliseconds() && len(c.bucket) > 1 {
|
||||
// A point is due a stride after the last one (for the first, a stride after the interval its
|
||||
// first sample stands for). Half an interval of slack, because a timer never fires exactly on
|
||||
// time: without it a tick that lands 5 ms early is "not yet", and every point runs one sample
|
||||
// long. Measured from the last point kept, not by counting samples, so a machine that stalled
|
||||
// or slept simply keeps the next sample it gets.
|
||||
iv := c.interval.Milliseconds()
|
||||
since := c.lastKept
|
||||
if since == 0 {
|
||||
since = c.bucket[0].T - iv
|
||||
}
|
||||
if s.T-since < c.stride().Milliseconds()-iv/2 {
|
||||
return
|
||||
}
|
||||
c.lastKept = s.T
|
||||
c.ring = append(c.ring, fold(c.bucket))
|
||||
c.bucket = c.bucket[:0]
|
||||
c.trim()
|
||||
|
||||
Reference in New Issue
Block a user