Skip to content

Commit e48c672

Browse files
committed
chore: Remove extraneous comments and script output prefixes from scripts and benchmark code.
1 parent e06a8ac commit e48c672

3 files changed

Lines changed: 13 additions & 26 deletions

File tree

run_tests.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ set -e
77

88
BASE_DIR=$(pwd)
99
ALLOC_DIR="$BASE_DIR/allocators"
10-
# Argument parsing
1110
FILTER_ALLOC=""
1211
TEST_ARGS=""
1312

@@ -42,7 +41,6 @@ run_test() {
4241
local extra_cflags=$3
4342
local extra_ldflags=$4
4443

45-
# Skip if we are filtering for a different allocator
4644
if [ ! -z "$FILTER_ALLOC" ] && [ "$FILTER_ALLOC" != "$name" ]; then
4745
return 0
4846
fi
@@ -97,9 +95,7 @@ if [ -z "$CURRENT_CUSTOM_ALLOC" ]; then
9795
fi
9896

9997
if [ -f "$CURRENT_CUSTOM_ALLOC" ]; then
100-
# We allow "custom" or "skeleton" as filters for this slot
10198
if [ ! -z "$FILTER_ALLOC" ] && [ "$FILTER_ALLOC" != "custom" ] && [ "$FILTER_ALLOC" != "skeleton" ] && [ "$FILTER_ALLOC" != "$CURRENT_CUSTOM_NAME" ]; then
102-
# Skip
10399
:
104100
else
105101
run_test "$CURRENT_CUSTOM_NAME" "$CURRENT_CUSTOM_ALLOC" "$CUSTOM_CFLAGS" "$CUSTOM_LDFLAGS"

setup_allocators.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ set -e
77
BASE_DIR=$(pwd)
88
ALLOC_DIR="$BASE_DIR/allocators"
99

10-
echo "[*] Checking for build dependencies..."
10+
echo "Checking for build dependencies..."
1111
for cmd in git cmake autoconf automake make cc; do
1212
if ! command -v $cmd &> /dev/null; then
13-
echo "[!] Error: $cmd is not installed."
13+
echo "Error: $cmd is not installed."
1414
exit 1
1515
fi
1616
done
1717

18-
echo "[*] Setting up dependencies in $ALLOC_DIR..."
18+
echo "Setting up dependencies in $ALLOC_DIR..."
1919
mkdir -p "$ALLOC_DIR"
2020

2121

2222
MIMALLOC_DIR="$ALLOC_DIR/mimalloc/mimalloc_src"
2323
if [ ! -d "$MIMALLOC_DIR" ]; then
24-
echo "[*] Cloning mimalloc..."
24+
echo "Cloning mimalloc..."
2525
git clone https://github.com/microsoft/mimalloc "$MIMALLOC_DIR"
2626
else
27-
echo "[*] mimalloc already cloned."
27+
echo "mimalloc already cloned."
2828
fi
2929

3030
# Build Mimalloc (Secure/Debug)
31-
echo "[*] Building mimalloc (secure)..."
31+
echo "Building mimalloc (secure)..."
3232
mkdir -p "$BASE_DIR/build_secure"
3333
cd "$BASE_DIR/build_secure"
3434
cmake "$MIMALLOC_DIR" -DMI_SECURE=ON -DMI_BUILD_SHARED=OFF -DMI_BUILD_TESTS=OFF
@@ -39,14 +39,14 @@ JEMALLOC_DIR="$ALLOC_DIR/jemalloc/jemalloc_src"
3939
mkdir -p "$ALLOC_DIR/jemalloc"
4040

4141
if [ ! -d "$JEMALLOC_DIR" ]; then
42-
echo "[*] Cloning jemalloc..."
42+
echo "Cloning jemalloc..."
4343
git clone https://github.com/jemalloc/jemalloc "$JEMALLOC_DIR"
4444
else
45-
echo "[*] jemalloc already cloned."
45+
echo "jemalloc already cloned."
4646
fi
4747

4848
# Build Jemalloc (Static, Prefixed)
49-
echo "[*] Building jemalloc..."
49+
echo "Building jemalloc..."
5050
cd "$JEMALLOC_DIR"
5151
if [ ! -f "configure" ]; then
5252
./autogen.sh
@@ -60,6 +60,5 @@ fi
6060
make -j$(nproc)
6161
cd "$BASE_DIR"
6262

63-
echo "[+] Setup complete! Libraries built."
6463
echo " - Mimalloc: build_secure/libmimalloc-secure.a"
6564
echo " - Jemalloc: allocators/jemalloc/jemalloc_src/lib/libjemalloc.a"

src/benchmarks/bench_synthetic.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ static void wl_syn_001_run(allocator_t *alloc, bench_metrics_t *metrics) {
1212
latency_samples_t lat;
1313
latency_init(&lat);
1414

15-
// Warmup
1615
for (size_t i = 0; i < BENCH_WARMUP_OPS; i++) {
1716
void *p = alloc->malloc(64);
1817
alloc->free(p);
@@ -49,14 +48,13 @@ static void wl_syn_002_run(allocator_t *alloc, bench_metrics_t *metrics) {
4948
bench_rng_t rng;
5049
bench_rng_seed(&rng, 0x12345678);
5150

52-
// Warmup
5351
for (size_t i = 0; i < BENCH_WARMUP_OPS; i++) {
5452
size_t sz = bench_rng_range(&rng, 16, 256);
5553
void *p = alloc->malloc(sz);
5654
alloc->free(p);
5755
}
5856

59-
bench_rng_seed(&rng, 0x12345678); // Reset for reproducibility
57+
bench_rng_seed(&rng, 0x12345678);
6058
uint64_t start = bench_get_time_ns();
6159

6260
for (size_t i = 0; i < iterations; i++) {
@@ -151,7 +149,7 @@ static void wl_syn_005_run(allocator_t *alloc, bench_metrics_t *metrics) {
151149
latency_samples_t lat;
152150
latency_init(&lat);
153151

154-
for (size_t i = 0; i < 1000; i++) { // Smaller warmup for large allocs
152+
for (size_t i = 0; i < 1000; i++) {
155153
void *p = alloc->malloc(1048576);
156154
alloc->free(p);
157155
}
@@ -163,7 +161,7 @@ static void wl_syn_005_run(allocator_t *alloc, bench_metrics_t *metrics) {
163161
void *p = alloc->malloc(1048576);
164162
alloc->free(p);
165163

166-
if (i % 10 == 0) { // Sample more frequently for fewer iterations
164+
if (i % 10 == 0) {
167165
latency_record(&lat, bench_get_time_ns() - op_start);
168166
}
169167
}
@@ -227,9 +225,7 @@ static void wl_syn_007_run(allocator_t *alloc, bench_metrics_t *metrics) {
227225
size_t total_ops = 0;
228226

229227
while (total_ops < iterations) {
230-
// Allocate batch
231228
for (size_t i = 0; i < batch_size && total_ops < iterations; i++) {
232-
// Power-law: mostly small, some large
233229
size_t sz = bench_rng_powerlaw(&rng, 16, 65536, 2.0);
234230
uint64_t op_start = bench_get_time_ns();
235231
batch[i] = alloc->malloc(sz);
@@ -240,7 +236,6 @@ static void wl_syn_007_run(allocator_t *alloc, bench_metrics_t *metrics) {
240236
total_ops++;
241237
}
242238

243-
// Free batch
244239
for (size_t i = 0; i < batch_size; i++) {
245240
if (batch[i]) {
246241
alloc->free(batch[i]);
@@ -268,7 +263,6 @@ static void wl_syn_008_run(allocator_t *alloc, bench_metrics_t *metrics) {
268263
for (size_t i = 0; i < iterations; i++) {
269264
void *p = alloc->malloc(16);
270265

271-
// Grow: 16 → 32 → 64 → 128 → 256 → 512 → 1024 → 2048 → 4096
272266
for (size_t sz = 32; sz <= 4096; sz *= 2) {
273267
uint64_t op_start = bench_get_time_ns();
274268
p = alloc->realloc(p, sz);
@@ -282,7 +276,6 @@ static void wl_syn_008_run(allocator_t *alloc, bench_metrics_t *metrics) {
282276
}
283277

284278
uint64_t elapsed = bench_get_time_ns() - start;
285-
// Count each realloc chain as 8 operations
286279
metrics->throughput_ops_sec =
287280
(double)(iterations * 8) / ((double)elapsed / 1e9);
288281
metrics->rss_bytes = bench_get_rss();
@@ -302,7 +295,6 @@ static void wl_syn_009_run(allocator_t *alloc, bench_metrics_t *metrics) {
302295
for (size_t i = 0; i < iterations; i++) {
303296
void *p = alloc->malloc(4096);
304297

305-
// Shrink: 4096 → 2048 → 1024 → 512 → 256 → 128 → 64 → 32 → 16
306298
for (size_t sz = 2048; sz >= 16; sz /= 2) {
307299
uint64_t op_start = bench_get_time_ns();
308300
p = alloc->realloc(p, sz);
@@ -334,7 +326,7 @@ static void wl_syn_010_run(allocator_t *alloc, bench_metrics_t *metrics) {
334326

335327
for (size_t i = 0; i < BENCH_WARMUP_OPS; i++) {
336328
size_t nmemb = bench_rng_range(&rng, 1, 256);
337-
size_t size = bench_rng_range(&rng, 16, 16); // 16-4096 total
329+
size_t size = bench_rng_range(&rng, 16, 16);
338330
void *p = alloc->calloc(nmemb, size);
339331
alloc->free(p);
340332
}

0 commit comments

Comments
 (0)