sliftutils 1.7.12 → 1.7.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +2 -1
- package/index.d.ts +95 -39
- package/misc/dist/yaml.ts.cache +2 -2
- package/misc/dist/yamlBase.ts.cache +2 -2
- package/misc/https/hostServer.d.ts +7 -0
- package/misc/https/hostServer.ts +89 -20
- package/misc/openrouter.ts +17 -14
- package/package.json +2 -2
- package/storage/ArchivesDisk.d.ts +1 -1
- package/storage/ArchivesDisk.ts +2 -1
- package/storage/IArchives.d.ts +5 -1
- package/storage/IArchives.ts +5 -1
- package/storage/backblaze.d.ts +1 -1
- package/storage/backblaze.ts +9 -6
- package/storage/dist/embeddingFormats.ts.cache +2 -2
- package/storage/proxydatabase/dist/Database.ts.cache +2 -2
- package/storage/proxydatabase/dist/ivfEmbeddingDatabase.ts.cache +123 -61
- package/storage/proxydatabase/dist/transactionSet.ts.cache +16 -4
- package/storage/remoteStorage/ArchivesRemote.d.ts +1 -1
- package/storage/remoteStorage/ArchivesRemote.ts +2 -1
- package/storage/remoteStorage/ArchivesUrl.d.ts +1 -1
- package/storage/remoteStorage/ArchivesUrl.ts +13 -9
- package/storage/remoteStorage/blobStore.d.ts +6 -2
- package/storage/remoteStorage/blobStore.ts +46 -6
- package/storage/remoteStorage/createArchives.d.ts +26 -11
- package/storage/remoteStorage/createArchives.ts +104 -28
- package/storage/remoteStorage/deployTakeover.d.ts +24 -0
- package/storage/remoteStorage/deployTakeover.ts +373 -0
- package/storage/remoteStorage/dist/ArchivesUrl.ts.cache +16 -11
- package/storage/remoteStorage/dist/blobStore.ts.cache +39 -4
- package/storage/remoteStorage/dist/createArchives.ts.cache +91 -9
- package/storage/remoteStorage/dist/deployTakeover.ts.cache +371 -0
- package/storage/remoteStorage/dist/remoteConfig.ts.cache +9 -3
- package/storage/remoteStorage/dist/sourceWrapper.ts.cache +3 -3
- package/storage/remoteStorage/dist/storageController.ts.cache +11 -12
- package/storage/remoteStorage/dist/storageServerState.ts.cache +120 -19
- package/storage/remoteStorage/remoteConfig.d.ts +1 -0
- package/storage/remoteStorage/remoteConfig.ts +6 -0
- package/storage/remoteStorage/storageController.d.ts +2 -0
- package/storage/remoteStorage/storageController.ts +9 -9
- package/storage/remoteStorage/storageServer.ts +14 -1
- package/storage/remoteStorage/storageServerState.d.ts +16 -1
- package/storage/remoteStorage/storageServerState.ts +118 -16
- package/yarn.lock +4 -4
- package/storage/dist/faceFramesData.ts.cache +0 -55
- package/storage/embeddingBench.d.ts +0 -1
- package/storage/embeddingBench.ts +0 -152
- package/storage/faceFramesData.d.ts +0 -1
- package/storage/faceFramesData.ts +0 -49
- package/storage/faceFramesServer.d.ts +0 -1
- package/storage/faceFramesServer.ts +0 -56
- package/storage/proxydatabase/ivfDbCheck.d.ts +0 -1
- package/storage/proxydatabase/ivfDbCheck.ts +0 -85
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { InMemoryDatabase } from "./inMemoryDatabase";
|
|
3
|
-
import { IvfEmbeddingRoot, IvfConfig, EmbeddingInput, insertEmbeddings, searchEmbeddings } from "./ivfEmbeddingDatabase";
|
|
4
|
-
import { encodeEmbedding, EmbeddingFormat } from "../embeddingFormats";
|
|
5
|
-
import { ensureFaceData } from "../faceFramesData";
|
|
6
|
-
|
|
7
|
-
// Exercises the tiered IVF embedding database through the in-memory Database wrapper, which counts every
|
|
8
|
-
// read/write/delete call and the bytes through each, across dataset sizes and load patterns, with timing.
|
|
9
|
-
|
|
10
|
-
const DIM = 512;
|
|
11
|
-
const FILE_NAME = "faceFrames2_full.f32";
|
|
12
|
-
const MODEL = "buffalo_l";
|
|
13
|
-
const FORMAT: EmbeddingFormat = "q8g8_2048";
|
|
14
|
-
|
|
15
|
-
async function loadFloats(count: number): Promise<Float32Array> {
|
|
16
|
-
const byteLength = count * DIM * 4;
|
|
17
|
-
const filePath = await ensureFaceData(FILE_NAME, byteLength);
|
|
18
|
-
const buffer = Buffer.alloc(byteLength);
|
|
19
|
-
const handle = fs.openSync(filePath, "r");
|
|
20
|
-
fs.readSync(handle, buffer, 0, byteLength, 0);
|
|
21
|
-
fs.closeSync(handle);
|
|
22
|
-
return new Float32Array(buffer.buffer, buffer.byteOffset, count * DIM);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async function buildInputs(count: number): Promise<EmbeddingInput[]> {
|
|
26
|
-
const floats = await loadFloats(count);
|
|
27
|
-
const inputs: EmbeddingInput[] = [];
|
|
28
|
-
for (let index = 0; index < count; index++) {
|
|
29
|
-
const slice = floats.subarray(index * DIM, (index + 1) * DIM);
|
|
30
|
-
inputs.push({ ref: "e" + index, embedding: encodeEmbedding({ input: slice, format: FORMAT, model: MODEL }) });
|
|
31
|
-
}
|
|
32
|
-
return inputs;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function freshDatabase(config: IvfConfig): InMemoryDatabase<IvfEmbeddingRoot> {
|
|
36
|
-
const root: IvfEmbeddingRoot = { config, count: 0, flat: {}, byRef: {}, steps: {}, centroids: {}, cells: {} };
|
|
37
|
-
return new InMemoryDatabase<IvfEmbeddingRoot>(root);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function pad(value: string | number, width: number): string {
|
|
41
|
-
return String(value).padStart(width);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function main() {
|
|
45
|
-
const config: IvfConfig = { model: MODEL, format: FORMAT, cellTargetSize: 128 };
|
|
46
|
-
const runs: { size: number; batch: number }[] = [
|
|
47
|
-
{ size: 10000, batch: 1 },
|
|
48
|
-
{ size: 10000, batch: 100 },
|
|
49
|
-
{ size: 100000, batch: 1000 },
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
let maxSize = 0;
|
|
53
|
-
for (const run of runs) {
|
|
54
|
-
if (run.size > maxSize) {
|
|
55
|
-
maxSize = run.size;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const loadStart = Date.now();
|
|
59
|
-
const allInputs = await buildInputs(maxSize);
|
|
60
|
-
console.log(`loaded + encoded ${maxSize} embeddings in ${((Date.now() - loadStart) / 1000).toFixed(1)}s\n`);
|
|
61
|
-
|
|
62
|
-
console.log(`${pad("added", 7)} ${pad("batch", 5)} | ${pad("secs", 7)} ${pad("reads", 8)} ${pad("writes", 8)} ${pad("deletes", 8)} ${pad("readMB", 9)} ${pad("writeMB", 8)} | recall`);
|
|
63
|
-
for (const run of runs) {
|
|
64
|
-
const database = freshDatabase(config);
|
|
65
|
-
const start = Date.now();
|
|
66
|
-
for (let offset = 0; offset < run.size; offset += run.batch) {
|
|
67
|
-
insertEmbeddings(database, allInputs.slice(offset, offset + run.batch));
|
|
68
|
-
}
|
|
69
|
-
const seconds = (Date.now() - start) / 1000;
|
|
70
|
-
|
|
71
|
-
let found = 0;
|
|
72
|
-
const sampleCount = 100;
|
|
73
|
-
for (let index = 0; index < sampleCount; index++) {
|
|
74
|
-
const query = allInputs[Math.floor(index * run.size / sampleCount)];
|
|
75
|
-
const hits = searchEmbeddings(database, query.embedding, { probeBudget: 512, resultCount: 1 });
|
|
76
|
-
if (hits && hits.length && hits[0].ref === query.ref) {
|
|
77
|
-
found++;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const recall = (found / sampleCount).toFixed(2);
|
|
81
|
-
console.log(`${pad(run.size, 7)} ${pad(run.batch, 5)} | ${pad(seconds.toFixed(1), 7)} ${pad(database.readCalls, 8)} ${pad(database.writeCalls, 8)} ${pad(database.deleteCalls, 8)} ${pad((database.bytesRead / 1e6).toFixed(0), 9)} ${pad((database.bytesWritten / 1e6).toFixed(0), 8)} | ${recall}`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
void main();
|