Skip to content

perf: reduce reentrant render-lock overhead in progress pipeline - #61

Merged
Qubitium merged 1 commit into
mainfrom
devin/optimize-rendering-latency-3
Jul 27, 2026
Merged

perf: reduce reentrant render-lock overhead in progress pipeline#61
Qubitium merged 1 commit into
mainfrom
devin/optimize-rendering-latency-3

Conversation

@Qubitium

Copy link
Copy Markdown
Contributor

Summary

Third pass at lowering per-call latency, focusing on the progress-bar render pipeline.

The public entry points (ProgressBar.draw, next, pulse, etc.) still acquire the shared _RENDER_LOCK, but the internal methods they call no longer re-enter that lock. The lock is an RLock, so nested acquisitions were safe but not free; removing the decorator from the pure read/build helpers cuts a lot of per-frame overhead.

Methods changed:

  • ProgressBar._resolve_rendered_line, _render_snapshot, _render_line, _should_render, calc_time, _animated_text, _should_animate_title, step, __bool__, __len__
  • RollingProgressBar._render_position, _advance_phase, _render_snapshot, _render_animation

These are only called from locked contexts (draw, next, pulse, render_progress_stack, session.render) or are pure reads (step, __len__), so the serialization guarantee is preserved while avoiding repeated getattr(..., "_headless"), _render_lock_context(), and RLock.__enter__/__exit__ work.

Profiling

Local cProfile harness (1000 iterations per API, 120 columns):

API Before PR #60 After this pass
progress snapshot 0.100 s 0.075 s
progress iter 0.108 s 0.085 s
columns 0.126 s 0.139 s
logs 0.063 s 0.066 s

Columns/logs are within run-to-run noise; the big remaining wins are in the progress path.

All tests pass (141 passed, 5 skipped, 5 subtests passed).

Link to Devin session: https://app.devin.ai/sessions/45e5067b04374a8381566d710d0311da
Requested by: @Qubitium

@Qubitium Qubitium self-assigned this Jul 27, 2026
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@Qubitium
Qubitium merged commit 64369cd into main Jul 27, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant