A Transparent and Verifiable Way to Sync the AT Protocol's PLC Directory

faster

+12 -3
+12 -3
bundle/manager.go
··· 7 7 "log" 8 8 "os" 9 9 "path/filepath" 10 + "runtime" 10 11 "sort" 11 12 "strconv" 12 13 "strings" ··· 95 96 } 96 97 } 97 98 98 - // Perform rebuild if needed 99 + // Perform rebuild if needed (using parallel scan) 99 100 if needsRebuild { 100 101 config.Logger.Printf("Rebuilding index from %d bundle files...", len(bundleFiles)) 101 102 ··· 108 109 logger: config.Logger, 109 110 } 110 111 111 - // Scan directory to rebuild index 112 - _, err := tempMgr.ScanDirectory() 112 + // Use parallel scan with auto-detected CPU count 113 + workers := runtime.NumCPU() 114 + if workers < 1 { 115 + workers = 1 116 + } 117 + 118 + config.Logger.Printf("Using %d workers for parallel scan", workers) 119 + 120 + // Scan directory to rebuild index (parallel) 121 + _, err := tempMgr.ScanDirectoryParallel(workers, nil) 113 122 if err != nil { 114 123 return nil, fmt.Errorf("failed to rebuild index: %w", err) 115 124 }