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

storage_proxy: place unique_response_handler:s in small_vector instead of std::vector #8606

Conversation

avikivity
Copy link
Member

This cuts an allocation in the write path. Instruction count reduction isn't
large, but performance does improve (results are consistent):

before: 196369.48 tps ( 55.2 allocs/op, 13.2 tasks/op, 51658 insns/op)
after: 199290.32 tps ( 54.2 allocs/op, 13.2 tasks/op, 51600 insns/op)

(this is perf_simple_query --write --smp 1 --operations-per-shard 1000000)

Since small_vector requires noexcept move constructor and assignment,
they corresponding unique_response_handler members are adjusted/added
respectively.

@psarna
Copy link
Contributor

psarna commented May 7, 2021

The previous vector->small_vector transition patch was based on typedefs and I think it was a good idea. It would be nicer to reduce the number of places where one has to type "3" to a single definition in storage_proxy.hh.

@@ -2012,7 +2020,7 @@ storage_proxy::create_write_response_handler(const std::tuple<lw_shared_ptr<paxo
inet_address_vector_topology_change(), inet_address_vector_topology_change(), std::move(tr_state), get_stats(), std::move(permit));
}

void storage_proxy::register_cdc_operation_result_tracker(const std::vector<storage_proxy::unique_response_handler>& ids, lw_shared_ptr<cdc::operation_result_tracker> tracker) {
void storage_proxy::register_cdc_operation_result_tracker(const utils::small_vector<storage_proxy::unique_response_handler, 3>& ids, lw_shared_ptr<cdc::operation_result_tracker> tracker) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you optimize for a batch with up to three different statements? One should be a common case here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we have one per replica. Agree it should be 1 if it's per-mutation.

@avikivity
Copy link
Member Author

The previous vector->small_vector transition patch was based on typedefs and I think it was a good idea. It would be nicer to reduce the number of places where one has to type "3" to a single definition in storage_proxy.hh.

I'll add a type name.

We'd like to change the vector to a more involved type, so to avoid
repeating it everywhere, give it a name. The actual type isn't changed
in this patch.
small_vector wants the move constructor to be noexcept, and move
assighment to exist (and be noexcept). These are easy to achieve.
…d of std::vector

This cuts an allocation in the write path. Instruction count reduction isn't
large, but performance does improve (results are consistent):

before: 196369.48 tps ( 55.2 allocs/op,  13.2 tasks/op,   51658 insns/op)
after:  199290.32 tps ( 54.2 allocs/op,  13.2 tasks/op,   51600 insns/op)

(this is perf_simple_query --write --smp 1 --operations-per-shard 1000000)
@avikivity avikivity force-pushed the storage_proxy-response-id-small_vector branch from 484791a to dd904f7 Compare May 9, 2021 20:54
@avikivity
Copy link
Member Author

Update:

  • split into three patches
  • type alias for vector of unique_response_handler
  • small_vector limited to 1 for common case of 1 mutation

Copy link
Contributor

@nyh nyh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I just have one question about the assignment operator.

service/storage_proxy.cc Show resolved Hide resolved
nyh added a commit that referenced this pull request May 10, 2021
… instead of std::vector' from Avi Kivity

This cuts an allocation in the write path. Instruction count reduction isn't
large, but performance does improve (results are consistent):

before: 196369.48 tps ( 55.2 allocs/op,  13.2 tasks/op,   51658 insns/op)
after:  199290.32 tps ( 54.2 allocs/op,  13.2 tasks/op,   51600 insns/op)

(this is perf_simple_query --write --smp 1 --operations-per-shard 1000000)

Since small_vector requires noexcept move constructor and assignment,
they corresponding unique_response_handler members are adjusted/added
respectively.

Closes #8606

* github.com:scylladb/scylla:
  storage_proxy: place unique_response_handler:s in small_vector instead of std::vector
  storage_proxy: make unique_response_handler friendly to small_vector
  storage_proxy: give a name to a vector of unique_response_handlers
@scylladb-promoter scylladb-promoter merged commit df9faba into scylladb:master May 11, 2021
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.

None yet

5 participants