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

Summary of changes in this PR: #1034

Merged
merged 6 commits into from
Apr 27, 2023
Merged

Summary of changes in this PR: #1034

merged 6 commits into from
Apr 27, 2023

Commits on Apr 20, 2023

  1. Summary of changes in this PR:

      * Finally achieving my dream of moving the connection pool out of HTTP; it's going to live in the [ConcurrentUtilities.jl](JuliaServices/ConcurrentUtilities.jl#18)
        package instead. In short, it had no unit tests, scant documentation, and was generally a pain to deal with in HTTP. We also discovered at least 2 major issues with the current
        implementation during a deep dive into performance and issue diagnosis, including:
          * If a ConnectError was thrown while creating a connection, a "permit" to the pool was permanently lost; get enough of them and the entire connection pool grinds to a halt :grimace:
          * Being a threadsafe structure, the pool had the poor choice of holding the pool lock for the duration of trying to get a permit _and making new connections_. This meant that in the
            case of a connection taking a long time to be made, we were essentially holding the rest of the pool hostage. This is totally unnecessary and can cause big performance issues in
            really heavy workloads where there's lots of contention on the pool for managing requests.
        The new implementation in ConcurrentUtilities.jl solves both these problems while being about 1/4th the LOC of the previous implementation. And it has unit tests! yay!
        All in all, I think #1033 and #1032 should both be mostly resolved by these changes/updates.
      * Relatedly, we're adjusting the API for connection pools to allow the user to pass in their _own_ connection pool to be used for that request (to check for a connection to reuse and to
        return the connection to after completion). A pool can be constructed like `HTTP.Pool(; max::Int)` and passed to any of the `HTTP.request` methods like `HTTP.get(...; pool=pool)`.
        HTTP has its own global default pool `HTTP.Connections.POOL` that it uses by default to manage connection reuse. The `HTTP.set_default_connection_limit!` will still work as long as it
        is called before any requests are made. Calling it _after_ requests have been made will be a no-op. The `connection_limit` keyword arg is now formally deprecated and will issue a warning
        if passed. I'm comfortable with a full deprecation here because it turns out it wasn't even really working before anyway (unless it was passed/used on _every_ request and never changed).
        So instead of "changing" things, we're really just doing a proper implementation that now actually works, has better behavior, and is actually controllable by the user.
      * Add a try-finally in keepalive! around our global IO lock usage just for good house-keeping
      * Refactored `try_with_timeout` to use a `Channel` instead of the non-threaded `@async`; it's much simpler and seems cleaner
      * I refactored a few of the stream IO functions so that we always know the number of bytes downloaded, whether in memory or written to
        an IO, so we can log them and use them in verbose logging to give bit-rate calculations
      * Added a new `logerrors::Bool=false` keyword arg that allows doing `@error` logs on errors that may otherwise be "swallowed" when doing retries;
        it can be helpful to sometimes be able to at least see what kinds of errors are happening; also cleaned up our error handling in general so we don't lose backtraces which fixes #1003.
      * Added lots of metrics around various time spent in various layers, read vs. write durations, etc. These can be enabled, and stored in the request context, by passing `observelayers=true`
        This mostly resolves #1025 and #1019.
      * Fixed some missing keyword args that either weren't correct in the inline docs or weren't included in the client.md docs
      * Removed a few client-side layers (BasicAuth, DebugRequest, Canonicalize, etc.) since their implementations were _really_ trivial and moved their functionality into a single HeadersRequest
        layer where we now do all the header-related work during the request. This has the affect of _drastically_ reducing the exploding backtraces we now have when doing requests because of
        our "functional style" client-side layering.
      * Fixed #612 by ensuring `keepalive` is included in our `connectionkey` computation so only connections that specified `keepalive` will be reused if its passed the same value on subsequent requests
    quinnj committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    639469b View commit details
    Browse the repository at this point in the history

Commits on Apr 21, 2023

  1. Configuration menu
    Copy the full SHA
    6b04184 View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2023

  1. Updates

    quinnj committed Apr 24, 2023
    Configuration menu
    Copy the full SHA
    41ef56d View commit details
    Browse the repository at this point in the history

Commits on Apr 27, 2023

  1. cleanup

    quinnj committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    9374cdc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6fed5e3 View commit details
    Browse the repository at this point in the history
  3. Address PR review

    quinnj committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    309f8dd View commit details
    Browse the repository at this point in the history