Starweb dev log #14
Analytics got a range picker, and the drawing underneath it got a lot cheaper to run.
The panel graphs now go from 1h up to 1y, not just a fixed 14 days. That needed a second counter: stats_min, one document per domain per minute, which only exists to answer the sub-day windows and ages out on a TTL index. The old daily stats collection stays forever so the all-time total is still exact. Past a month the buckets widen to weeks then 30-day chunks, since 180 daily points would just read as a smear at chart width.
The nebula background got refactored for speed: prep() runs once per canvas resize and does all the expensive math, square roots, atan2, walking every line segment, into a flat array; lit() runs per frame and just reads that array plus whatever actually changes frame to frame (the shine position, the cog’s rotation). Same picture, way less work per frame. Hex color parsing got a fast path too, since a canvas setting fillStyle per dot was hitting the full color parser thousands of times a frame for the one form it ever uses.
Canvas itself grew a few things: fillRect/strokeRect take an optional radius now, measureText reads the actual font the page pushed instead of the UI default, and hoverX/hoverY are readable off a canvas element. The ctx method lookup also switched from a chain of strcmp to a real table, since a heavy canvas loop calls into it constantly.
requestAnimationFrame self-paces now. A callback that runs long gets a gap after it sized to what it just cost, capped at 500ms, so one expensive canvas can’t eat the whole frame budget. It also only fires for the visible tab and stops while the window’s minimized; timers and fetches keep going regardless, same as a background tab in a real browser.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.