Skip to content

Loading…

Improve performance of slide histogram #2

Merged
merged 1 commit into from

2 participants

@slfritchie
Basho Technologies member

This is a patch by @jtuple ... I'm just creating the pull request to get the review & merge show on the road....

Partition slide histogram reservoir by erlang:system_info(scheduler_id),
as previously done with counter and spiral metrics.

@jtuple jtuple Improve performance of slide histogram
Partition slide histogram reservoir by erlang:system_info(scheduler_id),
as previously done with counter and spiral metrics.
b6bb134
@slfritchie
Basho Technologies member

+1 to merge.

Verification, using Erlang/OTP R15B02 or R15B03:

  1. git clone git://github.com/basho/basho_bench.git
  2. cd basho_bench
  3. git checkout origin/slf-null-performance-enhancements
  4. make
  5. (cd deps/folsom ; git checkout 4b72c41) ... this is the basho/folsom repo head branch's HEAD commit
  6. make
  7. ./basho_bench /path/to/preload.config
  8. tail -1 tests/current/put_latencies.csv | awk -F, '{print $1}' ... this is the total runtime, in seconds.
  9. (cd deps/folsom ; git checkout jdb-faster-slide)
  10. make
  11. ./basho_bench /path/to/preload.config
  12. tail -1 tests/current/put_latencies.csv | awk -F, '{print $1}' ... this is the total runtime, in seconds.

... where the preload.config file is this:

{mode, max}.
{concurrent, 100}.
{mode, max}.
{concurrent, 1}.
{duration, 3}.
{report_interval, 1}.

{driver, basho_bench_driver_null}.
{key_generator, {partitioned_sequential_int, 10000000}}.
{disable_sequential_int_progress_report, true}.
{value_generator, {fixed_bin, 1000, 42}}.
{operations, [ {put, 1} ]}.

On my MacBook Pro, I see the following runtimes omitted for steps 8 and steps 12:

  • step 8: 107.713825
  • step 12: 24.7412

That's about 4.3x faster, yay.

@slfritchie slfritchie merged commit cbe909a into master
@seancribbs seancribbs deleted the jdb-faster-slide branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 28, 2012
  1. @jtuple

    Improve performance of slide histogram

    jtuple committed
    Partition slide histogram reservoir by erlang:system_info(scheduler_id),
    as previously done with counter and spiral metrics.
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/folsom_sample_slide.erl
View
10 src/folsom_sample_slide.erl
@@ -33,6 +33,8 @@
-include("folsom.hrl").
+-define(WIDTH, 16). %% Keep this a power of two
+
new(Size) ->
Sample = #slide{window = Size},
Pid = folsom_sample_slide_sup:start_slide_server(?MODULE, Sample#slide.reservoir, Sample#slide.window),
@@ -40,16 +42,18 @@ new(Size) ->
update(#slide{reservoir = Reservoir} = Sample, Value) ->
Moment = moment(),
- ets:insert(Reservoir, {Moment, Value}),
+ X = erlang:system_info(scheduler_id),
+ Rnd = X band (?WIDTH-1),
+ ets:insert(Reservoir, {{Moment, Rnd}, Value}),
Sample.
get_values(#slide{window = Window, reservoir = Reservoir}) ->
Oldest = moment() - Window,
- ets:select(Reservoir, [{{'$1','$2'},[{'>=', '$1', Oldest}],['$2']}]).
+ ets:select(Reservoir, [{{{'$1','_'},'$2'},[{'>=', '$1', Oldest}],['$2']}]).
moment() ->
folsom_utils:now_epoch().
trim(Reservoir, Window) ->
Oldest = moment() - Window,
- ets:select_delete(Reservoir, [{{'$1','_'},[{'<', '$1', Oldest}],['true']}]).
+ ets:select_delete(Reservoir, [{{{'$1','_'},'_'},[{'<', '$1', Oldest}],['true']}]).
Something went wrong with that request. Please try again.