perf(importer): improve import pipeline throughput with 6 targeted optimizations - #345
Merged
Conversation
…timizations - Parallel file validation in multifile processor using bounded goroutine pool (sourcegraph/conc, maxConcurrentFileValidations=4) for near-linear speedup on multi-file NZBs - Merge segment validation passes: export SelectSegmentsForValidation + ValidateSegmentList so validation/segments.go can skip the redundant size- accumulation loop and share a single iteration with availability checking - Cache virtual directory category-path resolution with sync.Map to eliminate repeated string allocations on every import (invalidateCategoryCache provided for future config-change hooks) - Lazy progress tracker creation: guard CreateTracker calls behind broadcaster.HasSubscribers() to avoid allocations when no SSE client is connected; nil-safe Tracker.Update prevents panics when tracker is nil - Serialize queue claim transactions with a sync.Mutex so workers never contend on SQLite, eliminating exponential-backoff retries under high concurrency - Limit directory scanner depth to defaultMaxScanDepth=10 (configurable via SetMaxScanDepth) to prevent runaway traversal of deep or symlinked trees Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
yoshitaka420
pushed a commit
to yoshitaka420/altmount
that referenced
this pull request
Jun 1, 2026
…timizations (kipsilabs#345) - Parallel file validation in multifile processor using bounded goroutine pool (sourcegraph/conc, maxConcurrentFileValidations=4) for near-linear speedup on multi-file NZBs - Merge segment validation passes: export SelectSegmentsForValidation + ValidateSegmentList so validation/segments.go can skip the redundant size- accumulation loop and share a single iteration with availability checking - Cache virtual directory category-path resolution with sync.Map to eliminate repeated string allocations on every import (invalidateCategoryCache provided for future config-change hooks) - Lazy progress tracker creation: guard CreateTracker calls behind broadcaster.HasSubscribers() to avoid allocations when no SSE client is connected; nil-safe Tracker.Update prevents panics when tracker is nil - Serialize queue claim transactions with a sync.Mutex so workers never contend on SQLite, eliminating exponential-backoff retries under high concurrency - Limit directory scanner depth to defaultMaxScanDepth=10 (configurable via SetMaxScanDepth) to prevent runaway traversal of deep or symlinked trees Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sourcegraph/conc,maxConcurrentFileValidations=4) — near-linear speedup on multi-file NZBs (expected 2-4x for typical 100-file archives)SelectSegmentsForValidation+ValidateSegmentListfrominternal/usenet/validation.go;validation/segments.gonow shares a single iteration for size accumulation and availability checking, eliminating the redundant first passsync.Mapcache onServiceavoids repeated string operations incalculateProcessVirtualDiron every import;invalidateCategoryCache()available for future config-change hooksbroadcaster.HasSubscribers()guardsCreateTrackercalls in the RAR/7zip processors;Tracker.Updatehas a nil-receiver guard so passing a nil*Trackeris safesync.Mutexinqueue.Manager.processNextItemserialises DB claim transactions, eliminating SQLite lock-contention retries and their exponential backoff delaysDirectoryScannerdefaults tomaxScanDepth=10(configurable viaSetMaxScanDepth) to prevent runaway traversal of deep or cyclically-linked directory treesTest plan
make— full build (Go backend + frontend, all checks)go test ./internal/importer/...— no regressions in importer packagego test ./internal/usenet/...— segment validation tests pass with refactored helpersgo test ./internal/progress/...— nil-safe tracker and HasSubscribers tests pass🤖 Generated with Claude Code