Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug: Rate limit bitbake progress bars #372

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/driver/BitbakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class BitbakeDriver {
})
const disposables = [
child.onData((data) => {
logger.debug(data.toString())
logger.debug_ratelimit(data.toString())
}),
child.onExit(() => {
this.bitbakeProcess = undefined
Expand Down
32 changes: 32 additions & 0 deletions client/src/lib/src/utils/OutputLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,38 @@ export class OutputLogger {
this.log(message, 'debug')
}

public debug_ratelimit (message: string): void {
if (!this.shouldLog(this.level)) {
// OPTIM Skip the regex check if the log level is not high enough
return
}

if (OutputLogger.rateLimitPatterns.test(message)) {
const now = Date.now()
if (now - this.rateLimitStart < OutputLogger.rateLimit) {
this.rateLimitCount++
return
}
this.rateLimitStart = now
if (this.rateLimitCount > 0) {
this.debug(`Rate limited ${this.rateLimitCount} messages`)
this.rateLimitCount = 0
}
}

this.debug(message)
}

/* Catches messages like:
* 0: busybox-1.37.0-r0 do_fetch - 6s (pid 280) 7% |######### | 28.7M/s
* Parsing recipes: 10% |################ | ETA: 0:00:19
* No currently running tasks (0 of 3) 0% | |
*/
private static readonly rateLimitPatterns = /% \|/
private static readonly rateLimit = 1000
private rateLimitStart = 0
private rateLimitCount = 0

public warn (message: string): void {
this.log(message, 'warning')
}
Expand Down
Loading