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

CP-47001: stdext: quickcheck-style tests and select->epoll conversion #5402

Commits on Apr 15, 2024

  1. [maintenance]: disable implicit transitive deps

    This forces us to fully declare the dependencies of our code,
    and not rely on libraries that are brought in only as transitive dependencies
    of other libraries we happen to link to.
    
    E.g. if our module A depends on library X, which itself depends on library Y,
    then currently by linking X we also get Y linked and accessible from A
    directly.
    If code in module A uses both module X and Y *directly* then it needs to
    declare a dependency on both when implicit transitive deps are off or it gets a
    link failure (typically an error about a module or type being abstract).
    If the code in module A only uses module X then no change is needed (X can
    still use Y and the final executable will link both, it is just a question of
    what is visible and callable from A directly).
    
    This is especially useful when writing new code to get dependencies correct
    from the beginning.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    (cherry picked from commit 7203430)
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    4c29a1e View commit details
    Browse the repository at this point in the history
  2. fix(dune): avoid "module unavailable" errors when running dune build @…

    …check
    
    Bytecode builds for `http_lib` are disabled due to '(modes best)',
    and that means that anything that depends on it must have it disabled too to avoid this warning.
    
    Avoids these kinds of warnings:
    ```
    File "_none_", line 1:
    Error: Module `Buf_io' is unavailable (required by `Http_svr')
    ```
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    0278742 View commit details
    Browse the repository at this point in the history
  3. CP-47001: [xapi-fdcaps]: dune plumbing for new library

    This will be a new library that will provide a more type-safe interface to file descriptor operations.
    Useful on its own, but also for testing stdext.
    
    Minimal dependencies, only Unix (and Alcotest for testing).
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    514f136 View commit details
    Browse the repository at this point in the history
  4. CP-47001: [xapi-fd-test]: dune plumbing for a new test framework

    This will be a test framework providing QCheck generators and properties for
    testing file descriptor operations.
    It will try to generate:
    * different kinds of file descriptors
    * actual data written/read on the other end of pipes and socket pairs
    * different speeds and delays on the other end to find buffering bugs
    * file descriptors that are >1024 to find bugs with select
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    4c26824 View commit details
    Browse the repository at this point in the history
  5. CP-47001: [xapi-fdcaps]: add -principal flag

    We are going to use type-level constraints a lot.
    Try to future proof it by using the recommended compiler flag.
    `ocamlc` says this about `-principal`:
    > When using labelled arguments and/or polymorphic methods, this flag is required to
    > ensure future versions of the compiler will be able to infer types correctly, even if internal algorithms change
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    5b0ac7b View commit details
    Browse the repository at this point in the history
  6. CP-47001: [xapi-fdcaps]: optional coverage support

    This is not enabled by default (but bisect-ppx is nevertheless a build-time dependency)
    Usage: `make coverage`
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    a975edf View commit details
    Browse the repository at this point in the history
  7. CP-47001: [xapi-fdcaps]: add properties module and tests

    Lightweight wrapper using polymorphic variants to track read, write, and file kind properties on file descriptors.
    We only track the property at the time the file descriptor was opened.
    
    This prevents bugs like accidentally swapping the read and write ends of a pipe,
    or attempting to run an operation on a file descriptor that would alway s fail (e.g. setting a socket timeout on a pipe)
    
    Write tests using cram-style expect tests that the operations we expect to be forbidden by this type system
    are actually forbidden.
    The error messages may be compiler version dependent, so only run them on OCaml 4.14.1 for now.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    89e95b4 View commit details
    Browse the repository at this point in the history
  8. CP-47001: [xapi-fdcaps]: add operations module and tests

    Use the capabilities module to wrap most Unix operations needed in testing Unixext
    
    Add a testsuite that checks that whenever the type says "never" the underlying file descriptor operation
    would indeed raise an exception. This ensures that the type constraints we declare are actually correct.
    The checks use unsafe operations that bypass the type layer.
    
    Similarly check that operations that are accepted by the type system and marked as "always" in the type succeed.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    fd68005 View commit details
    Browse the repository at this point in the history
  9. CP-47001: [xapi-fdcaps]: wrap more Unix operations

    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    b1c757b View commit details
    Browse the repository at this point in the history
  10. CP-47001: [xapi-fdcaps] runtime tests for read-write properties

    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    4da756c View commit details
    Browse the repository at this point in the history
  11. CP-47001: [xapi-fdcaps-test]: add observations module

    It can be used to wrap read or write operations andobserve the data that is transferred,
    and elapsed time.
    
    It also provides 2 functions that create a file of a given kind.
    
    We only test UNIX sockets, because socketpair doesn't support TCP sockets on Linux.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    43026be View commit details
    Browse the repository at this point in the history
  12. CP-47001: [xapi-fdcaps-test]: add generate module

    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    908f5a0 View commit details
    Browse the repository at this point in the history
  13. CP-47001: [unixext-test]: add quickcheck-style test

    Uses 'xapi_fd_test'.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    78ec02f View commit details
    Browse the repository at this point in the history
  14. CP-47001: Add unit tests for threadext

    Signed-off-by: Steven Woods <steven.woods@citrix.com>
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    snwoods authored and edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    de2613e View commit details
    Browse the repository at this point in the history
  15. CP-47001: [unixext-test]: add test for Unixext.proxy

    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    8ef9fa5 View commit details
    Browse the repository at this point in the history
  16. Unix.time_limited_write: fix timeout behaviour on >64KiB writes/reads

    `Unix.write` would internally loop until the desired number of bytes are sent,
    or `EAGAIN`/`EWOULDBLOCK`/another error is reached.
    It cannot check for timeouts because it is not aware that we'd want one.
    
    For pipes and sockets in non-blocking mode this wouldn't be a problem, but this function
    is often called with block devices too.
    However according to `pselect(3p)` it is a no-op on regular files:
    "File descriptors associated with regular files shall always select true for ready to read, ready to write, and error conditions."
    And the behaviour on block devices is left unspecified by POSIX, and `select(2)` on Linux doesn't document the behaviour either:
    "The pselect() and select() functions shall support regular files, terminal and pseudo‐terminal devices, STREAMS‐based files, FIFOs, pipes, and sockets. The behavior of pselect() and select() on file descriptors that refer to other types of file is unspecified"
    
    Although timeouts for a completely stuck block device cannot be implemented, we can still implement timeouts for a *slow* block device.
    Use `Unix.single_{write,read}` instead which gives full control of the iteration to the caller.
    
    The only way to interrupt stuck IO on a block device or regular file would be to use a separate process and `SIGKILL` it after a timeout (this is what `block_device_io` in XAPI does).
    
    These approaches do not work:
    * `alarm` or `setitimer` would only interrupt one thread in a multi-threaded program.
    * `pthread_kill` can be used to send a signal to a particular thread, but that requires `EINTR` behaviour on syscalls to be enabled
    * XAPI expects `SA_RESTART` semantics from syscalls, and would fail an assertion if it ever sees `EINTR` in some paths,
    so although the syscall *would* get interrupted, it'd also immediately resume without giving the caller a chance to check for timeouts
    * even if it'd work there are no bindings to `pthread_kill` in OCaml
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    801bb4f View commit details
    Browse the repository at this point in the history
  17. Unix.time_limited_{read,write}: replace select with Polly

    'select' has a hardcoded limit of 1024 file descriptors.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    319b82b View commit details
    Browse the repository at this point in the history
  18. add Unixext.time_limited_single_read

    It is too easy to misuse Unixext.time_limited_read because that one takesan absolute timestamp
    as parameter, not a relative one.
    
    Introduce a new function that takes a relative time as parameter, and doesn't loop.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    8736e5d View commit details
    Browse the repository at this point in the history
  19. CP-32622: replace select with Thread.delay

    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    b093542 View commit details
    Browse the repository at this point in the history
  20. CP-32622: Delay: replace select with time_limited_read

    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    bcae6f5 View commit details
    Browse the repository at this point in the history
  21. CP-32622: replace select in proxy with polly

    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    1c374c2 View commit details
    Browse the repository at this point in the history
  22. CP-32622: move new libraries to proper subdir

    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    edwintorok committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    3f9472c View commit details
    Browse the repository at this point in the history

Commits on May 9, 2024

  1. Merge remote-tracking branch 'upstream/feature/perf' into private/edv…

    …int/merge-stdext2-tests2
    edwintorok committed May 9, 2024
    Configuration menu
    Copy the full SHA
    4ef091d View commit details
    Browse the repository at this point in the history