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

cluster: small performance optimisations #780

Merged
merged 7 commits into from Aug 22, 2023

Commits on Aug 2, 2023

  1. cluster: elide clones by moving keyspaces there and back

    Keyspace strategies were cloned and allocated into a Vec, just for
    creating an iterator to references to them in order to construct a
    `ReplicaLocator`. It was done due to lifetime issues (in order to send
    references to another thread, they must be 'static).
    The problem is solved by sending keyspaces to another thread for
    constructing `ReplicaLocator` and then moving it back to the calling
    thread afterwards. Clones are elided. Hooray!
    wprzytula committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    638db21 View commit details
    Browse the repository at this point in the history
  2. cluster: elide clones at PeerEndpoint construction

    By leveraging branched variable initialisation, cloning datacenters and
    racks is no longer necessary.
    wprzytula committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    94557a8 View commit details
    Browse the repository at this point in the history
  3. cluster: elide clone in update_rack_count()

    This one wasn't particularly hard.
    wprzytula committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    7f9d5e7 View commit details
    Browse the repository at this point in the history
  4. cluster: un-async get_working_connections()

    There no reason why the method should be async.
    wprzytula committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    00d37b3 View commit details
    Browse the repository at this point in the history

Commits on Aug 3, 2023

  1. cluster: prepare: refactor for clarity

    There was a convoluted logic that can be easily expressed using
    itertools' `find_or_first()` iterator method.
    wprzytula committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    e81b93b View commit details
    Browse the repository at this point in the history

Commits on Aug 22, 2023

  1. cluster: change get_working_connections() to iter variant

    `get_working_connections()` not only allocated `Vec`s for all nodes, but
    it even cloned them to one big `Vec`. At least the latter could be
    avoided by returning an iterator over connections.
    The new replacement method, `iter_working_connections()`, was put on
    `ClusterData` instead of `Cluster`, because it borrows from
    `ClusterData`, so lifetime issues would be brought otherwise.
    The two uses of `get_working_connections()`, `Session::prepare()` and
    `Session::check_schema_agreement()`, were updated to use
    `iter_working_connections()`, and `get_working_connections()` was
    deleted as not needed anymore.
    wprzytula committed Aug 22, 2023
    Configuration menu
    Copy the full SHA
    610956b View commit details
    Browse the repository at this point in the history
  2. cluster: send_use_keyspace(): avoid Vec allocation

    As `join_all()` accepts any `IntoIterator`, it accepts iterators in
    particular. Allocating a `Vec` is unnecessary.
    wprzytula committed Aug 22, 2023
    Configuration menu
    Copy the full SHA
    1bc5744 View commit details
    Browse the repository at this point in the history