@@ -223,18 +223,16 @@ func (l *lookup) nodeTip(accountHash common.Hash, path string, stateID common.Ha
223223func (l * lookup ) addLayer (diff * diffLayer ) {
224224 defer func (now time.Time ) {
225225 lookupAddLayerTimer .UpdateSince (now )
226+ log .Debug ("PathDB lookup add layer" , "id" , diff .id , "block" , diff .block , "elapsed" , time .Since (now ))
226227 }(time .Now ())
227228
228229 var (
229230 wg sync.WaitGroup
230231 state = diff .rootHash ()
231232 )
232- st00 := time .Now ()
233- var st0 , st1 , st2 , st3 time.Duration
234233 wg .Add (1 )
235234 go func () {
236235 defer wg .Done ()
237- st := time .Now ()
238236 for accountHash := range diff .states .accountData {
239237 list , exists := l .accounts [accountHash ]
240238 if ! exists {
@@ -243,13 +241,11 @@ func (l *lookup) addLayer(diff *diffLayer) {
243241 list = append (list , state )
244242 l .accounts [accountHash ] = list
245243 }
246- st0 = time .Since (st )
247244 }()
248245
249246 wg .Add (1 )
250247 go func () {
251248 defer wg .Done ()
252- st := time .Now ()
253249 for accountHash , slots := range diff .states .storageData {
254250 for slotHash := range slots {
255251 key := storageKey (accountHash , slotHash )
@@ -261,13 +257,11 @@ func (l *lookup) addLayer(diff *diffLayer) {
261257 l .storages [key ] = list
262258 }
263259 }
264- st1 = time .Since (st )
265260 }()
266261
267262 wg .Add (1 )
268263 go func () {
269264 defer wg .Done ()
270- st := time .Now ()
271265 for path := range diff .nodes .accountNodes {
272266 list , exists := l .accountNodes [path ]
273267 if ! exists {
@@ -276,7 +270,6 @@ func (l *lookup) addLayer(diff *diffLayer) {
276270 list = append (list , state )
277271 l .accountNodes [path ] = list
278272 }
279- st2 = time .Since (st )
280273 }()
281274
282275 wg .Add (1 )
@@ -292,41 +285,29 @@ func (l *lookup) addLayer(diff *diffLayer) {
292285 workChannels [i ] = make (chan string , 10 ) // Buffer to avoid blocking
293286 }
294287
295- // Start 16 workers, each handling its own shard
288+ // Start all workers, each handling its own shard
296289 for shardIndex := 0 ; shardIndex < storageNodesShardCount ; shardIndex ++ {
297290 go func (shardIdx int ) {
298291 defer storageWg .Done ()
299- st := time .Now ()
300- count := 0
301292
302293 shard := l .storageNodes [shardIdx ]
303294 for key := range workChannels [shardIdx ] {
304- // Access the specific shard map (no lock needed as each worker owns its shard)
305295 list , exists := shard [key ]
306296 if ! exists {
307297 list = make ([]common.Hash , 0 , 16 ) // TODO(rjl493456442) use sync pool
308298 }
309299 list = append (list , state )
310300 shard [key ] = list
311- count ++
312- }
313-
314- st3 := time .Since (st )
315- if st3 > time .Millisecond {
316- log .Info ("PathDB lookup add storage nodes worker" , "shard" , shardIdx , "count" , count , "elapsed" , st3 )
317301 }
318302 }(shardIndex )
319303 }
320304
321305 // Distribute work to workers based on shard index
322- distributeStart := time .Now ()
323- totalCount := 0
324306 for accountHash , slots := range diff .nodes .storageNodes {
325307 accountHex := accountHash .Hex ()
326308 for path := range slots {
327309 shardIndex := getStorageShardIndex (path )
328310 workChannels [shardIndex ] <- accountHex + path
329- totalCount ++
330311 }
331312 }
332313
@@ -337,13 +318,9 @@ func (l *lookup) addLayer(diff *diffLayer) {
337318
338319 // Wait for all storage workers to complete
339320 storageWg .Wait ()
340- st3 = time .Since (distributeStart )
341-
342- log .Info ("PathDB lookup add storage nodes" , "total_count" , totalCount , "accounts" , len (diff .nodes .storageNodes ), "elapsed" , st3 )
343321 }()
344322
345323 wg .Wait ()
346- log .Info ("PathDB lookup" , "id" , diff .id , "block" , diff .block , "st0" , st0 , "st1" , st1 , "st2" , st2 , "st3" , st3 , "elapsed" , time .Since (st00 ))
347324}
348325
349326// removeFromList removes the specified element from the provided list.
@@ -375,6 +352,7 @@ func removeFromList(list []common.Hash, element common.Hash) (bool, []common.Has
375352func (l * lookup ) removeLayer (diff * diffLayer ) error {
376353 defer func (now time.Time ) {
377354 lookupRemoveLayerTimer .UpdateSince (now )
355+ log .Debug ("PathDB lookup remove layer" , "id" , diff .id , "block" , diff .block , "elapsed" , time .Since (now ))
378356 }(time .Now ())
379357
380358 var (
0 commit comments