Skip to content

[benchmark] Add activity-analysis headroom cases measuring master - #1874

Open
leetcodez wants to merge 1 commit into
vgvassilev:masterfrom
leetcodez:s3-activity-baselines
Open

[benchmark] Add activity-analysis headroom cases measuring master#1874
leetcodez wants to merge 1 commit into
vgvassilev:masterfrom
leetcodez:s3-activity-baselines

Conversation

@leetcodez

@leetcodez leetcodez commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This PR introduces benchmark/ActivityWaste.cpp, a set of microbenchmarks designed to measure and monitor tape allocation overhead on the master branch. These act as baseline regression targets for upcoming activity analysis and dead-code pruning passes in the Clad differentiator.
Each benchmark case is designed to bypass Clang's constant folding and Clad's TBR optimization, successfully
forcing the recording of non-linear passive or dead intermediate variables.

The table below documents the measured headroom (tape waste) on master for each structural pattern before any advanced
activity analysis pruning is applied:

Case Range (N / work) AllocBytes Min AllocBytes Max Expected Waste Optimization Target
interproc passive work 100 → 5000 ~411 KB (50) ~2.05 MB (250) ~410 KB → ~2 MB 0 (fully pruned)
dead struct field n 64 → 4096 ~8.2 KB (1) ~98.7 KB (12) ~8 KB 0 (fully pruned)
dead array chain n 1000 → 10000 ~8.2 KB (1) ~82.2 KB (10) ~8 KB → ~82 KB 0 (fully pruned)
branch-guarded n 64 → 4096 0 (0 slabs) ~32.9 KB (4) tape ∝ n 0 (fully pruned)
useful-not-varied reps 100 → 10000 ~24.7 KB (3) ~246.7 KB (30) dead adjoint chain 0 (fully pruned)

Related to issue #1873

@leetcodez
leetcodez marked this pull request as draft July 7, 2026 17:37

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 112. Check the log or trigger a new build to see more.

#include "clad/Differentiator/Differentiator.h"
#include <memory>

double dummy_out = 0; // Global to prevent Clang constant folding

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'dummy_out' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

double dummy_out = 0; // Global to prevent Clang constant folding
       ^


namespace {
struct MemoryManager : public benchmark::MemoryManager {
size_t cur_num_allocs = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "size_t" is directly included [misc-include-cleaner]

benchmark/ActivityWaste.cpp:2:

- #include <memory>
+ #include <cstddef>
+ #include <memory>

cur_max_bytes_used = 0;
}
void Stop(Result& result) override {
result.num_allocs = cur_num_allocs;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int64_t' (aka 'long') is implementation-defined [cppcoreguidelines-narrowing-conversions]

    result.num_allocs = cur_num_allocs;
                        ^

}
void Stop(Result& result) override {
result.num_allocs = cur_num_allocs;
result.max_bytes_used = cur_max_bytes_used;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int64_t' (aka 'long') is implementation-defined [cppcoreguidelines-narrowing-conversions]

    result.max_bytes_used = cur_max_bytes_used;
                            ^

Comment thread benchmark/ActivityWaste.cpp Outdated
result.max_bytes_used = cur_max_bytes_used;
}
};
static auto mm = std::unique_ptr<MemoryManager>(new MemoryManager());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'mm' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]

Suggested change
static auto mm = std::unique_ptr<MemoryManager>(new MemoryManager());
auto mm = std::unique_ptr<MemoryManager>(new MemoryManager());

Comment thread benchmark/ActivityWaste.cpp Outdated
result.max_bytes_used = cur_max_bytes_used;
}
};
static auto mm = std::unique_ptr<MemoryManager>(new MemoryManager());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use std::make_unique instead [modernize-make-unique]

Suggested change
static auto mm = std::unique_ptr<MemoryManager>(new MemoryManager());
static auto mm = std::make_unique<MemoryManager>();

Comment thread benchmark/ActivityWaste.cpp Outdated
result.max_bytes_used = cur_max_bytes_used;
}
};
static auto mm = std::unique_ptr<MemoryManager>(new MemoryManager());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'mm' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

static auto mm = std::unique_ptr<MemoryManager>(new MemoryManager());
            ^

Comment thread benchmark/ActivityWaste.cpp Outdated
}
};
static auto mm = std::unique_ptr<MemoryManager>(new MemoryManager());
static struct InstrumentationRegistrer {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: class 'InstrumentationRegistrer' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

static struct InstrumentationRegistrer {
              ^

Comment thread benchmark/ActivityWaste.cpp Outdated
static struct InstrumentationRegistrer {
InstrumentationRegistrer() { benchmark::RegisterMemoryManager(mm.get()); }
~InstrumentationRegistrer() { benchmark::RegisterMemoryManager(nullptr); }
} __mem_mgr_register;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: '__mem_mgr_register' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]

benchmark/ActivityWaste.cpp:23:

- static struct InstrumentationRegistrer {
+ struct InstrumentationRegistrer {

Comment thread benchmark/ActivityWaste.cpp Outdated
static struct InstrumentationRegistrer {
InstrumentationRegistrer() { benchmark::RegisterMemoryManager(mm.get()); }
~InstrumentationRegistrer() { benchmark::RegisterMemoryManager(nullptr); }
} __mem_mgr_register;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: declaration uses identifier '__mem_mgr_register', which is a reserved identifier [bugprone-reserved-identifier]

} __mem_mgr_register;
  ^

this fix will not be applied because it overlaps with another fix

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@leetcodez
leetcodez force-pushed the s3-activity-baselines branch from 3a48c1b to 6f0d65e Compare July 7, 2026 18:07

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 105. Check the log or trigger a new build to see more.

@@ -0,0 +1,255 @@
#include "clad/Differentiator/Differentiator.h"
#include <memory>
#include "benchmark/benchmark.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: #includes are not sorted properly [llvm-include-order]

Suggested change
#include "benchmark/benchmark.h"
#include "benchmark/benchmark.h"
#include <memory>


namespace {
struct MemoryManager : public benchmark::MemoryManager {
size_t cur_num_allocs = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "size_t" is directly included [misc-include-cleaner]

benchmark/ActivityWaste.cpp:1:

- #include <memory>
+ #include <cstddef>
+ #include <memory>

Comment thread benchmark/ActivityWaste.cpp Outdated
static struct InstrumentationRegistrer {
InstrumentationRegistrer() { benchmark::RegisterMemoryManager(mm.get()); }
~InstrumentationRegistrer() { benchmark::RegisterMemoryManager(nullptr); }
} __mem_mgr_register;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: '__mem_mgr_register' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]

benchmark/ActivityWaste.cpp:22:

- static struct InstrumentationRegistrer {
+ struct InstrumentationRegistrer {

Comment thread benchmark/ActivityWaste.cpp Outdated
static struct InstrumentationRegistrer {
InstrumentationRegistrer() { benchmark::RegisterMemoryManager(mm.get()); }
~InstrumentationRegistrer() { benchmark::RegisterMemoryManager(nullptr); }
} __mem_mgr_register;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for variable '__mem_mgr_register' [readability-identifier-naming]

} __mem_mgr_register;
  ^

this fix will not be applied because it overlaps with another fix

Comment thread benchmark/ActivityWaste.cpp Outdated
static struct InstrumentationRegistrer {
InstrumentationRegistrer() { benchmark::RegisterMemoryManager(mm.get()); }
~InstrumentationRegistrer() { benchmark::RegisterMemoryManager(nullptr); }
} __mem_mgr_register;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable '__mem_mgr_register' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

} __mem_mgr_register;
  ^

~InstrumentationRegistrer() { benchmark::RegisterMemoryManager(nullptr); }
} __mem_mgr_register;

class AddBMCounterRAII {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: class 'AddBMCounterRAII' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

class AddBMCounterRAII {
      ^

} __mem_mgr_register;

class AddBMCounterRAII {
MemoryManager& MemMgr;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for private member 'MemMgr' [readability-identifier-naming]

Suggested change
MemoryManager& MemMgr;
MemoryManager& m_MemMgr;

benchmark/ActivityWaste.cpp:33:

-       : MemMgr(m), State(s) {
+       : m_MemMgr(m), State(s) {

benchmark/ActivityWaste.cpp:40:

-     State.counters["AllocN"] = MemMgr.cur_num_allocs / it;
-     State.counters["DellocN"] = MemMgr.cur_num_deallocs / it;
-     State.counters["AllocBytes"] = MemMgr.cur_max_bytes_used / it;
+     State.counters["AllocN"] = m_MemMgr.cur_num_allocs / it;
+     State.counters["DellocN"] = m_MemMgr.cur_num_deallocs / it;
+     State.counters["AllocBytes"] = m_MemMgr.cur_max_bytes_used / it;

} __mem_mgr_register;

class AddBMCounterRAII {
MemoryManager& MemMgr;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: member 'MemMgr' of type 'MemoryManager &' is a reference [cppcoreguidelines-avoid-const-or-ref-data-members]

  MemoryManager& MemMgr;
                 ^


class AddBMCounterRAII {
MemoryManager& MemMgr;
benchmark::State& State;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for private member 'State' [readability-identifier-naming]

Suggested change
benchmark::State& State;
benchmark::State& m_State;

benchmark/ActivityWaste.cpp:33:

-       : MemMgr(m), State(s) {
+       : MemMgr(m), m_State(s) {

benchmark/ActivityWaste.cpp:39:

-     const unsigned long it = State.iterations();
-     State.counters["AllocN"] = MemMgr.cur_num_allocs / it;
-     State.counters["DellocN"] = MemMgr.cur_num_deallocs / it;
-     State.counters["AllocBytes"] = MemMgr.cur_max_bytes_used / it;
+     const unsigned long it = m_State.iterations();
+     m_State.counters["AllocN"] = MemMgr.cur_num_allocs / it;
+     m_State.counters["DellocN"] = MemMgr.cur_num_deallocs / it;
+     m_State.counters["AllocBytes"] = MemMgr.cur_max_bytes_used / it;


class AddBMCounterRAII {
MemoryManager& MemMgr;
benchmark::State& State;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: member 'State' of type 'benchmark::State &' is a reference [cppcoreguidelines-avoid-const-or-ref-data-members]

  benchmark::State& State;
                    ^

@leetcodez
leetcodez force-pushed the s3-activity-baselines branch 3 times, most recently from 49fc827 to 42ade6f Compare July 7, 2026 21:01

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 93. Check the log or trigger a new build to see more.

#include "clad/Differentiator/Differentiator.h"
#include <cstddef>
#include <memory>
#include "benchmark/benchmark.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: #includes are not sorted properly [llvm-include-order]

Suggested change
#include "benchmark/benchmark.h"
#include "benchmark/benchmark.h"
#include <cstddef>
#include <memory>

result.max_bytes_used = cur_max_bytes_used;
}
};
auto mm = std::make_unique<MemoryManager>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'mm' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

auto mm = std::make_unique<MemoryManager>();
     ^

}
};
auto mm = std::make_unique<MemoryManager>();
struct InstrumentationRegistrer {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: class 'InstrumentationRegistrer' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

struct InstrumentationRegistrer {
       ^

struct InstrumentationRegistrer {
InstrumentationRegistrer() { benchmark::RegisterMemoryManager(mm.get()); }
~InstrumentationRegistrer() { benchmark::RegisterMemoryManager(nullptr); }
} MemMgrRegister;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'MemMgrRegister' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

} MemMgrRegister;
  ^

}
~AddBMCounterRAII() {
const unsigned long it = State.iterations();
State.counters["AllocN"] = MemMgr.cur_num_allocs / it;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'unsigned long' to 'double' [cppcoreguidelines-narrowing-conversions]

    State.counters["AllocN"] = MemMgr.cur_num_allocs / it;
                               ^

}
~AddBMCounterRAII() {
const unsigned long it = State.iterations();
State.counters["AllocN"] = MemMgr.cur_num_allocs / it;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: result of integer division used in a floating point context; possible loss of precision [bugprone-integer-division]

    State.counters["AllocN"] = MemMgr.cur_num_allocs / it;
                               ^

~AddBMCounterRAII() {
const unsigned long it = State.iterations();
State.counters["AllocN"] = MemMgr.cur_num_allocs / it;
State.counters["DellocN"] = MemMgr.cur_num_deallocs / it;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'unsigned long' to 'double' [cppcoreguidelines-narrowing-conversions]

    State.counters["DellocN"] = MemMgr.cur_num_deallocs / it;
                                ^

~AddBMCounterRAII() {
const unsigned long it = State.iterations();
State.counters["AllocN"] = MemMgr.cur_num_allocs / it;
State.counters["DellocN"] = MemMgr.cur_num_deallocs / it;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: result of integer division used in a floating point context; possible loss of precision [bugprone-integer-division]

    State.counters["DellocN"] = MemMgr.cur_num_deallocs / it;
                                ^

const unsigned long it = State.iterations();
State.counters["AllocN"] = MemMgr.cur_num_allocs / it;
State.counters["DellocN"] = MemMgr.cur_num_deallocs / it;
State.counters["AllocBytes"] = MemMgr.cur_max_bytes_used / it;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'unsigned long' to 'double' [cppcoreguidelines-narrowing-conversions]

    State.counters["AllocBytes"] = MemMgr.cur_max_bytes_used / it;
                                   ^

const unsigned long it = State.iterations();
State.counters["AllocN"] = MemMgr.cur_num_allocs / it;
State.counters["DellocN"] = MemMgr.cur_num_deallocs / it;
State.counters["AllocBytes"] = MemMgr.cur_max_bytes_used / it;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: result of integer division used in a floating point context; possible loss of precision [bugprone-integer-division]

    State.counters["AllocBytes"] = MemMgr.cur_max_bytes_used / it;
                                   ^

@leetcodez
leetcodez force-pushed the s3-activity-baselines branch from 42ade6f to 6689ff2 Compare July 7, 2026 21:29

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 83. Check the log or trigger a new build to see more.

mm->cur_num_allocs++;
mm->cur_max_bytes_used += size;
}
return malloc(size);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not manage memory manually; consider a container or a smart pointer [cppcoreguidelines-no-malloc]

  return malloc(size);
         ^

mm->cur_num_allocs++;
mm->cur_max_bytes_used += size;
}
return malloc(size);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "malloc" is directly included [misc-include-cleaner]

benchmark/ActivityWaste.cpp:3:

- #include <memory>
+ #include <cstdlib>
+ #include <memory>

mm->cur_num_allocs++;
mm->cur_max_bytes_used += size;
}
return malloc(size);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: returning a newly created resource of type 'void *' or 'gsl::owner<>' from a function whose return type is not 'gsl::owner<>' [cppcoreguidelines-owning-memory]

  return malloc(size);
  ^

void operator delete(void* p) noexcept {
if (mm)
mm->cur_num_deallocs++;
free(p);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: calling legacy resource function without passing a 'gsl::owner<>' [cppcoreguidelines-owning-memory]

  free(p);
  ^

void operator delete(void* p) noexcept {
if (mm)
mm->cur_num_deallocs++;
free(p);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not manage memory manually; use RAII [cppcoreguidelines-no-malloc]

  free(p);
  ^

void operator delete(void* p) noexcept {
if (mm)
mm->cur_num_deallocs++;
free(p);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "free" is directly included [misc-include-cleaner]

  free(p);
  ^

double positive_control(const double* x, int n) {
double r = 0;
for (int i = 0; i < n; ++i) {
double t = x[i] * x[i];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

    double t = x[i] * x[i];
                      ^

double positive_control(const double* x, int n) {
double r = 0;
for (int i = 0; i < n; ++i) {
double t = x[i] * x[i];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

    double t = x[i] * x[i];
               ^

}

static void BM_PositiveControl(benchmark::State& state) {
int n = state.range(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'int64_t' (aka 'long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

  int n = state.range(0);
          ^


static void BM_PositiveControl(benchmark::State& state) {
int n = state.range(0);
double* x = new double[n];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: initializing non-owner 'double *' with a newly created 'gsl::owner<>' [cppcoreguidelines-owning-memory]

  double* x = new double[n];
  ^

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 73. Check the log or trigger a new build to see more.


static void BM_PositiveControl(benchmark::State& state) {
int n = state.range(0);
double* x = new double[n];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use auto when initializing with new to avoid duplicating the type name [modernize-use-auto]

Suggested change
double* x = new double[n];
auto* x = new double[n];

static void BM_PositiveControl(benchmark::State& state) {
int n = state.range(0);
double* x = new double[n];
double* dx = new double[n];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: initializing non-owner 'double *' with a newly created 'gsl::owner<>' [cppcoreguidelines-owning-memory]

  double* dx = new double[n];
  ^

static void BM_PositiveControl(benchmark::State& state) {
int n = state.range(0);
double* x = new double[n];
double* dx = new double[n];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use auto when initializing with new to avoid duplicating the type name [modernize-use-auto]

Suggested change
double* dx = new double[n];
auto* dx = new double[n];

double* x = new double[n];
double* dx = new double[n];
for (int i = 0; i < n; ++i)
x[i] = 0.5;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

    x[i] = 0.5;
    ^

AddBMCounterRAII c(*mm.get(), state);
for (auto _ : state) {
for (int i = 0; i < n; ++i)
dx[i] = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

        dx[i] = 0;
        ^

benchmark::DoNotOptimize(dx);
}
}
delete[] x;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]

  delete[] x;
  ^
Additional context

benchmark/ActivityWaste.cpp:71: variable declared here

  double* x = new double[n];
  ^

}
}
delete[] x;
delete[] dx;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]

  delete[] dx;
  ^
Additional context

benchmark/ActivityWaste.cpp:72: variable declared here

  double* dx = new double[n];
  ^

double interproc_passive(const double* x, int n, int work) {
double r = 0;
for (int i = 0; i < n; ++i)
r += inner_accumulate(x[i], work);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

    r += inner_accumulate(x[i], work);
                          ^


static void BM_InterprocPassive(benchmark::State& state) {
const int n = 50;
int work = state.range(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'int64_t' (aka 'long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

  int work = state.range(0);
             ^

static void BM_InterprocPassive(benchmark::State& state) {
const int n = 50;
int work = state.range(0);
double x[n], dx[n];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays]

  double x[n], dx[n];
  ^

@leetcodez
leetcodez force-pushed the s3-activity-baselines branch from 1e8995d to 201aa29 Compare July 11, 2026 12:58
@leetcodez
leetcodez marked this pull request as ready for review July 11, 2026 12:58

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 64. Check the log or trigger a new build to see more.

mm->cur_num_allocs++;
mm->cur_max_bytes_used += size;
}
return malloc(size);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "malloc" is directly included [misc-include-cleaner]

benchmark/ActivityWaste.cpp:2:

- #include <memory>
+ #include <cstdlib>
+ #include <memory>

static void BM_InterprocPassive(benchmark::State& state) {
const int n = 50;
int work = state.range(0);
double x[n], dx[n];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]

Suggested change
double x[n], dx[n];
double x[n];
double dx[n];

int work = state.range(0);
double x[n], dx[n];
for (int i = 0; i < n; ++i) {
x[i] = 0.5;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index]

    x[i] = 0.5;
    ^

double x[n], dx[n];
for (int i = 0; i < n; ++i) {
x[i] = 0.5;
dx[i] = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index]

    dx[i] = 0;
    ^

AddBMCounterRAII c(*mm.get(), state);
for (auto _ : state) {
for (int i = 0; i < n; ++i)
dx[i] = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index]

      dx[i] = 0;
      ^

AddBMCounterRAII c(*mm.get(), state);
for (auto _ : state) {
for (int i = 0; i < n; ++i)
dx[i] = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use range-based for loop instead [modernize-loop-convert]

Suggested change
dx[i] = 0;
for (double & i : dx)
i = 0;

double dead_struct_field(const double* x, int n) {
double r = 0;
for (int i = 0; i < n; ++i) {
Particle p;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: uninitialized record type: 'p' [cppcoreguidelines-pro-type-member-init]

Suggested change
Particle p;
Particle p{};

double r = 0;
for (int i = 0; i < n; ++i) {
Particle p;
p.active1 = x[i];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

    p.active1 = x[i];
                ^

for (int i = 0; i < n; ++i) {
Particle p;
p.active1 = x[i];
p.active2 = x[i] * x[i];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

    p.active2 = x[i] * x[i];
                       ^

for (int i = 0; i < n; ++i) {
Particle p;
p.active1 = x[i];
p.active2 = x[i] * x[i];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

    p.active2 = x[i] * x[i];
                ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant