Skip to content

Progress bar - #1061

Draft
ArkadySkv wants to merge 7 commits into
OCamlPro:mainfrom
ArkadySkv:progress_bar
Draft

Progress bar #1061
ArkadySkv wants to merge 7 commits into
OCamlPro:mainfrom
ArkadySkv:progress_bar

Conversation

@ArkadySkv

@ArkadySkv ArkadySkv commented Aug 4, 2026

Copy link
Copy Markdown

Add --progress flag with dynamic progress bar for symbolic execution

This PR adds a --progress flag to the owi sym command, displaying a live‑updating progress bar during symbolic execution. The progress bar shows the number of completed tasks, total tasks, and a visual progress indicator.

OCaml Version

  • OCaml: 5.4.0 (same as project's main branch)
  • Dependencies: No new dependencies added

Motivation

Currently, there is no way to see the progress of symbolic execution without enabling --debug, which floods the output and significantly slows down execution. This feature provides a lightweight, user‑friendly progress indicator that updates in place.

Fixes: #458, #575

Changes

New Module: src/infra/progress.ml

  • Implements a dynamic progress bar with:
    • #‑filled bar showing completion percentage
    • Task counters (completed / total)
    • Carriage return for in‑place updates
    • Fallback to plain logging when stdout is not a TTY
    • "Waiting for tasks..." message when total is unknown

Modified Files

File Changes
src/bin/owi.ml Added --progress CLI flag, included in symbolic_parameters
src/symbolic/symbolic_parameters.ml Added progress : bool field
src/symbolic/symbolic_parameters.mli Added progress : bool to interface
src/symbolic/symbolic_driver.ml Integrated progress reporter with execution loop (task counting, reporting, finishing)
src/symbolic/symbolic_driver.mli Added progress:bool to run signature
src/cmd/cmd_sym.ml Pass ~progress from parameters to driver
src/cmd/cmd_iso.ml Pass ~progress from parameters to driver
src/cmd/cmd_iso.mli Added progress:bool to cmd signature
src/owi.mli Updated Symbolic_parameters record definition
src/dune Added progress.ml to build system

Testing

Test File: example.wat

(module
  (func $classify (param $x i32) (result i32)
    (if (i32.eq (local.get $x) (i32.const 0))
      (then (return (i32.const 42))))
    (if (i32.eq (local.get $x) (i32.const 1))
      (then (return (i32.const 99))))
    (return (i32.const 0)))
  (export "classify" (func $classify)))

Command & Output

./_build/default/src/bin/owi.exe sym --progress --invoke-with-symbols example.wat --entry-point classify

The progress bar updates as symbolic execution explores each path:

[###################                                         ]  33% (1/3 tasks)
[########################                                    ]  40% (2/5 tasks)
[####################################                        ]  60% (3/5 tasks)

All OK!

Expected Behavior

TTY output: Live‑updating progress bar with # characters, percentage, and task counts.

Non‑TTY output (redirected to file or pipe): Plain log messages like Progress: 3 / 5 tasks completed.

Unknown total: Shows "Waiting for tasks..." until the first task is counted.

Usage

owi sym --progress [OTHER_OPTIONS] FILE

Examples

# Symbolic execution with progress bar
owi sym --progress example.wat

# With symbolic arguments
owi sym --progress --invoke-with-symbols example.wat --entry-point classify

# With verbose logging (progress bar still works)
owi sym --progress --verbosity=debug example.wat

Implementation Details
The progress bar is implemented using:

Atomic counters for thread‑safe updates across workers.

Logs.app for output (follows Owi's logging system).

Carriage return (\r) for in‑place terminal updates.

Unix.isatty to detect TTY vs. non‑TTY output.

Tasks are counted at two points:

Total tasks incremented when a new task is pushed (Yield).

Completed tasks incremented when a task finishes (Ok or Error).

The reporter is enabled only when --progress is passed and output is a TTY.

Future Work
Add --progress support to other subcommands (owi c, owi c++, owi rust, owi go, owi zig).

Add customizable progress bar style (e.g., spinner for unknown total).

Related Issues
Closes #458 – add an option to display progress

Closes #575 – make a shiny terminal progress interface (partial)

Checklist
☑ Build passes (dune build @ALL)
☑ Tests pass (dune runtest) – except pre‑existing failures
☑ Code follows Owi style and uses the prelude library
☑ Documentation updated (usage examples)
☑ --progress flag appears in --help

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.

make a shiny terminal progress interface add an option to display progress

1 participant