Skip to content
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

incr-check enhancements, and CI for incremental test cases #21518

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

mlugg
Copy link
Member

@mlugg mlugg commented Sep 26, 2024

This does exactly what the title says. zig build test now includes zig build test-incremental, which runs incr-check over every case in test/incremental/ (we expect exit code 0 from incr-check). In addition, incr-check undergoes several enhancements:

  • Progress output now includes the target being tested
  • External executors are used for emitted binaries which cannot be executed natively
    • (If no executor exists, execution of the binary is silently skipped)
  • The temporary directory created by incr-check is removed by default (both on success and on error); it can be retained for debugging purposes with the --preserve-tmp flag

All of the incremental test cases now include the x86_64-windows-cbe target too, just for a little more coverage -- see the corresponding commit message.

@mlugg
Copy link
Member Author

mlugg commented Sep 26, 2024

Oh, I forgot to add: here's how long it takes to run zig build test-incremental for me, including building incr-check.

real    1m8.120s
user    6m35.906s
sys     0m17.981s

I'm using a Debug compiler here, so the numbers will be a little inflated -- probably release builds shave 10 seconds off. However, it won't be too drastic, because it's obvious just from watching the progress tree that the vast majority of time here is just spent waiting for zig cc to build C backend output. Per my final commit message, we probably don't want to include the CBE targets in the incremental test cases long-term, but since we currently have very few cases, it's useful right now for the extra coverage.

@mlugg mlugg force-pushed the incremental-ci branch 4 times, most recently from 5df7b7c to d37c56e Compare September 28, 2024 23:05
This is contained in the `test` step, so is tested by CI.

This commit also includes some enhancements to the `incr-check` tool to
make this work correctly.
If no external executor is available for a successful binary, its
execution is silently skipped. This allows the CI to test, to the
fullest extent possible, incremental cross-compilation to targets whose
binaries can't be executed on the host.
The new `--preserve-tmp` flag can be used to preserve the temporary
directory for debugging purposes.
Throw another target in there just to spice things up a little!

Running the incremental cases with the C backend is pretty slow due to
the need to recompile the whole output from scratch on every update; for
this reason, we probably don't want to keep many of these targeting CBE
long-term. However, for now, while we have relatively few tests and
things are still changing quite a lot, it's better to have this little
bit of extra test coverage.
* fix inconsistency in global cache directory name
* don't error if spawning external executor fails
* handle CRLF correctly
…Windows

This commit changes how `std.io.poll` is implemented on Windows. The new
implementation unfortunately incurs a little extra system call overhead,
but fixes a major bug in the old implementation.

I'm not yet set on this implementation, but I'm pushing it to check if
it resolves my CI failures.

The old implementation was buggy in that by leaving `ReadFile` calls
into the `LinearFifo` write end pending between `poll` calls, there was
potential for a race condition where the kernel satisfies the
asynchronous read after the caller has modified the corresponding
`LinearFifo` in some way; most likely by rotating its buffer for a
`readableSliceOfLen` call. The only way to allow the full `LinearFifo`
API to be used is to not leave these `ReadFile` calls pending after
`poll` returns. So, now, `pollWindows` will leave running a different
set of `ReadFile` calls, which are trying to read a single byte into a
temporary buffer. These are the operations we wait on with
`WaitForMultipleObjects`. When these reads are completed, we push that
single byte to the FIFO, and perform some reads directly into the FIFO
memory until we stop getting immediate results; then, we again queue a
single-byte read into a stable buffer for the next call to `poll`.

My main concern with this implementation is that if the kernel
frequently returns `IO_PENDING` for `ReadFile` calls even when the data
is available, then we could effectively skip the bulk-reading path,
hence reading data one byte at a time. Performance measurements are
necessary here.
you need to wait on cancelations i guess
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