Skip to content

perf(page): poll the live values less often and only while they are shown - #1232

Open
karlitschek wants to merge 4 commits into
masterfrom
perf/live-polling
Open

karlitschek wants to merge 4 commits into
masterfrom
perf/live-polling

Conversation

@karlitschek

Copy link
Copy Markdown
Member

Based on feat/os-status-collector (#1214).

AI disclosure: this change was written with Claude Code (claude-opus-5-5) and is to be reviewed by the author before it leaves draft; every commit carries an Assisted-by trailer.

🤖 Generated with Claude Code

@karlitschek
karlitschek force-pushed the feat/os-status-collector branch 2 times, most recently from 6d327c2 to 34014ec Compare October 25, 2026 19:19
Base automatically changed from feat/os-status-collector to master October 25, 2026 19:24
@nextcloud-command nextcloud-command added the AI assisted This PR contains AI-assisted commits label Oct 25, 2026
karlitschek and others added 4 commits October 25, 2026 20:45
The Status page asked for /update every two seconds, and kept asking on
the Database, Background jobs and Operating system pages, because those
only hide the other pages with v-show. Each request is a full Nextcloud
request cycle, and the CPU chart plots the 1-minute load average, which
the kernel recomputes only every five seconds, so most samples repeated
the previous one.

useLiveData now polls every five seconds by default and takes an
"active" flag. The Status page passes "the Status page is shown", so the
poll pauses on the other pages and resumes with a fresh request the
moment the Status page is shown again. The pause for a hidden browser
tab and the back-off on failures stay as they were. The charts keep 60
points, which now cover five minutes.

The Database page's live charts already stopped while another page was
shown, but switching away and back while a request was under way
started a second polling loop next to the first. Both pollers now wait
for the request under way instead.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Frank Karlitschek <karlitschek@users.noreply.github.com>
Every /update read all hardware temperature sensors. Some of them wake
sleeping drives or send NVMe or ATA commands, which a page polling every
few seconds should not trigger, and temperatures change slowly anyway.

LiveData keeps the readings in the local memory cache for 15 seconds.
The cache is per host, like the sensors, and an empty list is cached
too, so a host without sensors is not scanned again on every request.
The payload is unchanged, so the Temperature section keeps refreshing
on its own, just less often. Without a local memory cache configured
the sensors are read on every request as before.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Frank Karlitschek <karlitschek@users.noreply.github.com>
The Database page polls /database/live every three seconds. Each request
called DatabaseProbe::ping() and LiveMetrics::collect(), and each of
them opened its own connection (a fresh TCP connection with a database
override) and detected the database type with a query of its own. The
latency was timed over SHOW TABLES, or a pg_tables scan on PostgreSQL,
so it grew with the number of tables rather than showing the round trip.
PostgreSQL then queried pg_stat_activity twice and pg_settings once for
the connection counts.

LiveMetrics::collect() now builds the whole response over one
connection whose type is detected once: it times SELECT 1 on that
connection, and on PostgreSQL reads used, active and maximum connections
in one query with count(*) FILTER. A database the probe does not support
is not queried further. The JSON is unchanged; the cache hit ratio,
which collect() computed but the endpoint never returned, is no longer
read. ping() had no other caller and is gone.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Frank Karlitschek <karlitschek@users.noreply.github.com>
Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Frank Karlitschek <karlitschek@users.noreply.github.com>
@karlitschek
karlitschek marked this pull request as ready for review October 25, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI assisted This PR contains AI-assisted commits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants