Skip to content

perf: circular buffer, parallel RPC, and observer cleanup#248

Merged
jongio merged 1 commit into
mainfrom
patrol/perf-improvements
May 18, 2026
Merged

perf: circular buffer, parallel RPC, and observer cleanup#248
jongio merged 1 commit into
mainfrom
patrol/perf-improvements

Conversation

@jongio
Copy link
Copy Markdown
Owner

@jongio jongio commented May 18, 2026

Performance improvements

1. O(1) circular buffer for log buffers

Replace O(n) slice shifting (buf = append(buf[:0], buf[1:]...)) with a proper ring buffer using head/count index tracking. Affected types:

  • service.LogBuffer: main log buffer used by all services
  • localLogRing in rpc/logs.go: streaming log ring
  • localAzureLogRing in rpc/azure_stream.go: Azure streaming ring

Fixes #211

2. Parallel per-service RPC calls in GetAzureLogs

The dashboard client's GetAzureLogs now launches concurrent RPCs (via errgroup) when multiple services are requested, instead of issuing them sequentially. Single-service requests take a fast path with no goroutine overhead.

Fixes #212

3. MutationObserver and timer cleanup on Astro page transitions

Added astro:before-swap handlers (with { once: true }) to disconnect MutationObservers, remove media query listeners, and clear autoplay timers before Astro swaps the DOM. Affected components:

  • Lightbox.astro: disconnects observer, removes window globals
  • Screenshot.astro: disconnects observer, removes media query listener
  • DashboardCarousel.astro: clears autoplay interval timer

Fixes #214

- Replace O(n) slice shifting with O(1) ring buffer in LogBuffer,
  localLogRing, and localAzureLogRing (fixes #211)
- Parallelize per-service RPC calls in GetAzureLogs using errgroup
  for concurrent fan-out (fixes #212)
- Add astro:before-swap cleanup for MutationObserver and setInterval
  in Lightbox, Screenshot, and DashboardCarousel components (fixes #214)
@jongio jongio merged commit 1d7b88a into main May 18, 2026
9 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant