Skip to content

Instantly share code, notes, and snippets.

@nik9000
Created October 31, 2025 21:00
Show Gist options
  • Select an option

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

Select an option

Save nik9000/3a8eb7065d20c6f36d0c71fad80d1d2c 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
jq . -R --slurp <<CAT > /tmp/big
$(($doc % 10)) She should have died hereafter;
There would have been a time for such a word.
Tomorrow, and tomorrow, and tomorrow
Creeps in this petty pace from day to day
To the last syllable of recorded time;
And all our yesterdays have lighted fools
The way to dusty death. Out, out, brief candle!
Life’s but a walking shadow, a poor player
That struts and frets his hour upon the stage
And then is heard no more. It is a tale
Told by an idiot, full of sound and fury
Signifying nothing.
CAT
echo '{"index":{}}' >> /tmp/bulk
echo '{"@timestamp": '$doc', "kwd": "foo '$(($doc % 10))'", "n": '$doc', "big": '$(cat /tmp/big)'}' >> /tmp/bulk
done
echo '{
"settings": {
"index.number_of_shards": 100
},
"mappings": {
"properties": {
"@timestamp": { "type": "date" },
"kwd": { "type": "keyword" },
"big": { "type": "keyword" },
"n": { "type": "long" }
}
}
}' > /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..100}; 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/_refresh?pretty"
curl -s -uelastic:password -XPOST -HContent-Type:application/json 'localhost:9200/_query?pretty' -d'{
"query": "FROM test | STATS SUM(LENGTH(big))",
"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(LENGTH(big))"
}' | jq .took
done
# with small
# 20
# 14
# 14
# 13
# 13
# 12
# 12
# 12
# 14
# 13
# 24
# 14
# without small
# 83
# 85
# 83
# 82
# 101
# 84
# 85
# 86
# 89
# 87
# 86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment