Skip to content

Only fetch bucket properties once per request #54

@martinsumner

Description

@martinsumner

Using the general_api_perf test, the ets:lookup function is now prominent in the profile of various flavours of read/write test.

The microseconds per call is bigger than expected (0.50), but alos the frequency of the call.

The bucket properties for non-typed buckets are fetched from ETS - but for every GET/PUT they must be fetched twice. They are first fetched by riak_client to determine if this is a normal or consistent GET/PUT, then by the FSM to get the properties to use in the processing of the GET/PUT.

The code should be refactored to only fetch bucket properties once. In the longer term, perhaps persistent_term not ets shoudd be used for holding bucket properties.

It should also be noted that bucket properties are always remerged with default properties every request:

BucketProps = riak_core_bucket:get_bucket(Bucket),
%% typed buckets never fall back to defaults
Props =
case is_tuple(Bucket) of
false ->
lists:keymerge(1, lists:keysort(1, BucketProps),
lists:keysort(1, DefaultProps));
true ->
BucketProps
end,

This should probably happen once on storage, not every time on read.

Also of potential relevance is the riak_object:dvv_enabled/1 check:

riak_kv/src/riak_object.erl

Lines 973 to 980 in 752c754

%% @private is dvv enabled on this node?
-spec dvv_enabled(bucket()) -> boolean().
dvv_enabled(Bucket) ->
BProps = riak_core_bucket:get_bucket(Bucket),
%% default to `true`, since legacy buckets should have `false` by
%% default, and typed should have `true` and `undefined` is not a
%% valid return.
proplists:get_value(dvv_enabled, BProps, true).

Could this be optimised to not require repeated bucket property fetched each time it is called? [Note - this will normally be only called once for each PUT, at the coordinator]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions