Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

feat: raise configurable concurrency limits to 64

nash_su50968071667b
diff --git a/src/components/settings/sections/embedding-section.tsx b/src/components/settings/sections/embedding-section.tsx
index db8e9cf4..8118e5d2 100644
--- a/src/components/settings/sections/embedding-section.tsx
+++ b/src/components/settings/sections/embedding-section.tsx
@@ -16,6 +16,7 @@ import {
} from "@/lib/embedding"
import { testEmbeddingConnection, testEmbeddingFunction, type ProviderTestResult } from "@/lib/connection-tests"
import type { SettingsDraft, DraftSetter } from "../settings-types"
+import { MAX_USER_CONCURRENCY, clampUserConcurrency } from "@/lib/concurrency-limits"
interface Props {
draft: SettingsDraft
@@ -330,12 +331,12 @@ export function EmbeddingSection({ draft, setDraft }: Props) {
<Input
type="number"
min={1}
- max={32}
+ max={MAX_USER_CONCURRENCY}
step={1}
value={draft.embeddingConcurrency}
onChange={(e) => setDraft(
"embeddingConcurrency",
- Math.max(1, Math.min(32, Number(e.target.value) || 1)),
+ clampUserConcurrency(Number(e.target.value) || 1),
)}
/>
<p className="text-xs text-muted-foreground">
diff --git a/src/components/settings/sections/multimodal-section.tsx b/src/components/settings/sections/multimodal-section.tsx
index 308f2d4f..0c3c3119 100644
--- a/src/components/settings/sections/multimodal-section.tsx
+++ b/src/components/settings/sections/multimodal-section.tsx
@@ -2,6 +2,7 @@ import { useTranslation } from "react-i18next"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import type { SettingsDraft, DraftSetter } from "../settings-types"
+import { MAX_USER_CONCURRENCY, clampUserConcurrency } from "@/lib/concurrency-limits"
interface Props {
draft: SettingsDraft
@@ -269,22 +270,19 @@ export function MultimodalSection({ draft, setDraft }: Props) {
</div>
)}
- {/* Concurrency knob — practical impact: a 30-image PDF at
- concurrency=1 with a 10s/image VLM is 5 minutes of
- ingest wall time; concurrency=4 makes it ~75s. Going
- wider than ~8 is rarely a win on a single-GPU server
- that batches under the hood anyway. */}
+ {/* Concurrency knob — higher values are intended for endpoints
+ that can sustain many simultaneous vision requests. */}
<div className="space-y-2 rounded-md border p-3">
<Label>{t("settings.sections.multimodal.concurrency", "Concurrent caption requests")}</Label>
<Input
type="number"
min={1}
- max={16}
+ max={MAX_USER_CONCURRENCY}
step={1}
value={draft.multimodalConcurrency}
onChange={(e) => {
const n = Number(e.target.value)
- setDraft("multimodalConcurrency", Number.isFinite(n) ? n : 4)
+ setDraft("multimodalConcurrency", clampUserConcurrency(n, 4))
}}
/>
<p className="text-xs text-muted-foreground">
diff --git a/src/components/settings/sections/source-watch-section.tsx b/src/components/settings/sections/source-watch-section.tsx
index e0c33731..3a3d41cc 100644
--- a/src/components/settings/sections/source-watch-section.tsx
+++ b/src/components/settings/sections/source-watch-section.tsx
@@ -6,6 +6,7 @@ import {
normalizeSourceWatchConfig,
SOURCE_WATCH_FILE_TYPE_GROUPS,
} from "@/lib/source-watch-config"
+import { MAX_USER_CONCURRENCY } from "@/lib/concurrency-limits"
interface Props {
draft: SettingsDraft
@@ -137,7 +138,7 @@ export function SourceWatchSection({ draft, setDraft, projectReady }: Props) {
<input
type="number"
min={1}
- max={8}
+ max={MAX_USER_CONCURRENCY}
value={config.parsingConcurrency}
onChange={(event) => updateConfig({ parsingConcurrency: Number(event.target.value) || 1 })}
disabled={!projectReady}
@@ -160,7 +161,7 @@ export function SourceWatchSection({ draft, setDraft, projectReady }: Props) {
<input
type="number"
min={1}
- max={5}
+ max={MAX_USER_CONCURRENCY}
value={config.ingestConcurrency}
onChange={(event) => updateConfig({ ingestConcurrency: Number(event.target.value) || 1 })}
disabled={!projectReady}
diff --git a/src/components/settings/settings-view.tsx b/src/components/settings/settings-view.tsx
index cbae6547..9e106ff7 100644
--- a/src/components/settings/settings-view.tsx
+++ b/src/components/settings/settings-view.tsx
@@ -25,6 +25,7 @@ import { useWikiStore } from "@/stores/wiki-store"
import { useChatStore } from "@/stores/chat-store"
import { useUpdateStore, hasAvailableUpdate } from "@/stores/update-store"
import { useZoomStore } from "@/stores/zoom-store"
+import { clampUserConcurrency } from "@/lib/concurrency-limits"
import {
loadSourceWatchAllProjects,
loadSourceWatchConfig,
@@ -145,7 +146,7 @@ function initialDraft(
embeddingOutputDimensionality: embed.outputDimensionality,
embeddingMaxChunkChars: embed.maxChunkChars,
embeddingOverlapChunkChars: embed.overlapChunkChars,
- embeddingConcurrency: embed.concurrency ?? 1,
+ embeddingConcurrency: clampUserConcurrency(embed.concurrency ?? 1),
embeddingBatchSize: embed.batchSize ?? 1,
embeddingExtraHeaders: embed.extraHeaders ?? {},
multimodalEnabled: multimodal.enabled,
@@ -158,7 +159,7 @@ function initialDraft(
multimodalAzureApiVersion: multimodal.azureApiVersion ?? "2024-10-21",
multimodalAzureModelFamily: multimodal.azureModelFamily ?? "auto",
multimodalApiMode: multimodal.apiMode,
- multimodalConcurrency: multimodal.concurrency,
+ multimodalConcurrency: clampUserConcurrency(multimodal.concurrency, 4),
outputLanguage,
maxHistoryMessages,
proxyEnabled: proxy.enabled,
@@ -401,7 +402,7 @@ export function SettingsView() {
outputDimensionality: draft.embeddingOutputDimensionality,
maxChunkChars: draft.embeddingMaxChunkChars,
overlapChunkChars: draft.embeddingOverlapChunkChars,
- concurrency: Math.max(1, Math.min(32, Math.floor(draft.embeddingConcurrency || 1))),
+ concurrency: clampUserConcurrency(draft.embeddingConcurrency || 1),
batchSize: Math.max(1, Math.min(64, Math.floor(draft.embeddingBatchSize || 1))),
extraHeaders: draft.embeddingExtraHeaders,
}
@@ -416,13 +417,8 @@ export function SettingsView() {
azureApiVersion: draft.multimodalProvider === "azure" ? draft.multimodalAzureApiVersion.trim() : undefined,
azureModelFamily: draft.multimodalProvider === "azure" ? draft.multimodalAzureModelFamily : undefined,
apiMode: draft.multimodalProvider === "custom" ? draft.multimodalApiMode : undefined,
- // Clamp at save time so a hand-edited persisted store with a
- // ridiculous concurrency value (e.g. someone setting 1000 in
- // the JSON) doesn't blow up the captioning pipeline. Caption
- // calls already share the LLM endpoint with everything else;
- // going wider than ~16 just queues behind the server's batch
- // slot.
- concurrency: Math.max(1, Math.min(16, draft.multimodalConcurrency || 4)),
+ // Clamp hand-edited persisted values at the shared application limit.
+ concurrency: clampUserConcurrency(draft.multimodalConcurrency || 4),
}
const newProxy = {
diff --git a/src/i18n/en.json b/src/i18n/en.json
index e17dcd3b..148cb090 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -646,7 +646,7 @@
"overlapChunkChars": "Overlap (characters)",
"overlapChunkCharsHint": "Characters of overlap between adjacent chunks so ideas aren't severed at boundaries.",
"concurrency": "Concurrent requests",
- "concurrencyHint": "Maximum embedding requests in flight (1–32). Increase gradually according to your endpoint's capacity.",
+ "concurrencyHint": "Maximum embedding requests in flight (1–64). Increase gradually according to your endpoint's capacity.",
"batchSize": "Inputs per request",
"batchSizeHint": "OpenAI-compatible endpoints only (1–64). Unsupported providers automatically use single-input requests.",
"providerTests": "Provider tests",
diff --git a/src/i18n/it.json b/src/i18n/it.json
index 8332a01a..0775a03d 100644
--- a/src/i18n/it.json
+++ b/src/i18n/it.json
@@ -646,7 +646,7 @@
"overlapChunkChars": "Sovrapposizione (caratteri)",
"overlapChunkCharsHint": "Caratteri di sovrapposizione tra chunk adiacenti, così i concetti non vengono spezzati ai bordi.",
"concurrency": "Richieste in parallelo",
- "concurrencyHint": "Numero massimo di richieste di embedding contemporanee (1–32). Aumentalo gradualmente in base alla capacità del tuo endpoint.",
+ "concurrencyHint": "Numero massimo di richieste di embedding contemporanee (1–64). Aumentalo gradualmente in base alla capacità del tuo endpoint.",
"batchSize": "Input per richiesta",
"batchSizeHint": "Solo endpoint compatibili OpenAI (1–64). I provider non supportati usano automaticamente richieste a input singolo.",
"providerTests": "Test del provider",
diff --git a/src/i18n/ru.json b/src/i18n/ru.json
index eaf78d53..91ee0da3 100644
--- a/src/i18n/ru.json
+++ b/src/i18n/ru.json
@@ -646,7 +646,7 @@
"overlapChunkChars": "Перекрытие (символов)",
"overlapChunkCharsHint": "Перекрытие между соседними фрагментами, чтобы идеи не обрывались на границах.",
"concurrency": "Параллельные запросы",
- "concurrencyHint": "Максимум одновременных запросов эмбеддингов (1–32). Увеличивайте постепенно в соответствии с возможностями эндпоинта.",
+ "concurrencyHint": "Максимум одновременных запросов эмбеддингов (1–64). Увеличивайте постепенно в соответствии с возможностями эндпоинта.",
"batchSize": "Входных данных на запрос",
"batchSizeHint": "Только для эндпоинтов, совместимых с OpenAI (1–64). Неподдерживаемые провайдеры автоматически используют запросы с одним входным значением.",
"providerTests": "Тесты провайдера",
diff --git a/src/i18n/zh.json b/src/i18n/zh.json
index 89595bc8..98e6185c 100644
--- a/src/i18n/zh.json
+++ b/src/i18n/zh.json
@@ -646,7 +646,7 @@
"overlapChunkChars": "重叠字符数",
"overlapChunkCharsHint": "相邻 chunk 之间的重叠字符数,避免语义在边界被切断。",
"concurrency": "并发请求数",
- "concurrencyHint": "同时进行的 embedding 请求上限(1–32)。请根据 endpoint 承载能力逐步调高。",
+ "concurrencyHint": "同时进行的 embedding 请求上限(1–64)。请根据 endpoint 承载能力逐步调高。",
"batchSize": "单次请求输入数",
"batchSizeHint": "仅 OpenAI 兼容 endpoint 支持(1–64);不支持的 Provider 会自动使用单条请求。",
"providerTests": "Provider 测试",
diff --git a/src/lib/concurrency-limits.test.ts b/src/lib/concurrency-limits.test.ts
new file mode 100644
index 00000000..8fabcc50
--- /dev/null
+++ b/src/lib/concurrency-limits.test.ts
@@ -0,0 +1,12 @@
+import { describe, expect, it } from "vitest"
+import { clampUserConcurrency } from "./concurrency-limits"
+
+describe("clampUserConcurrency", () => {
+ it("allows values through 64 and clamps invalid values", () => {
+ expect(clampUserConcurrency(64)).toBe(64)
+ expect(clampUserConcurrency(100)).toBe(64)
+ expect(clampUserConcurrency(0)).toBe(1)
+ expect(clampUserConcurrency(2.9)).toBe(2)
+ expect(clampUserConcurrency(Number.NaN, 4)).toBe(4)
+ })
+})
diff --git a/src/lib/concurrency-limits.ts b/src/lib/concurrency-limits.ts
new file mode 100644
index 00000000..9ad87c15
--- /dev/null
+++ b/src/lib/concurrency-limits.ts
@@ -0,0 +1,10 @@
+export const MIN_USER_CONCURRENCY = 1
+export const MAX_USER_CONCURRENCY = 64
+
+export function clampUserConcurrency(value: number, fallback = MIN_USER_CONCURRENCY): number {
+ const resolved = Number.isFinite(value) ? Math.floor(value) : Math.floor(fallback)
+ return Math.max(
+ MIN_USER_CONCURRENCY,
+ Math.min(MAX_USER_CONCURRENCY, resolved),
+ )
+}
diff --git a/src/lib/embedding.ts b/src/lib/embedding.ts
index 4cfe4f52..0a384b05 100644
--- a/src/lib/embedding.ts
+++ b/src/lib/embedding.ts
@@ -28,6 +28,7 @@ import type { FileNode } from "@/types/wiki"
import { normalizePath } from "@/lib/path-utils"
import { chunkMarkdown, type Chunk } from "@/lib/text-chunker"
import { parseFrontmatter } from "@/lib/frontmatter"
+import { clampUserConcurrency } from "@/lib/concurrency-limits"
// ── Error surfacing ──────────────────────────────────────────────────────
@@ -143,7 +144,7 @@ function supportsOpenAiCompatibleBatch(cfg: EmbeddingConfig): boolean {
type AsyncLimiter = <T>(task: () => Promise<T>) => Promise<T>
function createAsyncLimiter(rawLimit: number | undefined): AsyncLimiter {
- const limit = Math.max(1, Math.min(32, Math.floor(rawLimit ?? 1)))
+ const limit = clampUserConcurrency(rawLimit ?? 1)
let active = 0
const waiters: Array<() => void> = []
return async <T>(task: () => Promise<T>): Promise<T> => {
@@ -460,7 +461,7 @@ async function parallelForEach<T>(
): Promise<void> {
const workerCount = Math.min(
items.length,
- Math.max(1, Math.min(32, Math.floor(rawLimit ?? 1))),
+ clampUserConcurrency(rawLimit ?? 1),
)
let next = 0
await Promise.all(Array.from({ length: workerCount }, async () => {
diff --git a/src/lib/image-caption-pipeline.ts b/src/lib/image-caption-pipeline.ts
index 9f7e1336..8f63b3cd 100644
--- a/src/lib/image-caption-pipeline.ts
+++ b/src/lib/image-caption-pipeline.ts
@@ -41,6 +41,7 @@ import { writeFile, readFile, createDirectory, fileExists, readFileAsBase64 } fr
import { captionImage } from "@/lib/vision-caption"
import type { LlmConfig } from "@/stores/wiki-store"
import { normalizePath } from "@/lib/path-utils"
+import { clampUserConcurrency } from "@/lib/concurrency-limits"
interface CaptionEntry {
caption: string
@@ -370,7 +371,7 @@ export async function captionMarkdownImages(
uniqueRefs.push(ref)
}
- const concurrency = Math.max(1, options?.concurrency ?? 1)
+ const concurrency = clampUserConcurrency(options?.concurrency ?? 1)
const total = uniqueRefs.length
let completed = 0
diff --git a/src/lib/ingest-queue.test.ts b/src/lib/ingest-queue.test.ts
index 8fbb7ef8..e934dfd2 100644
--- a/src/lib/ingest-queue.test.ts
+++ b/src/lib/ingest-queue.test.ts
@@ -127,7 +127,7 @@ describe("ingest-queue — enqueue & basic processing", () => {
setIngestWorkerLimit(0)
expect(getIngestWorkerLimit()).toBe(1)
setIngestWorkerLimit(99)
- expect(getIngestWorkerLimit()).toBe(5)
+ expect(getIngestWorkerLimit()).toBe(64)
setIngestWorkerLimit(2.9)
expect(getIngestWorkerLimit()).toBe(2)
})
diff --git a/src/lib/ingest-queue.ts b/src/lib/ingest-queue.ts
index e1ee842d..66e4da86 100644
--- a/src/lib/ingest-queue.ts
+++ b/src/lib/ingest-queue.ts
@@ -5,6 +5,7 @@ import { getProjectPathById } from "@/lib/project-identity"
import { hasUsableLlm } from "@/lib/has-usable-llm"
import { getTaskLlmConfig } from "@/lib/llm-task-routing"
import { IngestCommitCoordinator } from "@/lib/ingest-commit-coordinator"
+import { clampUserConcurrency } from "@/lib/concurrency-limits"
// ── Types ─────────────────────────────────────────────────────────────────
@@ -89,7 +90,7 @@ function resetQueueAccounting(): void {
}
export function setIngestWorkerLimit(limit: number): void {
- workerLimit = Math.max(1, Math.min(5, Math.floor(limit) || 1))
+ workerLimit = clampUserConcurrency(limit)
if (currentProjectId && !paused) processNext(currentProjectId)
}
diff --git a/src/lib/source-preprocess.test.ts b/src/lib/source-preprocess.test.ts
index f10d65da..83a66b46 100644
--- a/src/lib/source-preprocess.test.ts
+++ b/src/lib/source-preprocess.test.ts
@@ -12,7 +12,7 @@ describe("source preprocessing", () => {
expect(normalizeParsingConcurrency(Number.NaN)).toBe(1)
expect(normalizeParsingConcurrency(0)).toBe(1)
expect(normalizeParsingConcurrency(3.9)).toBe(3)
- expect(normalizeParsingConcurrency(99)).toBe(8)
+ expect(normalizeParsingConcurrency(99)).toBe(64)
})
it("never exceeds the configured concurrency and de-duplicates paths", async () => {
diff --git a/src/lib/source-preprocess.ts b/src/lib/source-preprocess.ts
index 0a743019..d8783789 100644
--- a/src/lib/source-preprocess.ts
+++ b/src/lib/source-preprocess.ts
@@ -1,7 +1,8 @@
import { preprocessFile } from "@/commands/fs"
+import { MAX_USER_CONCURRENCY, MIN_USER_CONCURRENCY } from "@/lib/concurrency-limits"
-export const MIN_PARSING_CONCURRENCY = 1
-export const MAX_PARSING_CONCURRENCY = 8
+export const MIN_PARSING_CONCURRENCY = MIN_USER_CONCURRENCY
+export const MAX_PARSING_CONCURRENCY = MAX_USER_CONCURRENCY
export function normalizeParsingConcurrency(value: number): number {
if (!Number.isFinite(value)) return MIN_PARSING_CONCURRENCY
diff --git a/src/lib/source-watch-config.test.ts b/src/lib/source-watch-config.test.ts
index 5b25c89c..b8e16f65 100644
--- a/src/lib/source-watch-config.test.ts
+++ b/src/lib/source-watch-config.test.ts
@@ -20,8 +20,8 @@ describe("source watch config", () => {
expect(
normalizeSourceWatchConfig({ persistExtractedMarkdown: true }).persistExtractedMarkdown,
).toBe(true)
- expect(normalizeSourceWatchConfig({ parsingConcurrency: 20 }).parsingConcurrency).toBe(8)
- expect(normalizeSourceWatchConfig({ ingestConcurrency: 20 }).ingestConcurrency).toBe(5)
+ expect(normalizeSourceWatchConfig({ parsingConcurrency: 100 }).parsingConcurrency).toBe(64)
+ expect(normalizeSourceWatchConfig({ ingestConcurrency: 100 }).ingestConcurrency).toBe(64)
expect(normalizeSourceWatchConfig({ ingestConcurrency: 0 }).ingestConcurrency).toBe(1)
expect(
normalizeSourceWatchConfig({ parsingConcurrency: Number.NaN }).parsingConcurrency,
diff --git a/src/lib/source-watch-config.ts b/src/lib/source-watch-config.ts
index bdf7c5a7..149be74e 100644
--- a/src/lib/source-watch-config.ts
+++ b/src/lib/source-watch-config.ts
@@ -1,5 +1,6 @@
import type { SourceWatchConfig } from "@/stores/wiki-store"
import { normalizePath } from "@/lib/path-utils"
+import { clampUserConcurrency } from "@/lib/concurrency-limits"
import sourceWatchDefaults from "@/lib/source-watch-defaults.json"
export const DEFAULT_SOURCE_WATCH_CONFIG: SourceWatchConfig = sourceWatchDefaults
@@ -45,12 +46,12 @@ export function normalizeSourceWatchConfig(config?: Partial<SourceWatchConfig> |
const rawParsingConcurrency = config?.parsingConcurrency
?? DEFAULT_SOURCE_WATCH_CONFIG.parsingConcurrency
const parsingConcurrency = Number.isFinite(rawParsingConcurrency)
- ? Math.max(1, Math.min(8, Math.floor(rawParsingConcurrency)))
+ ? clampUserConcurrency(rawParsingConcurrency)
: DEFAULT_SOURCE_WATCH_CONFIG.parsingConcurrency
const rawIngestConcurrency = config?.ingestConcurrency
?? DEFAULT_SOURCE_WATCH_CONFIG.ingestConcurrency
const ingestConcurrency = Number.isFinite(rawIngestConcurrency)
- ? Math.max(1, Math.min(5, Math.floor(rawIngestConcurrency)))
+ ? clampUserConcurrency(rawIngestConcurrency)
: DEFAULT_SOURCE_WATCH_CONFIG.ingestConcurrency
return {
enabled: config?.enabled ?? DEFAULT_SOURCE_WATCH_CONFIG.enabled,
diff --git a/src/stores/wiki-store.ts b/src/stores/wiki-store.ts
index 0cfb56d9..32831468 100644
--- a/src/stores/wiki-store.ts
+++ b/src/stores/wiki-store.ts
@@ -185,9 +185,8 @@ interface EmbeddingConfig {
* `concurrency` bounds parallel caption requests during ingest.
* 30-image PDFs with sequential captioning at ~10s/image (a Qwen3
* thinking model on consumer GPU) take 5 minutes. At concurrency=4
- * that drops to ~75s. Going wider than 8 typically just queues
- * behind a single-GPU server's batch slot, so we cap the slider
- * UI at a tasteful max in the settings view.
+ * that drops to ~75s. Higher values are available for hosted or
+ * multi-GPU endpoints that can sustain broader parallelism.
*/
/**
* Global outbound HTTP proxy. When `enabled` and `url` is a valid