Skip to content

Add C benchmark infrastructure to compare current branch vs v0.8.0#124

Closed
Copilot wants to merge 7 commits intomasterfrom
copilot/optimize-computation-efficiency
Closed

Add C benchmark infrastructure to compare current branch vs v0.8.0#124
Copilot wants to merge 7 commits intomasterfrom
copilot/optimize-computation-efficiency

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

Adds a self-contained C benchmark to quantify solve-time changes on this branch relative to v0.8.0, and applies the micro-optimizations that came out of that analysis.

Benchmark (benchmark/)

  • bench_qp.c — standalone C program, no Julia/MATLAB required. Generates dense random QPs at n=10–80, runs 3000 solves per size, takes best-of-7 passes to suppress OS jitter. Links against any libdaqpstat.a.
  • README.md — build instructions and two-version comparison workflow.
# Build and compare
gcc -O3 -fassociative-math -fno-signed-zeros -fno-trapping-math \
    -I include -I codegen benchmark/bench_qp.c build/libdaqpstat.a -lm -o bench
./bench

Measured results (identical flags: -O3 -fassociative-math -fno-signed-zeros -fno-trapping-math):

Version Grand total (5 sizes × 3000 solves, best-of-7)
v0.8.0 ~1.083 s
HEAD ~1.108 s (+2.3%)

Small problems (n≤20) are slightly faster; the regression concentrates at n≥60 and is under investigation.

Solver micro-optimisations (src/, include/)

  • daqp_dotstatic inline (include/factorization.h): was a cross-TU call preventing inlining and vectorisation at all call sites. No LTO required.
  • Scalar hoisting (src/auxiliary.c): work->lam_star[i] indexed 4–6 times per outer iteration in daqp_compute_primal_and_fval; hoisted to lam_i.
  • LDL_add D-update (src/factorization.c): local scaled variable avoids double-read of work->L[disp]; local sum used directly for singularity check instead of re-reading work->D[n_active].
  • Gill-1974 downdate (src/factorization.c): cache work->D[i] in Di to avoid two array reads; reorder w[r]/L[disp] update to break store-load dependency chain.
  • daqp_activate_constraints correctness fix (src/auxiliary.c): overdetermined initial working set now correctly distinguishes immutable (equality) constraints that cannot be silently deactivated, rather than blindly clearing all remaining active bits.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Improve computation efficiency in core C files Optimize core computational routines in daqp.c, auxiliary.c, factorization.c, utils.c Mar 20, 2026
Copilot AI requested a review from darnstrom March 20, 2026 16:24
Copilot AI changed the title Optimize core computational routines in daqp.c, auxiliary.c, factorization.c, utils.c Optimize core solver routines while preserving ANSI C compatibility Mar 20, 2026
…ranchless LDL copy, scalar hoisting

Co-authored-by: darnstrom <55484604+darnstrom@users.noreply.github.com>
Agent-Logs-Url: https://github.com/darnstrom/daqp/sessions/e10a68ed-b14f-434b-84b8-757f0d99a068
Copilot AI changed the title Optimize core solver routines while preserving ANSI C compatibility Optimize core solver routines: remove non-ANSI-C extensions, improve cache access patterns Mar 20, 2026
Co-authored-by: darnstrom <55484604+darnstrom@users.noreply.github.com>
Agent-Logs-Url: https://github.com/darnstrom/daqp/sessions/7c31f878-dc03-4642-beba-62cc34c53a82
…ew dependencies)

Co-authored-by: darnstrom <55484604+darnstrom@users.noreply.github.com>
Agent-Logs-Url: https://github.com/darnstrom/daqp/sessions/117a647f-ae4c-457d-a2db-67a4031dd13b
Copilot AI changed the title Optimize core solver routines: remove non-ANSI-C extensions, improve cache access patterns Performance optimizations for core DAQP solver routines (ANSI C, no new dependencies) Mar 20, 2026
Copilot AI changed the title Performance optimizations for core DAQP solver routines (ANSI C, no new dependencies) Add C benchmark infrastructure to compare current branch vs v0.8.0 Mar 20, 2026
@darnstrom darnstrom closed this Mar 23, 2026
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.

2 participants