mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-12 09:47:20 +02:00
Trois défauts sans rapport entre eux, tous visibles à l'écran. Jauge de contexte bloquée à « 0 / N (0 %) » : le comptage exact vient de usage.prompt_tokens (include_usage), qu'un llama-server récent a cessé de renvoyer. On note désormais si l'usage est arrivé ; sinon la fin de tour publie l'estimation qui pilote déjà la compaction — approximative, mais jamais absente. Et la souscription envoie la valeur courante juste après le rattrapage : une page rechargée affichait zéro sur une discussion pourtant pleine, faute d'événement ctx_used dans la fenêtre rejouée. Espace disque : « il ne reste que 11,9 Go » sur un partage Unraid qui en a des centaines. /mnt/user est servi par shfs, un FUSE qui agrège plusieurs disques — statfs y renvoie l'espace d'un seul, et ce chiffre REFUSAIT l'installation du modèle. Les systèmes de fichiers qui approximent (FUSE, overlay, NFS, CIFS, Ceph, Gluster) sont reconnus par leur magie : leur chiffre reste affiché, précédé d'un « ~ », mais ne bloque plus rien. Panneau Fichiers : le panneau entier défilait, emportant vers le haut l'en-tête, le fil d'Ariane et le pied (occupation disque, bouton .zip) dès qu'il y avait quelques fichiers. Seule la liste défile maintenant ; le pied reste en bas et l'état vide se centre. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
161 lines
5.4 KiB
TypeScript
161 lines
5.4 KiB
TypeScript
/**
|
|
* Some of the internal operations of micromark do lots of editing
|
|
* operations on very large arrays. This runs into problems with two
|
|
* properties of most circa-2020 JavaScript interpreters:
|
|
*
|
|
* - Array-length modifications at the high end of an array (push/pop) are
|
|
* expected to be common and are implemented in (amortized) time
|
|
* proportional to the number of elements added or removed, whereas
|
|
* other operations (shift/unshift and splice) are much less efficient.
|
|
* - Function arguments are passed on the stack, so adding tens of thousands
|
|
* of elements to an array with `arr.push(...newElements)` will frequently
|
|
* cause stack overflows. (see <https://stackoverflow.com/questions/22123769/rangeerror-maximum-call-stack-size-exceeded-why>)
|
|
*
|
|
* SpliceBuffers are an implementation of gap buffers, which are a
|
|
* generalization of the "queue made of two stacks" idea. The splice buffer
|
|
* maintains a cursor, and moving the cursor has cost proportional to the
|
|
* distance the cursor moves, but inserting, deleting, or splicing in
|
|
* new information at the cursor is as efficient as the push/pop operation.
|
|
* This allows for an efficient sequence of splices (or pushes, pops, shifts,
|
|
* or unshifts) as long such edits happen at the same part of the array or
|
|
* generally sweep through the array from the beginning to the end.
|
|
*
|
|
* The interface for splice buffers also supports large numbers of inputs by
|
|
* passing a single array argument rather passing multiple arguments on the
|
|
* function call stack.
|
|
*
|
|
* @template T
|
|
* Item type.
|
|
*/
|
|
export class SpliceBuffer<T> {
|
|
/**
|
|
* @param {ReadonlyArray<T> | null | undefined} [initial]
|
|
* Initial items (optional).
|
|
* @returns
|
|
* Splice buffer.
|
|
*/
|
|
constructor(initial?: ReadonlyArray<T> | null | undefined);
|
|
/** @type {Array<T>} */
|
|
left: Array<T>;
|
|
/** @type {Array<T>} */
|
|
right: Array<T>;
|
|
/**
|
|
* Array access;
|
|
* does not move the cursor.
|
|
*
|
|
* @param {number} index
|
|
* Index.
|
|
* @return {T}
|
|
* Item.
|
|
*/
|
|
get(index: number): T;
|
|
/**
|
|
* The length of the splice buffer, one greater than the largest index in the
|
|
* array.
|
|
*/
|
|
get length(): number;
|
|
/**
|
|
* Remove and return `list[0]`;
|
|
* moves the cursor to `0`.
|
|
*
|
|
* @returns {T | undefined}
|
|
* Item, optional.
|
|
*/
|
|
shift(): T | undefined;
|
|
/**
|
|
* Slice the buffer to get an array;
|
|
* does not move the cursor.
|
|
*
|
|
* @param {number} start
|
|
* Start.
|
|
* @param {number | null | undefined} [end]
|
|
* End (optional).
|
|
* @returns {Array<T>}
|
|
* Array of items.
|
|
*/
|
|
slice(start: number, end?: number | null | undefined): Array<T>;
|
|
/**
|
|
* Mimics the behavior of Array.prototype.splice() except for the change of
|
|
* interface necessary to avoid segfaults when patching in very large arrays.
|
|
*
|
|
* This operation moves cursor is moved to `start` and results in the cursor
|
|
* placed after any inserted items.
|
|
*
|
|
* @param {number} start
|
|
* Start;
|
|
* zero-based index at which to start changing the array;
|
|
* negative numbers count backwards from the end of the array and values
|
|
* that are out-of bounds are clamped to the appropriate end of the array.
|
|
* @param {number | null | undefined} [deleteCount=0]
|
|
* Delete count (default: `0`);
|
|
* maximum number of elements to delete, starting from start.
|
|
* @param {Array<T> | null | undefined} [items=[]]
|
|
* Items to include in place of the deleted items (default: `[]`).
|
|
* @return {Array<T>}
|
|
* Any removed items.
|
|
*/
|
|
splice(start: number, deleteCount?: number | null | undefined, items?: Array<T> | null | undefined): Array<T>;
|
|
/**
|
|
* Remove and return the highest-numbered item in the array, so
|
|
* `list[list.length - 1]`;
|
|
* Moves the cursor to `length`.
|
|
*
|
|
* @returns {T | undefined}
|
|
* Item, optional.
|
|
*/
|
|
pop(): T | undefined;
|
|
/**
|
|
* Inserts a single item to the high-numbered side of the array;
|
|
* moves the cursor to `length`.
|
|
*
|
|
* @param {T} item
|
|
* Item.
|
|
* @returns {undefined}
|
|
* Nothing.
|
|
*/
|
|
push(item: T): undefined;
|
|
/**
|
|
* Inserts many items to the high-numbered side of the array.
|
|
* Moves the cursor to `length`.
|
|
*
|
|
* @param {Array<T>} items
|
|
* Items.
|
|
* @returns {undefined}
|
|
* Nothing.
|
|
*/
|
|
pushMany(items: Array<T>): undefined;
|
|
/**
|
|
* Inserts a single item to the low-numbered side of the array;
|
|
* Moves the cursor to `0`.
|
|
*
|
|
* @param {T} item
|
|
* Item.
|
|
* @returns {undefined}
|
|
* Nothing.
|
|
*/
|
|
unshift(item: T): undefined;
|
|
/**
|
|
* Inserts many items to the low-numbered side of the array;
|
|
* moves the cursor to `0`.
|
|
*
|
|
* @param {Array<T>} items
|
|
* Items.
|
|
* @returns {undefined}
|
|
* Nothing.
|
|
*/
|
|
unshiftMany(items: Array<T>): undefined;
|
|
/**
|
|
* Move the cursor to a specific position in the array. Requires
|
|
* time proportional to the distance moved.
|
|
*
|
|
* If `n < 0`, the cursor will end up at the beginning.
|
|
* If `n > length`, the cursor will end up at the end.
|
|
*
|
|
* @param {number} n
|
|
* Position.
|
|
* @return {undefined}
|
|
* Nothing.
|
|
*/
|
|
setCursor(n: number): undefined;
|
|
}
|
|
//# sourceMappingURL=splice-buffer.d.ts.map
|