perf(cluster): batch the console lines instead of one render per line
Every line of cluster traffic went straight to state: a spread copy of a 2000-element array, a slice copy, and a React render, per line. An RBN feed sends hundreds a second, so that was tens of MB/s of garbage in the renderer and hundreds of re-renders - and it ran whether the console was open or not, so the cost was paid for a panel nobody was looking at. Reported on an old PC where the UI had stopped responding. Lines are staged in a ref and flushed on a 200 ms timer, the same shape the spot handler already uses. The staging buffer is bounded too, so a burst longer than the console can show is not carried in full just to be sliced away on commit.
This commit is contained in:
@@ -3,10 +3,12 @@
|
|||||||
"version": "0.24.1",
|
"version": "0.24.1",
|
||||||
"date": "",
|
"date": "",
|
||||||
"en": [
|
"en": [
|
||||||
|
"Performance: the DX-cluster console no longer drags the whole interface down. Every line of traffic — spots, MOTD, everything — was applied to the screen one at a time, and an RBN feed alone sends hundreds a second: that meant two copies of a 2000-line buffer and a redraw for each one, whether the console was open or not. Lines are now grouped and applied five times a second. The difference is most visible on an older PC, where this alone could make the app crawl.",
|
||||||
"Update: \"stage current exe: … Accès refusé\" is fixed. Two causes, both handled. The previous build was always staged under the same name, so one leftover that could not be deleted — an antivirus holding it open is the usual reason — blocked every later update, permanently, with no way out but deleting the file by hand; the staging name is now unique. And when the running program cannot be renamed at all, which some endpoint protection deliberately prevents, OpsLog no longer gives up: it leaves the new build beside the old one and swaps them after closing, when its own file is an ordinary file again. If even that fails, OpsLog restarts on the current version rather than leaving you with nothing, and the download is kept for the next attempt.",
|
"Update: \"stage current exe: … Accès refusé\" is fixed. Two causes, both handled. The previous build was always staged under the same name, so one leftover that could not be deleted — an antivirus holding it open is the usual reason — blocked every later update, permanently, with no way out but deleting the file by hand; the staging name is now unique. And when the running program cannot be renamed at all, which some endpoint protection deliberately prevents, OpsLog no longer gives up: it leaves the new build beside the old one and swaps them after closing, when its own file is an ordinary file again. If even that fails, OpsLog restarts on the current version rather than leaving you with nothing, and the download is kept for the next attempt.",
|
||||||
"Band map: the width can be dragged. Both the map docked beside the tables and the per-band cards in the Band map tab were locked at a fixed width, so an operator watching a busy band could not give the map more room — nor take it back for the log. Grab the edge to resize, double-click it to go back to the default. The width is remembered and travels with your data folder, like the other layout settings. In the tab, one width applies to every card: they sit side by side, and columns of different widths read as a mistake."
|
"Band map: the width can be dragged. Both the map docked beside the tables and the per-band cards in the Band map tab were locked at a fixed width, so an operator watching a busy band could not give the map more room — nor take it back for the log. Grab the edge to resize, double-click it to go back to the default. The width is remembered and travels with your data folder, like the other layout settings. In the tab, one width applies to every card: they sit side by side, and columns of different widths read as a mistake."
|
||||||
],
|
],
|
||||||
"fr": [
|
"fr": [
|
||||||
|
"Performance : la console du cluster DX ne plombe plus toute l'interface. Chaque ligne de trafic — spots, MOTD, tout — était appliquée à l'écran une par une, et un flux RBN en envoie à lui seul des centaines par seconde : cela faisait deux copies d'un tampon de 2000 lignes et un redessin pour chacune, que la console soit ouverte ou non. Les lignes sont désormais groupées et appliquées cinq fois par seconde. La différence se voit surtout sur un PC ancien, où cela suffisait à faire ramer l'application.",
|
||||||
"Mise à jour : le « stage current exe : … Accès refusé » est corrigé. Deux causes, traitées toutes les deux. L'ancienne version était toujours mise de côté sous le même nom : un seul reliquat impossible à supprimer — un antivirus qui le garde ouvert, le plus souvent — bloquait définitivement toutes les mises à jour suivantes, sans autre issue que d'effacer le fichier à la main ; ce nom est désormais unique. Et quand le programme en cours d'exécution ne peut pas être renommé du tout, ce que certaines protections empêchent volontairement, OpsLog n'abandonne plus : il laisse la nouvelle version à côté de l'ancienne et les échange après sa fermeture, quand son propre fichier redevient un fichier ordinaire. Si même cela échoue, OpsLog redémarre sur la version actuelle plutôt que de te laisser sans rien, et le téléchargement est conservé pour la prochaine tentative.",
|
"Mise à jour : le « stage current exe : … Accès refusé » est corrigé. Deux causes, traitées toutes les deux. L'ancienne version était toujours mise de côté sous le même nom : un seul reliquat impossible à supprimer — un antivirus qui le garde ouvert, le plus souvent — bloquait définitivement toutes les mises à jour suivantes, sans autre issue que d'effacer le fichier à la main ; ce nom est désormais unique. Et quand le programme en cours d'exécution ne peut pas être renommé du tout, ce que certaines protections empêchent volontairement, OpsLog n'abandonne plus : il laisse la nouvelle version à côté de l'ancienne et les échange après sa fermeture, quand son propre fichier redevient un fichier ordinaire. Si même cela échoue, OpsLog redémarre sur la version actuelle plutôt que de te laisser sans rien, et le téléchargement est conservé pour la prochaine tentative.",
|
||||||
"Band map : la largeur se règle à la souris. La carte ancrée à côté des tableaux et les cartes par bande de l'onglet Band map étaient figées à une largeur fixe : impossible de donner plus de place à la carte sur une bande chargée, ni de la reprendre pour le journal. Attrape le bord pour redimensionner, double-clic pour revenir au défaut. La largeur est mémorisée et voyage avec ton dossier de données, comme les autres réglages de disposition. Dans l'onglet, une seule largeur vaut pour toutes les cartes : elles sont côte à côte, et des colonnes de largeurs différentes se lisent comme une erreur."
|
"Band map : la largeur se règle à la souris. La carte ancrée à côté des tableaux et les cartes par bande de l'onglet Band map étaient figées à une largeur fixe : impossible de donner plus de place à la carte sur une bande chargée, ni de la reprendre pour le journal. Attrape le bord pour redimensionner, double-clic pour revenir au défaut. La largeur est mémorisée et voyage avec ton dossier de données, comme les autres réglages de disposition. Dans l'onglet, une seule largeur vaut pour toutes les cartes : elles sont côte à côte, et des colonnes de largeurs différentes se lisent comme une erreur."
|
||||||
]
|
]
|
||||||
|
|||||||
+32
-4
@@ -1413,14 +1413,42 @@ export default function App() {
|
|||||||
const [clusterLines, setClusterLines] = useState<ClusterLine[]>([]);
|
const [clusterLines, setClusterLines] = useState<ClusterLine[]>([]);
|
||||||
const [clusterConsoleOpen, setClusterConsoleOpen] = useState(false);
|
const [clusterConsoleOpen, setClusterConsoleOpen] = useState(false);
|
||||||
const clusterConsoleRef = useRef<HTMLDivElement | null>(null);
|
const clusterConsoleRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
// Console lines are STAGED and flushed on a timer, never applied one by one.
|
||||||
|
//
|
||||||
|
// Every line of cluster traffic reaches this handler — spots, MOTD, WHO, the
|
||||||
|
// lot — and an RBN feed alone puts out hundreds a second. Committing each one
|
||||||
|
// meant two copies of a 2000-element array (spread, then slice) plus a React
|
||||||
|
// render PER LINE: tens of megabytes of garbage per second, and the renders
|
||||||
|
// happened even with the console closed, so an operator paid for a panel they
|
||||||
|
// were not looking at. On an older machine that is enough to make the whole UI
|
||||||
|
// crawl. Batching turns hundreds of updates a second into five.
|
||||||
|
const pendingLinesRef = useRef<ClusterLine[]>([]);
|
||||||
|
const pendingLineTimer = useRef<number | undefined>(undefined);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const off = EventsOn('cluster:line', (l: any) => {
|
const flushLines = () => {
|
||||||
|
pendingLineTimer.current = undefined;
|
||||||
|
const batch = pendingLinesRef.current;
|
||||||
|
if (batch.length === 0) return;
|
||||||
|
pendingLinesRef.current = [];
|
||||||
setClusterLines((prev) => {
|
setClusterLines((prev) => {
|
||||||
const next = [...prev, l as ClusterLine];
|
const total = prev.length + batch.length;
|
||||||
return next.length > CONSOLE_CAP ? next.slice(next.length - CONSOLE_CAP) : next;
|
return total > CONSOLE_CAP ? prev.slice(total - CONSOLE_CAP).concat(batch) : prev.concat(batch);
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
const off = EventsOn('cluster:line', (l: any) => {
|
||||||
|
const buf = pendingLinesRef.current;
|
||||||
|
buf.push(l as ClusterLine);
|
||||||
|
// Bound the staging buffer too: a burst longer than the console can show
|
||||||
|
// would otherwise be carried in full just to be sliced away on commit.
|
||||||
|
if (buf.length > CONSOLE_CAP) buf.splice(0, buf.length - CONSOLE_CAP);
|
||||||
|
if (pendingLineTimer.current === undefined) {
|
||||||
|
pendingLineTimer.current = window.setTimeout(flushLines, 200);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return () => { off?.(); };
|
return () => {
|
||||||
|
off?.();
|
||||||
|
if (pendingLineTimer.current !== undefined) window.clearTimeout(pendingLineTimer.current);
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
// Follow the tail, but ONLY when already at the bottom — otherwise scrolling up
|
// Follow the tail, but ONLY when already at the bottom — otherwise scrolling up
|
||||||
// to read a SH/DX reply would yank you back down on the next spot.
|
// to read a SH/DX reply would yank you back down on the next spot.
|
||||||
|
|||||||
Reference in New Issue
Block a user