• Stars
    star
    255
  • Rank 159,729 (Top 4 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 4 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

report progress of concurrent applications and display it in various ways

Rust Crates.io

prodash allows to integrate progress reporting into concurrent applications and provides renderers for displaying it in various ways.

It's easy to integrate thanks to a pragmatic API, and comes with a terminal user interface by default.

asciicast asciicast

How to use…

Be sure to read the documentation at https://docs.rs/prodash, it contains various examples on how to get started.

Or run the demo application like so cd prodash && cargo run --all-features --example dashboard.

Feature Toggles

This crate comes with various cargo features to tailor it to your needs.

  • progress-tree (default)
    • Provide a Progress and Root trait implementation for use with the render-line and render-tui backed by dashmap.
    • progress-tree-hp-hashmap - high-performance registry for pregree tree nodes in case of ultra-heavy insertions and deletions.
      • If this is necessary, it's probably impossible to resonably visualize the progress tree anyway, but the option exists nonetheless in case it is ever needed. Historically, this was the default, but now it seems simpler is better and just fine for typical programs.
    • progress-tree-log (default)
      • If logging in the log crate is initialized, a log will be used to output all messages provided to tree::Item::message(…) and friends. No actual progress is written.
      • May interfere with render-tui or render-line, or any renderer outputting to the console.
  • progress-log
    • A Progress implementation which logs messages and progress using the log crate
  • local-time
    • If set, timestamps in the message pane of the render-tui will be using the local time, not UTC
    • If set, timestamps of the log messages of the render-line will be using the local time, not UTC
    • Has no effect without the render-tui or render-line respectively
    • On Unix one needs to provide flags to rustc when building the binary to acknowledge potential unsoundness: RUSTFLAGS="--cfg unsound_local_offset" cargo build will do the job, but there are other ways to do that as well.
  • render-line
    • Provide a minimal line-based progress renderer which can be limited to a subset of the progress hierarchy.
    • It's like the render-tui, but with far less dependencies and less visual fidelity - all it needs is to move the cursor a little while drawing characters and block graphics.
    • Support for clicolors spec and no-color spec
    • Supports initial delay that won't affect log messages, showing progress only when needed, automatically.
    • Requires one of these additional feature flags to be set to be functional
      • one required (mutually exclusive)
        • render-line-crossterm - use the crossterm backend, useful for working on windows
        • render-line-termion - use the termion backend, useful for lean unix-only builds
    • Optional features
      • render-line-autoconfigure
        • If enabled, calls to render::line::Options::auto_configure() will configure the display based on whether or not we are in a terminal and set its color mode based on what's possible or desired.
      • signal-hook
        • If set, and the hide_cursor line renderer option is set, the cursor will be hidden and SIG_INT and SIG_TERM handlers will be installed to reset the cursor on exit. Otherwise you have to make sure to call shutdown_and_wait() on the JoinHandle returned to give the renderer a chance to undo the terminal changes. Failing to do so will leave the cusor hidden once the program has already finished.
        • Comes at the cost of an extra thread and additional dependencies.
  • render-tui
    • Provide a terminal user interface visualizing every detail of the current progress state. It treats the terminal as a matrix display.
    • Requires one of these additional feature flags to be set to be functional ** (one required, mutually exclusive)
      • render-tui-crossterm
        • Use the crossterm crate as terminal backend
        • Works everywhere natively, but has more dependencies
        • You can set additional features like this cargo build --features render-tui-crossterm,crossterm/event-stream
      • render-tui-termion
        • Use the termion crate as terminal backend
        • It has less dependencies but works only on unix systems
        • to get this, disable default features and chose at least render-tui and render-tui-termion.
  • unit-bytes
    • Supports dynamic byte display using the tiny bytesize crate.
  • unit-human
    • Display counts in a way that is easier to grasp for humans, using the tiny human_format crate.
  • unit-duration
    • Displays time in seconds like '5m4s' using the tiny compound_duration crate.

Features

  • fast insertions and updates for transparent progress tracking of highly concurrent programs
  • a messages buffer for information about success and failure
  • a terminal user interface for visualization, with keyboard controls and dynamic re-sizing
  • unicode and multi-width character support

Limitations

  • the line renderer is inherently limited in the amount of progress it can display without visual artifacts.
  • it does copy quite some state each time it displays progress information and messages
  • The underlying sync data structure, dashmap, does not document every use of unsafe
    • I also evaluated evmap, which has 25% less uses of unsafe, but a more complex interface.
    • Thus far it seemed 'ok' to use, who knows… we are getting mutable pieces of a hashmap from multiple threads, however, we never hand out multiple handles to the same child which should make actual concurrent access to the same key impossible.
  • If there are more than 2^16 tasks
    • then
      • running concurrently on a single level of the tree, they start overwriting each other
      • over its lifetime, even though they do not run concurrently, eventually new tasks will seem like old tasks (their ID wrapped around)
    • why
      • on drop, they never decrement a child count used to generate a new ID
    • fix
      • make the id bigger, like u32
      • we should do that once there is a performance test
  • If the log lines are too long for the terminal width when using the line renderer
    • then
      • visual artifacts will appear
    • why
      • trying to draw beyond the terminal boundary will add a line break automatically, which can cause unexpected overdraw.
    • fix
      • count amount of blocks drawn, without ansi codes, and stop drawing at the boundary.

Lessons Learned

  • drop() is not garantueed to be called when the future returns Ready and is in the futures::executor::ThreadPool
    • Workaround: drop and cleanup explicitly, prone to forgetting it.
    • This is also why futures::future::abortable() works (by stopping the polling), but doesn't as cleanup is not performed, even though it clearly would be preferred.
    • fix
      • Use a join handle and await it - this will drop the future properly
  • select() might not work with complex futures - these should then be boxed() if Unpin isn't implemented.

More Repositories

1

gitoxide

An idiomatic, lean, fast & safe pure Rust implementation of Git
Rust
7,202
star
2

dua-cli

View disk space usage and delete unwanted data, fast.
Rust
2,803
star
3

google-apis-rs

A binding and CLI generator for all Google APIs
Rust
1,011
star
4

open-rs

Open a path or URL with the system-defined program
Rust
234
star
5

jwalk

Filesystem walk performed in parallel with streamed and sorted results
Rust
209
star
6

trash-rs

A Rust library for moving files to the Recycle Bin
Rust
168
star
7

crates-io-cli

Interact with crates.io from the command-line
Rust
93
star
8

treediff-rs

Extract differences between arbitrary datastructures
Rust
69
star
9

github-star-counter

A tool to query direct (and indirect) stars of a GitHub user or organization
Rust
59
star
10

termbook

A runner for `mdbooks` to keep your documentation tested.
Rust
46
star
11

pulldown-cmark-to-cmark

Convert pulldown-cmark Events back to the string they were parsed from
Rust
38
star
12

cargo-smart-release

Release complex cargo-workspaces automatically with changelog generation, used by `gitoxide`
Rust
37
star
13

learning-rust-with-gitoxide

Our sessions when learning Rust with gitoxide
Rust
36
star
14

yup-hyper-mock

`hyper-mock` is a utility library to help hyper clients with their testing
Rust
29
star
15

benchmarksgame-cvs-mirror

A git mirror of the benchmarksgame cvs repository
Java
17
star
16

bsuite

Provide a plugin with tools to handle ptex files
C++
16
star
17

json-tools

A zero-copy json-lexer, filters and serializer.
Rust
15
star
18

rust-tracer

A pet raytracer to see how fast rust can go
Rust
15
star
19

crates-index-diff-rs

Learn what's changed on crates.io
Rust
14
star
20

fs-utils-rs

Utilities to help working with the filesytem
Rust
12
star
21

godi

Tool to verify data integrity with maximised performance
Go
9
star
22

bcore

powerful application framework built to integrate, not separate
Python
8
star
23

tui-crates

Various crates related to handling terminal user interfaces
Rust
7
star
24

catchit-rs

A simple and fun game made with Piston and Rust
Rust
7
star
25

anon-csv-cli

A command-line utility for anonymising CSV files
Rust
6
star
26

therror

`thiserror` + killer-feature
Rust
6
star
27

cli-template-rs

A template for command-line applications in Rust - just clone to get started
Shell
5
star
28

dotfiles

My configuration files, with auto-setup for quick account initialization
Shell
4
star
29

git-count

A simple program to count objects in git repositories - for trying the `git2` library
Rust
4
star
30

BPT

*unmaintained repository * - see BSuite
C++
3
star
31

pgit

Git Command-Line Tools in Python
Python
3
star
32

git-reconstruct

A Rust tool to reconstruct git history from tarball dumps. This is especially useful when a device vendor bases its code on an unknown commit of the git of a system on a chip vendor.
Rust
3
star
33

merchants-guide

An implementation of the merchants guide coding challenge in Rust the way I would love to see it
Rust
2
star
34

rust-hack-and-learn

A web-app for managing Katas for Rust
JavaScript
2
star
35

gitplusplus

Rewrite git using c++11 facilities
C++
2
star
36

bit

A collection of frameworks most useful to running IT infrastructure
Python
2
star
37

shallow-source

for observing shallow protocol interactions with a remote
2
star
38

kattis-autori

https://open.kattis.com/problems/autori
Shell
1
star
39

kattis-sibice

https://open.kattis.com/problems/sibice
Shell
1
star
40

javascript_the-good-parts

Repository with the book's examples, in comparison with Rust
JavaScript
1
star
41

bshotgun

Write better shotgun tools, faster
Python
1
star
42

kattis-aaah

Shell
1
star
43

reproduce-rayon-hang

minimal sample to reproduce a hang caused by jwalk running within par_iter()
Rust
1
star
44

npm-tools-rs

A Rust library to help dealing with NPM modules
Rust
1
star
45

kattis-scaling-recipes

https://open.kattis.com/problems/recipes
Rust
1
star
46

kattis-aliencodebreaker

https://open.kattis.com/problems/aliencodebreaking
Rust
1
star
47

kattis-tarifa

https://open.kattis.com/problems/tarifa
Shell
1
star
48

failure-tools

Various tools to be used in conjunction with the 'failure' crate.
Rust
1
star
49

and-rs

Porcelain for your Android-SDK tool suite
Rust
1
star
50

bbuild

A cmake based multi-platform build system with bcore integration
Python
1
star
51

kattis-pig-latin

https://open.kattis.com/problems/piglatin
Shell
1
star
52

kattis-filip

https://open.kattis.com/problems/filip
Shell
1
star
53

kattis-cli-template-rs

A template for quickly getting started on kattis samples
Shell
1
star
54

gogit

If I ever wanted to learn go programming, I would implement the git-core. Probably this is never going to happen.
Go
1
star
55

hotel-reservations

An implementation of the hotel reservations coding challenge in Rust the way I would love to see it
Rust
1
star
56

kattis-recount

https://open.kattis.com/problems/recount
Shell
1
star
57

git-commits-by-blob

An alternative backend for https://github.com/ali1234/gitxref
Rust
1
star
58

byron

1
star
59

atom-byrons-edittools

Comforts you with smart tools aiding your editing workflow in Atom
CoffeeScript
1
star
60

kattis-shattered-cake

https://open.kattis.com/problems/shatteredcake
Shell
1
star
61

mars-rover

An implementation of the mars rover coding challenge in Rust the way I would love to see it
Rust
1
star
62

kattis-quadrant

https://open.kattis.com/problems/quadrant
Shell
1
star