From 6f31b1135ac88736a67afde742ff5dca90f5526c Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Thu, 24 Jul 2014 14:29:45 +0200 Subject: [PATCH] [Benchmark] Make TermsAggregationSearchBenchmark fairer to uninverted field data. The benchmark indexes 200 unique full-width longs. For uninverted field data we try to use the most memory-efficient storage, and in that case it would use two arrays: one for the doc->ordinals mapping and one for the ordinal->value mapping. Which is slower than what doc values do by storing directly the mapping from docs to values. --- .../aggregations/TermsAggregationSearchBenchmark.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java index aff3a4dc6ab..698bd07530c 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java @@ -175,10 +175,6 @@ public class TermsAggregationSearchBenchmark { .endObject() .endObject())).actionGet(); - long[] lValues = new long[NUMBER_OF_TERMS]; - for (int i = 0; i < NUMBER_OF_TERMS; i++) { - lValues[i] = ThreadLocalRandom.current().nextLong(); - } ObjectOpenHashSet uniqueTerms = ObjectOpenHashSet.newInstance(); for (int i = 0; i < NUMBER_OF_TERMS; i++) { boolean added; @@ -203,7 +199,7 @@ public class TermsAggregationSearchBenchmark { XContentBuilder builder = jsonBuilder().startObject(); builder.field("id", Integer.toString(counter)); final String sValue = sValues[ThreadLocalRandom.current().nextInt(sValues.length)]; - final long lValue = lValues[ThreadLocalRandom.current().nextInt(lValues.length)]; + final long lValue = ThreadLocalRandom.current().nextInt(NUMBER_OF_TERMS); builder.field("s_value", sValue); builder.field("l_value", lValue); builder.field("s_value_dv", sValue); @@ -220,7 +216,7 @@ public class TermsAggregationSearchBenchmark { for (String field : new String[] {"lm_value", "lm_value_dv"}) { builder.startArray(field); for (int k = 0; k < NUMBER_OF_MULTI_VALUE_TERMS; k++) { - builder.value(lValues[ThreadLocalRandom.current().nextInt(sValues.length)]); + builder.value(ThreadLocalRandom.current().nextInt(NUMBER_OF_TERMS)); } builder.endArray(); } @@ -327,7 +323,7 @@ public class TermsAggregationSearchBenchmark { stats.add(termsStats("terms_stats_agg_sm_l_dv", Method.AGGREGATION, "sm_value_dv", "l_value_dv", null)); stats.add(termsStats("terms_stats_agg_def_sm_l", Method.AGGREGATION_DEFERRED, "sm_value", "l_value", null)); stats.add(termsStats("terms_stats_agg_def_sm_l_dv", Method.AGGREGATION_DEFERRED, "sm_value_dv", "l_value_dv", null)); - + System.out.println("------------------ SUMMARY ----------------------------------------------"); System.out.format(Locale.ENGLISH, "%35s%10s%10s%15s\n", "name", "took", "millis", "fieldata size"); for (StatsResult stat : stats) {