Skip to content

Commit 2e7bd1c

Browse files
authored
Merge branch 'main' into TAT-1043-feat-add-perps-slippage-config
2 parents 50af04c + bfe479c commit 2e7bd1c

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

.github/scripts/benchmark-stats-commit.sh

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,21 @@ assemble_performance_data() {
122122

123123
# Merge the startup group into presets (only if any startup files were found).
124124
if [[ "${page_load_json}" != "{}" ]]; then
125-
presets_json=$(echo "${presets_json}" | jq --argjson pl "${page_load_json}" '. + {"pageLoad": $pl}')
125+
# Keep large JSON off argv (ARG_MAX): presets_json via stdin, page_load_json
126+
# via a temp file read with --slurpfile.
127+
pl_file="$(mktemp)"
128+
printf '%s' "${page_load_json}" >"${pl_file}"
129+
presets_json=$(printf '%s' "${presets_json}" | jq --slurpfile pl "${pl_file}" '. + {"pageLoad": $pl[0]}')
130+
rm -f "${pl_file}"
126131
fi
127132

128133
echo "Collected ${file_count} preset(s)" >&2
129134

130-
jq -n \
135+
# presets_json can exceed ARG_MAX; pass it via stdin instead of as a jq argument
136+
# (a too-large argv makes the kernel fail to exec jq with "Argument list too long").
137+
printf '%s' "${presets_json}" | jq \
131138
--argjson timestamp "$(date +%s000)" \
132-
--argjson presets "${presets_json}" \
133-
'{ timestamp: $timestamp, presets: $presets }'
139+
'{ timestamp: $timestamp, presets: . }'
134140
}
135141

136142
# Resolve stats file and assemble data
@@ -191,8 +197,14 @@ fi
191197

192198
TEMP_FILE="${STATS_FILE}.tmp"
193199

194-
jq --arg sha "${HEAD_COMMIT_HASH}" --argjson data "${COMMIT_DATA}" \
195-
'. + {($sha): $data}' "${STATS_FILE}" > "${TEMP_FILE}"
200+
# COMMIT_DATA wraps presets_json and is strictly larger, so it can exceed
201+
# ARG_MAX too. Read it via --slurpfile from a temp file rather than passing
202+
# the blob on argv.
203+
data_file="$(mktemp)"
204+
printf '%s' "${COMMIT_DATA}" >"${data_file}"
205+
jq --arg sha "${HEAD_COMMIT_HASH}" --slurpfile data "${data_file}" \
206+
'. + {($sha): $data[0]}' "${STATS_FILE}" > "${TEMP_FILE}"
207+
rm -f "${data_file}"
196208
mv "${TEMP_FILE}" "${STATS_FILE}"
197209

198210
git add "${STATS_FILE}"

0 commit comments

Comments
 (0)