Created
March 25, 2020 02:10
-
-
Save cirocosta/8f71c47e7c28f6e7bfbe25603308852e to your computer and use it in GitHub Desktop.
stress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/atc/atccmd/command.go b/atc/atccmd/command.go | |
index e33d9eee8..cd7006969 100644 | |
--- a/atc/atccmd/command.go | |
+++ b/atc/atccmd/command.go | |
@@ -11,6 +11,7 @@ import ( | |
_ "net/http/pprof" | |
"net/url" | |
"os" | |
+ "runtime" | |
"strings" | |
"time" | |
@@ -441,6 +442,17 @@ func (cmd *RunCommand) Runner(positionalArguments []string) (ifrit.Runner, error | |
} | |
}) | |
+ http.HandleFunc("/debug/gc", func(w http.ResponseWriter, r *http.Request) { | |
+ runtime.GC() | |
+ }) | |
+ | |
+ http.HandleFunc("/debug/mem", func(w http.ResponseWriter, r *http.Request) { | |
+ var memStats runtime.MemStats | |
+ runtime.ReadMemStats(&memStats) | |
+ | |
+ fmt.Fprintf(w, "%d\n", memStats.HeapAlloc) | |
+ }) | |
+ | |
if err := cmd.configureMetrics(logger); err != nil { | |
return nil, err | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit | |
set -o nounset | |
main () { | |
login | |
for iter in $(seq 1 20); do | |
make_all_jobs_active | |
for i in $(seq 1 28); do | |
echo "ITER: $iter $i ----------" | |
reduce_jobs "1000" | |
gc | |
time_taken=$(request_jobs) | |
printf "%s,%s,%s,%s\n" $iter $i $(mem) $time_taken >> results.txt | |
done | |
done | |
} | |
reduce_jobs () { | |
local amount=$1 | |
local qry="UPDATE jobs SET active=false WHERE CTID IN (select CTID from jobs where active is true limit $amount);" | |
echo "$qry" | docker exec -i concourse_db_1 psql -U dev --dbname concourse; | |
} | |
make_all_jobs_active () { | |
local qry="UPDATE jobs SET active=true;" | |
echo "$qry" | docker exec -i concourse_db_1 psql -U dev --dbname concourse; | |
} | |
login () { | |
fly -t local login -u test -p test | |
} | |
request_jobs () { | |
local start=$(date +%s) | |
fly -t local curl /api/v1/jobs &> /dev/null | |
local end=$(date +%s) | |
echo $((end-start)) | |
} | |
gc () { | |
curl localhost:8079/debug/gc | |
} | |
mem () { | |
curl localhost:8079/debug/mem | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment