Skip to content

Instantly share code, notes, and snippets.

@nik9000
Last active November 11, 2025 07:15
Show Gist options
  • Select an option

  • Save nik9000/f46b39a6213902c10e92ff51a7924e5c to your computer and use it in GitHub Desktop.

Select an option

Save nik9000/f46b39a6213902c10e92ff51a7924e5c to your computer and use it in GitHub Desktop.
# ./gradlew run -Dtests.heap.size=2g -Dtests.jvm.argline="-da -dsa"
rm /tmp/bulk
for doc in {1..10000}; do
echo '{"index":{}}' >> /tmp/bulk
echo '{"@timestamp": '$doc', "i": [-'$doc', '$doc']}' >> /tmp/bulk
done
echo '{
"settings": {
"index.number_of_shards": 1
},
"mappings": {
"properties": {
"@timestamp": { "type": "date" },
"i": { "type": "integer" }
}
}
}' > /tmp/idx
curl -uelastic:password -XDELETE localhost:9200/test
curl -uelastic:password -XPUT -HContent-Type:application/json localhost:9200/test --data @/tmp/idx
for docs in {1..1000}; do
echo -n "$docs: "
curl -s -uelastic:password -XPOST -HContent-Type:application/json "localhost:9200/test/_bulk?pretty" --data-binary @/tmp/bulk | tee /tmp/bulk_result | grep error
curl -s -uelastic:password -XPOST -HContent-Type:application/json "localhost:9200/test/_flush" | tee /tmp/flush_out > /dev/null
done
curl -s -uelastic:password -XPOST -HContent-Type:application/json "localhost:9200/test/_forcemerge?max_num_segments=1"
curl -s -uelastic:password -XPOST -HContent-Type:application/json "localhost:9200/test/_refresh?pretty"
# Run this after the ctr-c-ing the while true loop below to get the profile output in comments below
curl -s -uelastic:password -XPOST -HContent-Type:application/json 'localhost:9200/_query?pretty' -d'{
"query": "FROM test | STATS SUM(MV_MAX(i))",
"profile": true
}' | jq -c '[.profile.drivers[].operators[] | {process_nanos: .status.process_nanos, operator}] | sort_by(.process_nanos)[]'
while true; do
curl -s -uelastic:password -XPOST -HContent-Type:application/json 'localhost:9200/_query?pretty' -d'{
"query": "FROM test | STATS SUM(MV_MAX(i))"
}' | jq .took
done
# before
# 100
# 83
# 85
# 85
# 82
# 86
# 86
# 85
# 83
# 87
# 86
# 83
# 86
# 86
# 86
# {"process_nanos":725,"operator":"ProjectOperator[projection = [0]]"}
# {"process_nanos":1946834,"operator":"EvalOperator[evaluator=MvMax[field=Attribute[channel=1]]]"}
# {"process_nanos":1956920,"operator":"EvalOperator[evaluator=MvMax[field=Attribute[channel=1]]]"}
# {"process_nanos":2025084,"operator":"EvalOperator[evaluator=MvMax[field=Attribute[channel=1]]]"}
# {"process_nanos":2161048,"operator":"EvalOperator[evaluator=MvMax[field=Attribute[channel=1]]]"}
# {"process_nanos":4069034,"operator":"LuceneSourceOperator[shards = [test:0], maxPageSize = 21845, remainingDocs = 2147473942]"}
# {"process_nanos":4095971,"operator":"LuceneSourceOperator[shards = [test:0], maxPageSize = 21845, remainingDocs = 2147473942]"}
# {"process_nanos":4128660,"operator":"LuceneSourceOperator[shards = [test:0], maxPageSize = 21845, remainingDocs = 2147473942]"}
# {"process_nanos":4411004,"operator":"LuceneSourceOperator[shards = [test:0], maxPageSize = 21845, remainingDocs = 2147473942]"}
# {"process_nanos":68779518,"operator":"ValuesSourceReaderOperator[fields = [i]]"}
# {"process_nanos":68931939,"operator":"ValuesSourceReaderOperator[fields = [i]]"}
# {"process_nanos":69053814,"operator":"ValuesSourceReaderOperator[fields = [i]]"}
# {"process_nanos":70739610,"operator":"ValuesSourceReaderOperator[fields = [i]]"}
# after
# 58
# 55
# 58
# 58
# 59
# 58
# 55
# 54
# 54
# 54
# 54
# 56
# 55
# {"process_nanos":670,"operator":"ProjectOperator[projection = [0]]"}
# {"process_nanos":5417,"operator":"EvalOperator[evaluator=Attribute[channel=1]]"}
# {"process_nanos":5836,"operator":"EvalOperator[evaluator=Attribute[channel=1]]"}
# {"process_nanos":6376,"operator":"EvalOperator[evaluator=Attribute[channel=1]]"}
# {"process_nanos":6517,"operator":"EvalOperator[evaluator=Attribute[channel=1]]"}
# {"process_nanos":3521848,"operator":"LuceneSourceOperator[shards = [test:0], maxPageSize = 21845, remainingDocs = 2147473942]"}
# {"process_nanos":3558479,"operator":"LuceneSourceOperator[shards = [test:0], maxPageSize = 21845, remainingDocs = 2147473942]"}
# {"process_nanos":3584673,"operator":"LuceneSourceOperator[shards = [test:0], maxPageSize = 21845, remainingDocs = 2147473942]"}
# {"process_nanos":4008889,"operator":"LuceneSourceOperator[shards = [test:0], maxPageSize = 21845, remainingDocs = 2147473942]"}
# {"process_nanos":38529804,"operator":"ValuesSourceReaderOperator[fields = [i]]"}
# {"process_nanos":38544052,"operator":"ValuesSourceReaderOperator[fields = [i]]"}
# {"process_nanos":40722151,"operator":"ValuesSourceReaderOperator[fields = [i]]"}
# {"process_nanos":41323293,"operator":"ValuesSourceReaderOperator[fields = [i]]"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment