Skip to content

Commit

Permalink
fix: Skip parsing irrelevant log lines for progress (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
meyfa authored Jul 14, 2024
1 parent 4f0c8f4 commit cf56240
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/src/renovate/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export function extractProgress (logs: string, options: {
const repositories = new Map<string, ProgressItem>()
let foundRepositories = false
for (const line of lines(logs)) {
// Avoid parsing log lines that are obviously irrelevant.
// This improves performance even for small logs, but especially for debug/trace logs it can improve by 5-10x.
if (!line.includes('"repositories"') && !line.includes('Repository started') && !line.includes('Repository finished')) {
continue
}
const message = tryParseLogMessage(line)
// Note: While it looks ugly, manual validation is more than 3x faster than using superstruct.
// This is worth it here as there is lots of data to process.
Expand All @@ -20,7 +25,7 @@ export function extractProgress (logs: string, options: {
}
// The initial log message is for autodiscovery and tells us about the repositories that will be processed.
if ('repositories' in message && Array.isArray(message.repositories) &&
message.repositories.every(msg => typeof msg === 'string')) {
message.repositories.every((item) => typeof item === 'string')) {
foundRepositories = true
for (const repository of message.repositories) {
const item: ProgressItem = { repository, state: 'pending' }
Expand Down

0 comments on commit cf56240

Please sign in to comment.