-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
rework std.Progress #20059
rework std.Progress #20059
Commits on May 28, 2024
-
New design ideas: * One global instance, don't try to play nicely with other instances except via IPC. * One process owns the terminal and the other processes communicate via IPC. * Clear the whole terminal and use multiple lines. What's implemented so far: * Query the terminal for size. * Register a SIGWINCH handler. * Use a thread for redraws. To be done: * IPC * Handling single threaded targets * Porting to Windows * More intelligent display of the progress tree rather than only using one line.
Configuration menu - View commit details
-
Copy full SHA for d6e8ba3 - Browse repository at this point
Copy the full SHA d6e8ba3View commit details -
Move the mutex into the nodes Track the whole tree instead of only recently activated node
Configuration menu - View commit details
-
Copy full SHA for e1e4de2 - Browse repository at this point
Copy the full SHA e1e4de2View commit details -
This time, we preallocate a fixed set of nodes and have the user-visible Node only be an index into them. This allows for lock-free management of the node storage. Only the parent indexes are stored, and the update thread makes a serialized copy of the state before trying to compute children lists. The update thread then walks the tree and outputs an entire tree of progress rather than only one line. There is a problem with clearing from the cursor to the end of the screen when the cursor is at the bottom of the terminal.
Configuration menu - View commit details
-
Copy full SHA for a3c9511 - Browse repository at this point
Copy the full SHA a3c9511View commit details -
the clear, save, restore thing doesn't work when the terminal is at the bottom
Configuration menu - View commit details
-
Copy full SHA for 66c3b6a - Browse repository at this point
Copy the full SHA 66c3b6aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 582acdf - Browse repository at this point
Copy the full SHA 582acdfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 67e08e7 - Browse repository at this point
Copy the full SHA 67e08e7View commit details -
Configuration menu - View commit details
-
Copy full SHA for ed36470 - Browse repository at this point
Copy the full SHA ed36470View commit details -
Configuration menu - View commit details
-
Copy full SHA for f071164 - Browse repository at this point
Copy the full SHA f071164View commit details -
Configuration menu - View commit details
-
Copy full SHA for df46f5a - Browse repository at this point
Copy the full SHA df46f5aView commit details -
std.Progress: save a copy of IPC data
so that the previous message can be used when the pipe is empty. prevents flickering
Configuration menu - View commit details
-
Copy full SHA for 3a768bd - Browse repository at this point
Copy the full SHA 3a768bdView commit details -
std.process.Child: fix ZIG_PROGRESS env var handling
and properly dup2 the file descriptor to make it handle the case when other files are already open
Configuration menu - View commit details
-
Copy full SHA for c01cfde - Browse repository at this point
Copy the full SHA c01cfdeView commit details -
std.Progress: fix using saved IPC data
also fix handling of BrokenPipe also fix continuing wrong loop in error conditions
Configuration menu - View commit details
-
Copy full SHA for f6873c6 - Browse repository at this point
Copy the full SHA f6873c6View commit details -
Configuration menu - View commit details
-
Copy full SHA for f97c2f2 - Browse repository at this point
Copy the full SHA f97c2f2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 795c579 - Browse repository at this point
Copy the full SHA 795c579View commit details -
Configuration menu - View commit details
-
Copy full SHA for a486392 - Browse repository at this point
Copy the full SHA a486392View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1cf1cb6 - Browse repository at this point
Copy the full SHA 1cf1cb6View commit details -
Configuration menu - View commit details
-
Copy full SHA for b27fdf9 - Browse repository at this point
Copy the full SHA b27fdf9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2233d95 - Browse repository at this point
Copy the full SHA 2233d95View commit details -
* bump default statically allocated resources * debug help when multiple instances of std.Progress are initialized * only handle sigwinch on supported operating systems * handle when reading from the pipe returns 0 bytes * avoid printing more lines than rows
Configuration menu - View commit details
-
Copy full SHA for 70e39c1 - Browse repository at this point
Copy the full SHA 70e39c1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 352dc2c - Browse repository at this point
Copy the full SHA 352dc2cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2759173 - Browse repository at this point
Copy the full SHA 2759173View commit details -
Configuration menu - View commit details
-
Copy full SHA for 516366f - Browse repository at this point
Copy the full SHA 516366fView commit details -
std.Progress: fix race condition with IPC nodes
It stored some metadata into the canonical node storage data but that is a race condition because another thread recycles those nodes. Also, keep the parent name for empty child root node names.
Configuration menu - View commit details
-
Copy full SHA for ca03c9c - Browse repository at this point
Copy the full SHA ca03c9cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9331da8 - Browse repository at this point
Copy the full SHA 9331da8View commit details -
std.process.Child: prevent racing children from inheriting progress p…
…ipes This fix is already in master branch for stdin, stdout, and stderr; this commit solves the same problem but for the progress pipe. Both fixes were originally included in one commit on this branch, however it was split it into two so that master branch could receive the fix before the progress branch is merged.
Configuration menu - View commit details
-
Copy full SHA for acdf988 - Browse repository at this point
Copy the full SHA acdf988View commit details -
Module: fix and improve progress reporting
* correctly report time spent analyzing function bodies * print fully qualified decl names * also have a progress node for codegen The downside of these changes is that it's a bit flickerey, but the upside is that it's accurate; you can see what the compiler's doing!
Configuration menu - View commit details
-
Copy full SHA for d403d8c - Browse repository at this point
Copy the full SHA d403d8cView commit details -
Progress: fix compile errors on windows
Works for `zig build-exe`, IPC still not implemented yet.
Configuration menu - View commit details
-
Copy full SHA for d77f5e7 - Browse repository at this point
Copy the full SHA d77f5e7View commit details -
Configuration menu - View commit details
-
Copy full SHA for e8907f9 - Browse repository at this point
Copy the full SHA e8907f9View commit details -
std.process.Child: comptime assert to protect prog_fileno
documenting my assumptions via comptime assertion
Configuration menu - View commit details
-
Copy full SHA for e2e61f3 - Browse repository at this point
Copy the full SHA e2e61f3View commit details -
Configuration menu - View commit details
-
Copy full SHA for e820173 - Browse repository at this point
Copy the full SHA e820173View commit details -
Configuration menu - View commit details
-
Copy full SHA for eb718ce - Browse repository at this point
Copy the full SHA eb718ceView commit details -
frontend: fix use of undefined progress node
This was causing a crash when running `zig test`.
Configuration menu - View commit details
-
Copy full SHA for d3b03ed - Browse repository at this point
Copy the full SHA d3b03edView commit details -
std.Progress: move global preallocations to thread memory
Instead of making static buffers configurable, let's pick strong defaults and then use the update thread's stack memory to store the preallocations. The thread uses a fairly shallow stack so this memory is otherwise unused. This also makes the data section of the executable smaller since it runtime allocates the memory when a `std.Progress` instance is allocated, and in the case that the process is not connected to a terminal, it never allocates the memory.
Configuration menu - View commit details
-
Copy full SHA for 7fe72d5 - Browse repository at this point
Copy the full SHA 7fe72d5View commit details -
std.Progress: move more global preallocations to thread memory
Same idea as previous commit
Configuration menu - View commit details
-
Copy full SHA for 807b613 - Browse repository at this point
Copy the full SHA 807b613View commit details -
std.Progress: truncate IPC data exceeding preallocated buffers
This accomplishes 2 things simultaneously: 1. Don't trust child process data; if the data is outside the expected range, ignore the data. 2. If there is too much data to fit in the preallocated buffers, drop the data.
Configuration menu - View commit details
-
Copy full SHA for 52ed54d - Browse repository at this point
Copy the full SHA 52ed54dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 11f8947 - Browse repository at this point
Copy the full SHA 11f8947View commit details -
std.Progress: smaller type for parents and robustify
Switch Node.Parent, Node.Index, and Node.OptionalIndex to be backed by u8 rather than u16. This works fine since we use 200 as the preallocated node buffer. This has the nice property that scanning the entire parents array for allocated nodes fits in 4 cache lines, even if we bumped the 200 up to 254 (leaving room for the two special states). The thread that reads progress updates from the pipe now handles short reads by ignoring messages that are sent in multiple reads. When checking the terminal size, if there is a failure, fall back to a conservative guess of 80x25 rather than panicking. A debug message is also emitted which would be displayed only in a debug build.
Configuration menu - View commit details
-
Copy full SHA for ea7d8ec - Browse repository at this point
Copy the full SHA ea7d8ecView commit details -
std.Progress: use std.log.debug rather than warn
when the errors could possibly be spammed many times
Configuration menu - View commit details
-
Copy full SHA for 0ca2b4e - Browse repository at this point
Copy the full SHA 0ca2b4eView commit details -
zig build: give a root progress name
Now it's more clear when zig is building the build script vs building the actual project.
Configuration menu - View commit details
-
Copy full SHA for 849693f - Browse repository at this point
Copy the full SHA 849693fView commit details -
std.Progress: keep cursor on newline
Don't truncate trailing newline. This better handles stray writes to stderr that are not std.Progress-aware, such as from non-zig child processes. This commit also makes `Node.start` and `Node.end` bail out early with a comptime branch when it is known the target will not be spawning an update thread.
Configuration menu - View commit details
-
Copy full SHA for 52ffdec - Browse repository at this point
Copy the full SHA 52ffdecView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6145819 - Browse repository at this point
Copy the full SHA 6145819View commit details -
std.Progress: count newlines more accurately
Split newline_count into written_newline_count and accumulated_newline_count. This handle the case when the tryLock() fails to obtain the lock, because in such case there would not be any newlines written to the terminal but the system would incorrectly think there were. Now, written_newline_count is only adjusted when the write() call succeeds. Furthermore, write() call failure is handled by exiting the update thread.
Configuration menu - View commit details
-
Copy full SHA for dc3a192 - Browse repository at this point
Copy the full SHA dc3a192View commit details -
std.Progress: elide root node if empty
when the root progress node has a zero length name, the sub-tree is flattened one layer, reducing visual noise, as well as bytes written to the terminal.
Configuration menu - View commit details
-
Copy full SHA for 64c6a50 - Browse repository at this point
Copy the full SHA 64c6a50View commit details -
CLI: add missing call to root progress node end()
cleans up unwanted "LLVM Emit Object" being left on the screen
Configuration menu - View commit details
-
Copy full SHA for c9587d3 - Browse repository at this point
Copy the full SHA c9587d3View commit details -
std.process.cleanExit: lock stderr before exiting
This makes it so that any other threads which are writing to stderr have a chance to finish before the process terminates. It also clears the terminal in case any progress has been written to stderr, while still accomplishing the goal of not waiting until the update thread exits.
Configuration menu - View commit details
-
Copy full SHA for 45b505c - Browse repository at this point
Copy the full SHA 45b505cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 03073d6 - Browse repository at this point
Copy the full SHA 03073d6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0937992 - Browse repository at this point
Copy the full SHA 0937992View commit details -
std.Build.Step.Run: account for new environment variable
Introduces `disable_zig_progress` which prevents the build runner from assigning the child process a progress node. This is needed for the empty_env test which requires the environment to be completely empty.
Configuration menu - View commit details
-
Copy full SHA for a5e4fe5 - Browse repository at this point
Copy the full SHA a5e4fe5View commit details -
std.Progress: adjust the timings a little bit
Slightly slower refresh rate. It's still updating very quickly. Lower the initial delay so that CLI applications feel more responsive. Even though the application is doing work for the full 500ms until something is displayed on the screen, it feels nicer to get the progress earlier.
Configuration menu - View commit details
-
Copy full SHA for eea7e5e - Browse repository at this point
Copy the full SHA eea7e5eView commit details -
std.Progress: handle big-endian targets
We cannot rely on host endianness because the parent or child process may be executing inside QEMU.
Configuration menu - View commit details
-
Copy full SHA for dcf9cae - Browse repository at this point
Copy the full SHA dcf9caeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2367a1f - Browse repository at this point
Copy the full SHA 2367a1fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4438925 - Browse repository at this point
Copy the full SHA 4438925View commit details -
Configuration menu - View commit details
-
Copy full SHA for bb1f4d2 - Browse repository at this point
Copy the full SHA bb1f4d2View commit details -
std.Progress: fix race condition with setIpcFd
The update thread was sometimes reading the special state and then incorrectly getting 0 for the file descriptor, making it hang since it tried to read from stdin.
Configuration menu - View commit details
-
Copy full SHA for aca7feb - Browse repository at this point
Copy the full SHA aca7febView commit details -
zig build: respect --color argument
`--color off` now disables the CLI progress bar both in the parent process and the build runner process.
Configuration menu - View commit details
-
Copy full SHA for b7889f2 - Browse repository at this point
Copy the full SHA b7889f2View commit details -
std.process.Child: fix spawning child proc with new cwd fd
Before this fix, the dup2 of the progress pipe was clobbering the cwd fd, causing the fchdir to return ENOTDIR in between fork() and exec().
Configuration menu - View commit details
-
Copy full SHA for 947a3a1 - Browse repository at this point
Copy the full SHA 947a3a1View commit details -
CLI: actually fix translate-c creating root progress node twice
7281cc1 did not solve the problem because even when Node.index is none, it still counts as initializing the global Progress object. Just use a normal zig optional, and all is good.
Configuration menu - View commit details
-
Copy full SHA for 5bdfe22 - Browse repository at this point
Copy the full SHA 5bdfe22View commit details -
std.Progress: relax some of the atomic orderings
Generates better machine code, particularly on ARM
Configuration menu - View commit details
-
Copy full SHA for 65a0e14 - Browse repository at this point
Copy the full SHA 65a0e14View commit details -
Configuration menu - View commit details
-
Copy full SHA for 40afac4 - Browse repository at this point
Copy the full SHA 40afac4View commit details -
std.Progress: better Windows support
* Merge a bunch of related state together into TerminalMode. Windows sometimes follows the same path as posix via ansi_escape_codes, sometimes not. * Use a different thread entry point for Windows API but share the same entry point on Windows when the terminal is in ansi_escape_codes mode. * Only clear the terminal when the stderr lock is held. * Don't try to clear the terminal when nothing has been written yet. * Don't try to clear the terminal in IPC mode. * Fix size detection logic bug under error conditions.
Configuration menu - View commit details
-
Copy full SHA for 3a3d218 - Browse repository at this point
Copy the full SHA 3a3d218View commit details