Skip to content

Commit 2abca1c

Browse files
committed
firewall: live view: optimize viewbuffer rendering
Using addData + remove will costs quite some rendering time. Doing a clear() instead, and then immediately rendering the current state of the viewbuffer seems to be a lot faster. This also makes sure that we aren't inserting rows beyond the bufferSize limit, which serve no purpose, as these have to be removed anyway.
1 parent 6f6a394 commit 2abca1c

File tree

1 file changed

+8
-24
lines changed
  • src/opnsense/mvc/app/views/OPNsense/Diagnostics

1 file changed

+8
-24
lines changed

src/opnsense/mvc/app/views/OPNsense/Diagnostics/fw_log.volt

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@
266266
}
267267
break;
268268
case 'pushMany':
269-
event.data.reverse();
270269
const tmp = event.data.filter(record => this._passesCurrentFilters(record));
271270
this.viewBuffer.pushMany(tmp);
272271
break;
@@ -279,29 +278,17 @@
279278
* mutated on the viewbuffer is considered valid (passed the filter(s)).
280279
*/
281280
_onViewBufferEvent(event) {
282-
// also investigate setData instead of addDate + remove
283281
switch (event.type) {
284282
case 'push':
285-
this.table.addData([event.data], true);
286-
break;
287283
case 'pushMany':
288-
this.table.addData(event.data.reverse(), true);
289-
break;
290284
case 'reset':
291-
let tmp = this.viewBuffer.toArray();
292-
this.table.addData(tmp, true);
285+
this.table.clearData();
286+
this.table.setData(this.viewBuffer.toArray());
293287
break;
294288
case 'clear':
295289
this.table.clearData();
296290
break;
297291
}
298-
299-
let rows = this.table.getRows();
300-
if (this.viewBuffer.length >= this.bufferSize && rows.length > this.bufferSize) {
301-
for (let i = this.bufferSize; i < rows.length; i++) {
302-
rows[i].delete();
303-
}
304-
}
305292
}
306293

307294
_hashFilter({field, operator, value}) {
@@ -454,14 +441,11 @@
454441
}
455442

456443
/**
457-
*
444+
* Update existing records in the table. Records supplied but not found in
445+
* the table (indexed by __digest__) are ignored.
458446
*/
459447
updateTable(records) {
460-
try {
461-
this.table.updateData(records, true);
462-
} catch (e) {
463-
// ignore
464-
}
448+
this.table.updateData(records).catch((error) => {});
465449
}
466450

467451
setFilterMode(mode = 'AND') {
@@ -540,8 +524,8 @@
540524
if (!hostnames.get(record.dst)) hostnames.set(record.dst, null);
541525

542526
// make sure the hostname key exists
543-
record['srchostname'] = hostnames.get(record.src);
544-
record['dsthostname'] = hostnames.get(record.dst);
527+
record['srchostname'] = hostnames.get(record.src) || '<span class="fa fa-spinner fa-pulse"></span>';
528+
record['dsthostname'] = hostnames.get(record.dst) || '<span class="fa fa-spinner fa-pulse"></span>';
545529
}
546530

547531
resolve(data);
@@ -962,7 +946,7 @@
962946
}
963947

964948
bufferDataUnsubscribe = buffer.subscribe((event) => {
965-
// register to active data feed, apply hostnames as they come
949+
// register to active data feed (all data), apply hostnames as they come
966950
if (event.type === "push" || event.type === "pushMany") {
967951
let records = Array.isArray(event.data) ? event.data : [event.data];
968952
records.map((record) => {

0 commit comments

Comments
 (0)