Skip to content

Commit

Permalink
optimization: skip a useless Sprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Dec 2, 2024
1 parent 0020d33 commit 20d1dfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 2 additions & 3 deletions pipeline/process_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ func (p *Pipeline) executeModules(ctx context.Context, execOutput execout.Execut
p.extraMapModuleOutputs = nil
p.extraStoreModuleOutputs = nil
blockNum := execOutput.Clock().Number
block := fmt.Sprintf("%d (%s)", blockNum, execOutput.Clock().Id)

// they may be already built, but we call this function every time to enable future dynamic changes
if err := p.BuildModuleExecutors(ctx); err != nil {
Expand All @@ -318,7 +317,7 @@ func (p *Pipeline) executeModules(ctx context.Context, execOutput execout.Execut
}
res := p.execute(ctx, executor, execOutput)
if err := p.applyExecutionResult(ctx, executor, res, execOutput); err != nil {
return fmt.Errorf("applying executor results %q on block %s: %w", executor.Name(), block, res.err)
return fmt.Errorf("applying executor results %q on block %d (%s): %w", executor.Name(), blockNum, execOutput.Clock().Id, res.err)
}
}
} else {
Expand Down Expand Up @@ -351,7 +350,7 @@ func (p *Pipeline) executeModules(ctx context.Context, execOutput execout.Execut
return fmt.Errorf("running executor %q: %w", executor.Name(), result.err)
}
if err := p.applyExecutionResult(ctx, executor, result, execOutput); err != nil {
return fmt.Errorf("applying executor results %q on block %s: %w", executor.Name(), block, result.err)
return fmt.Errorf("applying executor results %q on block %d (%s): %w", executor.Name(), blockNum, execOutput.Clock(), result.err)
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions storage/store/filename.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,18 @@ func NewPartialFileInfo(moduleName string, start uint64, exclusiveEndBlock uint6
}

func parseFileName(moduleName, filename string) (*FileInfo, bool) {
res := stateFileRegex.FindAllStringSubmatch(filename, 1)
res := stateFileRegex.FindAllSubmatchIndex([]byte(filename), 1)
if len(res) != 1 {
return nil, false
}

fmt.Println(filename, res)
return &FileInfo{
ModuleName: moduleName,
Filename: filename,
Range: block.NewRange(uint64(mustAtoi(res[0][2])), uint64(mustAtoi(res[0][1]))),
Partial: res[0][4] == "partial",
WithTraceID: res[0][3] != "",
Range: block.NewRange(uint64(mustAtoi(filename[res[0][4]:res[0][5]])), uint64(mustAtoi(filename[res[0][2]:res[0][3]]))),
Partial: filename[res[0][8]:res[0][9]] == "partial",
WithTraceID: res[0][6] != -1,
}, true
}

Expand Down

0 comments on commit 20d1dfb

Please sign in to comment.