Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions .github/workflows/load-test-coordinator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,28 @@ jobs:
PR="$(gh pr list --repo "${{ github.repository }}" --state open \
--head "$REF" --json number --jq '.[0].number // ""' 2>/dev/null || true)"
fi
LEGS='[
Comment thread
cjonas9 marked this conversation as resolved.
# go-bench baseline: latest published release, falls back to the highest v* tag.
BASELINE="$(gh api "repos/${{ github.repository }}/releases/latest" --jq .tag_name 2>/dev/null || true)"
if [ -z "$BASELINE" ]; then
BASELINE="$(git ls-remote --tags --refs origin 'v[0-9]*' \
| sed 's|.*refs/tags/||' | sort -V | tail -n 1 || true)"
fi
[ -n "$BASELINE" ] || echo "::warning::no baseline release found; the go-bench leg will fail"
echo "go-bench baseline: ${BASELINE:-<none>}"

# Unquoted heredoc so $BASELINE expands into the go-bench entry;
LEGS="$(jq -c . <<EOF
[
{"label":"Apply-load ingestion","run_label":"apply-load","script":"cmd/stellar-rpc/internal/integrationtest/infrastructure/perf-eval/ingest-load-test/run-load-test.sh","budget":225},
{"label":"Backfill ingestion","run_label":"backfill","script":"cmd/stellar-rpc/internal/integrationtest/infrastructure/perf-eval/backfill-test/run-backfill.sh","budget":345}
]'
{"label":"Backfill ingestion","run_label":"backfill","script":"cmd/stellar-rpc/internal/integrationtest/infrastructure/perf-eval/backfill-test/run-backfill.sh","budget":345},
{"label":"Go endpoint benchmarks","run_label":"go-bench","script":"cmd/stellar-rpc/internal/integrationtest/infrastructure/perf-eval/go-bench/run-go-bench.sh","budget":120,"root_volume_gb":50,"extra_env":"export BASELINE_REF=$BASELINE"}
]
EOF
)"
{
echo "target_sha=$SHA"
echo "pr_number=$PR"
echo "legs=$(jq -c . <<<"$LEGS")"
echo "legs=$LEGS"
} >> "$GITHUB_OUTPUT"

# The fan-out: one matrix entry per leg.
Expand All @@ -87,6 +101,9 @@ jobs:
run_label: ${{ matrix.leg.run_label }}
leg_script: ${{ matrix.leg.script }}
budget_minutes: ${{ matrix.leg.budget }}
# optional per-leg fields; fallbacks mirror the ec2-leg.yml defaults
root_volume_gb: ${{ matrix.leg.root_volume_gb || 500 }}
extra_env: ${{ matrix.leg.extra_env || '' }}

report:
name: Aggregate + report
Expand Down
7 changes: 4 additions & 3 deletions cmd/stellar-rpc/internal/db/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,14 @@ func BenchmarkTransactionFetch(b *testing.B) {
require.NoError(b, write.Commit(lcms[len(lcms)-1], nil))
reader := NewTransactionReader(log, db, passphrase)

randoms := make([]int, b.N)
for i := 0; b.Loop(); i++ {
Comment thread
Shaptic marked this conversation as resolved.
// fixed-size pool of pre-drawn indices (b.Loop owns the iteration count)
randoms := make([]int, 4096)
for i := range randoms {
randoms[i] = rand.Intn(len(lcms))
}

for i := 0; b.Loop(); i++ {
r := randoms[i]
r := randoms[i%len(randoms)]
tx, err := reader.GetTransaction(ctx, lcms[r].TransactionHash(0))
require.NoError(b, err)
assert.Equal(b, r%2 == 0, tx.Successful)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Backfill ingestion leg. Concatenated after bootstrap-common.sh in the rendered
# EC2 user-data, so it relies on that file's env, helpers, bootstrap_box, and
# run_leg. It hands off to `runner instantiate`, which builds stellar-rpc and
# times a backfill run against the pubnet datastore. The other half, `runner
# Backfill ingestion leg. Relies on bootstrap-common.sh's env, helpers,
# bootstrap_box, and run_leg. It hands off to `runner instantiate` to build
# stellar-rpc and time a backfill run against the datalake. The other half, `runner
# gather`, polls S3 for the result object.
LEG_TITLE="Backfill ingestion"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,32 @@ var backfillDoneRe = regexp.MustCompile(`Backfill process complete, ledgers \[(\
// runs a timed backfill, then publishes the verdict.
func instantiate(ctx context.Context) error {
var (
bucket = harness.Env("BUCKET", "stellar-rpc-ci-load-test")
region = harness.Env("REGION", "us-east-1")
workDir = harness.Env("WORK_DIR", "/data")
resultsFile = harness.Env("RESULTS_FILE", "/tmp/results.md")
resultKey = os.Getenv("RESULT_KEY")
targetSHA = os.Getenv("TARGET_SHA")
runID = harness.Env("RUN_ID", "manual")
env = harness.GetEnv()
// ~1 day by default for cheap test runs; the full week is 120960.
retention = harness.Env("HISTORY_RETENTION_WINDOW", "17280")
deadline = harness.Env("BACKFILL_DEADLINE", "4h")

binaryPath = filepath.Join(workDir, "stellar-rpc-bin") // built here (the repo checkout is in WORK_DIR)
binaryPath = filepath.Join(env["WORK_DIR"], "stellar-rpc-bin") // built here (the repo checkout is in WORK_DIR)
)
repoRoot, err := os.Getwd()
if err != nil {
return err
}
bail := func(format string, args ...any) error {
return harness.BailInstance(resultsFile, "Backfill ingestion", runID, targetSHA, fmt.Sprintf(format, args...))
return harness.BailInstance(env["RESULTS_FILE"], "Backfill ingestion", env["RUN_ID"], env["TARGET_SHA"],
fmt.Sprintf(format, args...))
}

want, err := strconv.Atoi(retention) // used to compare against ingested ledgers below
if err != nil {
return bail("parsing retention window %q: %v", retention, err)
}

awsCfg, err := config.LoadDefaultConfig(ctx, config.WithRegion(region))
awsCfg, err := config.LoadDefaultConfig(ctx, config.WithRegion(env["REGION"]))
if err != nil {
return bail("loading AWS config: %v", err)
}
fetch := &harness.S3Fetcher{Client: s3.NewFromConfig(awsCfg), Bucket: bucket}
fetch := &harness.S3Fetcher{Client: s3.NewFromConfig(awsCfg), Bucket: env["BUCKET"]}

if err := fetch.FetchVerified(ctx, "core/stellar-core.zst", corePath, true, "stellar-core"); err != nil {
return bail("%v", err)
Expand All @@ -83,12 +78,12 @@ func instantiate(ctx context.Context) error {
}

// fetch + write core config from SDK
coreCfg := filepath.Join(workDir, "captive-core-pubnet.cfg")
coreCfg := filepath.Join(env["WORK_DIR"], "captive-core-pubnet.cfg")
if err := os.WriteFile(coreCfg, ledgerbackend.PubnetDefaultConfig, 0o644); err != nil {
return bail("writing captive-core config: %v", err)
}

cfgPath, err := renderConfig(repoRoot, workDir, coreCfg, retention)
cfgPath, err := renderConfig(repoRoot, env["WORK_DIR"], coreCfg, retention)
if err != nil {
return bail("rendering config: %v", err)
}
Expand All @@ -108,12 +103,13 @@ func instantiate(ctx context.Context) error {
}
logger.Infof("backfill complete: %d ledgers [%d -> %d] in %s", ingested, lo, hi, elapsed.Round(time.Second))

md := renderMarkdown(targetSHA, retention, lo, hi, ingested, elapsed)
if err := os.WriteFile(resultsFile, []byte(md), 0o644); err != nil {
md := renderMarkdown(env["TARGET_SHA"], retention, lo, hi, ingested, elapsed)
if err := os.WriteFile(env["RESULTS_FILE"], []byte(md), 0o644); err != nil {
return bail("writing results: %v", err)
}
if err := harness.PublishResult(
ctx, fetch.Client, bucket, resultKey, "ok", runID, targetSHA, resultsFile, ""); err != nil {
ctx, fetch.Client, env["BUCKET"], env["RESULT_KEY"], "ok", env["RUN_ID"], env["TARGET_SHA"],
env["RESULTS_FILE"], ""); err != nil {
return bail("publishing result: %v", err)
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ bail() {
}
trap 'bail "unhandled error at line $LINENO while running: $BASH_COMMAND"' ERR

# persists the full box log to S3 even if instance terminated
# persists the full box log to S3 even if instance terminated. TERM is trapped
# too: a hard terminate mid-run (leg timeout) never reaches the EXIT trap.
upload_box_log() {
[ -n "$BUCKET" ] && [ -n "$RESULT_KEY" ] || return 0
aws s3 cp /var/log/user-data.log "s3://$BUCKET/${RESULT_KEY%/*}/user-data.log" >/dev/null 2>&1 || true
}
trap upload_box_log EXIT
trap upload_box_log EXIT TERM

# bootstrap_box installs the build toolchain and checks out TARGET_SHA into
# $WORK_DIR/stellar-rpc, leaving the shell cd'd at the repo root. Generic across
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Go endpoint benchmark leg. Relies on bootstrap-common.sh's env, helpers,
# bootstrap_box, and run_leg. The runner benches the candidate checkout against
# BASELINE_REF and publishes a benchstat comparison.
LEG_TITLE="Go endpoint benchmarks"

log "clearing stale go-bench state"
rm -rf "$WORK_DIR/stellar-rpc-baseline"
rm -f /tmp/baseline.txt /tmp/candidate.txt /tmp/benchstat.txt /tmp/bench-results.json

bootstrap_box
run_leg ./cmd/stellar-rpc/internal/integrationtest/infrastructure/perf-eval/go-bench/runner
Loading
Loading