perf: parse, chunk and hash documents in a worker thread and add startup and document-parse benchmarks

This commit is contained in:
mesalogo
2026-10-03 13:54:24 +08:00
parent 9d03217f99
commit 10c5162811
15 changed files with 1787 additions and 33 deletions
+28
View File
@@ -0,0 +1,28 @@
// Wire format shared by document-parse-client (Main) and document-parse-worker.
export type DocumentParseOperation =
| 'parseDocument'
| 'extractPdfTextPages'
| 'extractPptxPages'
| 'chunkDocument'
| 'sha256'
export type DocumentParseRequest = {
id: number
op: DocumentParseOperation
args: unknown[]
}
export type SerializedDocumentParseError = {
name: string
message: string
/** Primitive own properties some error types carry (PDF.js, Node). */
extra?: Record<string, unknown>
cause?: SerializedDocumentParseError
}
export type DocumentParseResponse =
| { id: number; result: unknown }
| { id: number; error: SerializedDocumentParseError }
export const documentParseErrorExtraKeys = ['code', 'status', 'missing', 'details', 'extraDelay'] as const