Skip to content

Nhse o34 orkv.i54 propfetch#58

Draft
martinsumner wants to merge 14 commits intoopenriak-3.4from
nhse-o34-orkv.i54-propfetch
Draft

Nhse o34 orkv.i54 propfetch#58
martinsumner wants to merge 14 commits intoopenriak-3.4from
nhse-o34-orkv.i54-propfetch

Conversation

@martinsumner
Copy link
Contributor

Reduce the number of re-requests for the bucket property in the PUT path.

Running the general_counter_perf test, this branch reduces the calls to ets:lookup/2 from 115 to 65. Primarily by fetching the bucket properties once at the start of the PUT, and re-using the properties throughout the PUT process (rather than re-requesting them via ETS lookups).

There are o(100) `ets:lookup/2` function calls in order to do a single n=3 counter update.  This is a first path to try and reduce the number of individual calls for bucket properties.

Note each request for a typed bucket property currently requires 4 x `ets:lookup/2`.
2 x bucket-property requests were required as part of aae_update.  Also property requests for object update/merge.
Rather than repeatedly calling `lists:keyfind/2` or `proplists:get_value/3`

However, there are issues with the way bucket properties are merged with defaults.  Depending on the function used, thye could be merged using ukeysort - so there was a unique enty for every property, or keysort.  If it was merged with keysort there would be multiple properties, but only the first would be found (by proplists:get_value or lists:keyfind).

This now tries to standardise bucket property fetches (that may impact the PUT path) to produce genuinely merged properties.
The coordinator should detect this.  If it has been accepted elsewhere (i.e. it is a replicated PUT, or it has been added on a misconfigured node), then accept it here.

Changes the layout of the code to separate the size_check and sibling_check rather than split the encode_and_put fun.

This should reduce the number of calls to application:get_env (and consequent calls to ets:lookup/2)
Walk the options on prepare (as well as validate) within the PUT_FSM

Fix the object_format to v1 (tests will need to intercept the function)

Only perform the size and sibling checks on a normal PUT at the coordinator.

Allow bucket properties to be kept in a map at the riak_kv_put_fsm, and still have options fetched.

Only calculate node_confirms, if node_confirms is a requirement for `enough`.  Calculate it more efficiently when required

Revert changes to remove put functions from riak_client - required for riak_test.
lists:keyfind is done in a NIF and is faster for small amounts of properties (i.e. the three being extracted in riak_kv_vnode), where the input list or properties will be larger than the output.

There is no advantage from using a map.
@martinsumner martinsumner mentioned this pull request Sep 29, 2025
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