perf(library): send the track list as a dictionary-encoded column table

GetTracks answered with one JSON object per track: 20.5 MB at 26k
tracks, ~350 bytes a row of repeated key names, four cover URLs that
are identical across an album, and the album, artist and genre strings
repeated on every track. Encoding it was ~170 MB of transient Go
allocation, and parsing it the WebView's memory peak.

GetTrackTable replaces it: one array per column, every repeated
string stored once and sent as an index, genre lists interned, and only
the fields the Tracks view reads. LastPlayed and the three larger cover
tiers are left to the details dialog, which now fetches whole tracks by
path. Each row still goes through trackFromRow, so this is an encoding
of the one projection, not a second one. 167 bytes a track against 929
in the test library; a Go test holds it under a quarter of the object
encoding, and a Vitest test reads the Go columns and the generated
Track interface and fails if they drift.

An empty library is now an empty table rather than the "no tracks in
library" error the old binding returned.

Closes #281
This commit is contained in:
yonlu committed 2026-10-05 23:30:37 -04:00
1 parent 4a9fe1d207
commit 7a1412383f
42 files changed
+1011 -275

No files matched your search

+6 -5
View File
@@ -20,6 +20,7 @@ import { emit, stub, flush, resetHarness } from '@test/support/harness';
import { Events } from '../../src/events';
import { fixture, shadow, shadowAll } from '@test/support/render';
import { searchStore } from '@store/search-store';
import { trackTable } from '@test/support/track-table';
/**
* The searchable columns' accessors read these fields and call
@@ -76,7 +77,7 @@ describe('the track list says how it is sorted', () => {
beforeEach(async () => {
resetHarness();
searchStore.setTerm('');
stub('library.Library.GetTracks', TRACKS);
stub('library.Library.GetTrackTable', trackTable(TRACKS));
stub('library.Library.GetAlbums', []);
emit(Events.LibraryScanComplete);
});
@@ -132,7 +133,7 @@ describe('the track list has a voice for its own state', () => {
});
it('announces the result of a search that matches nothing', async () => {
stub('library.Library.GetTracks', TRACKS);
stub('library.Library.GetTrackTable', trackTable(TRACKS));
emit(Events.LibraryScanComplete);
const el = await fixture<LitElement>('track-list');
@@ -163,7 +164,7 @@ describe('a selectable grid is a listbox, not a row of buttons', () => {
searchStore.setTerm('');
stub('library.Library.GetArtists', ARTISTS);
stub('library.Library.GetGenres', GENRES);
stub('library.Library.GetTracks', []);
stub('library.Library.GetTrackTable', trackTable([]));
stub('library.Library.GetAlbums', []);
emit(Events.LibraryScanComplete);
});
@@ -197,7 +198,7 @@ describe('a clipped value is readable somewhere', () => {
beforeEach(async () => {
resetHarness();
searchStore.setTerm('');
stub('library.Library.GetTracks', TRACKS);
stub('library.Library.GetTrackTable', trackTable(TRACKS));
stub('library.Library.GetAlbums', []);
emit(Events.LibraryScanComplete);
});
@@ -240,7 +241,7 @@ describe('the playing row is more than a colour', () => {
beforeEach(async () => {
resetHarness();
searchStore.setTerm('');
stub('library.Library.GetTracks', TRACKS);
stub('library.Library.GetTrackTable', trackTable(TRACKS));
stub('library.Library.GetAlbums', []);
emit(Events.LibraryScanComplete);
});