mirror of
https://github.com/discourse/discourse.git
synced 2026-08-04 10:39:43 +08:00
This is the next part after the worker pool and reporter changes. I needed
something that can show the progress of more than one step at the same time. The
converter will run steps in parallel later, and the single progress bar we use
today (`ExtendedProgressBar`, on top of `ruby-progressbar`) can only show one
step. For now only one step runs at a time, so you see one live line, and
finished steps and notices scroll up into the terminal history. Once the
scheduler is done, showing several lines at once works without more changes.
I first checked which library to use in a small POC: ruby-progressbar (what we
use today), bubbletea-ruby, tty-progressbar, and a hand-written ANSI renderer.
The gems all needed me to fight or patch their internals to get what we need.
bubbletea came closest, but its event loop blocks the other threads while it
waits for input, so the progress updates dropped from about 200/s to 9/s — that
would slow down the actual conversion, not just the display. Working around that
means patching the gem, and keeping notices and finished steps in the terminal
history needs changing how it draws. So I'd be writing the hard parts myself
anyway, on top of behavior I don't control and a heavy dependency. The
hand-written renderer does everything we need, uses much less CPU, and only adds
one small pure-Ruby gem (`unicode-display_width`). It also lets us drop
`ruby-progressbar`.
What it does:
- Shows a live line per running step, with finished steps and notices scrolling
into the history. Each step ends as done, interrupted (Ctrl-C) or failed.
- Falls back to plain line output for pipes, CI and dumb terminals.
- The importer reports through the same thing now, so the converter and the
importer share one progress display.
Roughly how a run looks:
✓ Converting categories 4,281 0:01
✓ Converting users 312,440 0:03 ⚠ 17 warnings
⠋ Converting posts 41% 1,248,776 4:07 ETA 5:52 73,143/s
⠋ Converting tags 11% 10,944 0:03 ETA 0:24
The output in pipes and CI looks different than before.
|
||
|---|---|---|
| .. | ||
| locales | ||
| importer.yml | ||
| upload.yml.sample | ||