Skip to content

Commit bb612b5

Browse files
committed
refactor: source-level audit — fix doc inaccuracies, modernize build, unify style
Documentation accuracy: - README: CMake 3.22+ → 3.20+ (matches CMakeLists.txt) - CLAUDE.md, docs index: "C++17 minimum" → C++20 required - benchmarks/README: fix script path to tools/performance/ - SECURITY.md: 1.0.x → 1.3.x Build system: - Remove redundant BENCHMARK_MAIN() from all 10 bench files (CMake template already links benchmark::benchmark_main) - Replace directory-level include_directories() with hpc_headers INTERFACE library and target-based linkage throughout - Fix pre-push hook: --cached (always empty) → @{push}..HEAD Style: - Unify #include "hpc/..." → <hpc/...> (3 files) - Translate all Chinese source comments to English Content trimming: - README doc entry points: 9 links → 4 - CLAUDE.md "avoid reintroducing": 11 items → 4
1 parent 58e0f67 commit bb612b5

29 files changed

Lines changed: 51 additions & 85 deletions

.githooks/pre-push

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ set -euo pipefail
66
repo_root="$(git rev-parse --show-toplevel)"
77
cd "$repo_root"
88

9+
# Compare against the upstream tracking branch (or origin/master as fallback)
10+
upstream=$(git rev-parse --abbrev-ref @{push} 2>/dev/null || echo "origin/master")
11+
912
# Only run format check if there are C++ files changed
10-
if git diff --name-only --cached | grep -qE '\.(cpp|hpp|h|cxx|cc)$'; then
13+
if git diff --name-only "$upstream"..HEAD | grep -qE '\.(cpp|hpp|h|cxx|cc)$'; then
1114
echo "Checking C++ formatting..."
1215
./scripts/format.sh --check || {
1316
echo "❌ Format check failed. Run ./scripts/format.sh to fix."

.github/SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
| Version | Supported |
66
| ------- | ------------------ |
7-
| 1.0.x | :white_check_mark: |
7+
| 1.3.x | :white_check_mark: |
88

99
## Reporting a Vulnerability
1010

CLAUDE.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This repository is in **closure and hardening mode** (archive-ready for low-freq
66

77
## C++ Standards and Style
88

9-
- **Target**: C++17 minimum, C++20 where beneficial
9+
- **Target**: C++20 (required, `CMAKE_CXX_STANDARD_REQUIRED ON`)
1010
- **Style**: enforced via `.clang-format` (Google style, 100 chars)
1111
- **Memory safety**: prefer RAII, smart pointers, avoid raw `new/delete`
1212
- **Performance**: always measure with benchmarks before claiming improvement
@@ -73,14 +73,7 @@ The `.vscode/` directory is **gitignored**. Use `.clangd`, `.editorconfig`, and
7373

7474
## Things to avoid reintroducing
7575

76-
- HonKit / GitBook-era configuration
77-
- `.kiro/`-style legacy spec structures
78-
- duplicate changelog surfaces with no maintenance value
7976
- non-blocking CI steps that hide real failures
80-
- generic AI instructions that do not reflect this repository
8177
- per-example shim headers that only re-export a canonical `include/hpc/` header
82-
- CMake anti-pattern directories with no runnable target
8378
- wrapper scripts that duplicate `cmake --preset` commands
84-
- split root-level design md files (consolidated into `docs/META.md`)
85-
- English-only documentation surfaces (all bilingual surfaces now have zh parity)
86-
- unused custom Vue components in the docs theme
79+
- English-only documentation surfaces (all bilingual surfaces must have zh parity)

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ set(CMAKE_CXX_EXTENSIONS OFF)
1414
# Export compile commands for IDE support
1515
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1616

17-
# Add core include directory for all targets
18-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
17+
# Canonical header-only library (include/hpc/)
18+
add_library(hpc_headers INTERFACE)
19+
target_include_directories(hpc_headers INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
1920

2021
# Include custom CMake modules
2122
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,14 @@ cmake --preset=ubsan && cmake --build build/ubsan && ctest --preset=ubsan
7878
## Documentation entry points
7979

8080
- **Docs site:** <https://lessup.github.io/cpp-high-performance-guide/>
81-
- **Academy:** [`docs/en/academy/index.md`](docs/en/academy/index.md)
82-
- **Architecture:** [`docs/en/architecture/index.md`](docs/en/architecture/index.md)
8381
- **Playbook:** [`docs/en/playbook/index.md`](docs/en/playbook/index.md)
8482
- **Reference:** [`docs/en/reference/index.md`](docs/en/reference/index.md)
85-
- **Research:** [`docs/en/research/index.md`](docs/en/research/index.md)
86-
- **Quick start inside the playbook:** [`docs/en/getting-started/quickstart.md`](docs/en/getting-started/quickstart.md)
87-
- **Profiling guide:** [`docs/en/guides/profiling-guide.md`](docs/en/guides/profiling-guide.md)
88-
- **Validation & sanitizers:** [`docs/en/guides/validation.md`](docs/en/guides/validation.md)
8983
- **Chinese entry:** `README.zh-CN.md` and `docs/zh/`
9084

9185
## Tech stack
9286

9387
- **Language:** C++20
94-
- **Build:** CMake 3.22+, Ninja
88+
- **Build:** CMake 3.20+, Ninja
9589
- **Testing:** Google Test, RapidCheck
9690
- **Benchmarking:** Google Benchmark
9791
- **Docs:** VitePress + GitHub Pages

README.zh-CN.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,14 @@ cmake --preset=ubsan && cmake --build build/ubsan && ctest --preset=ubsan
7878
## 文档入口
7979

8080
- **文档站:** <https://lessup.github.io/cpp-high-performance-guide/>
81-
- **学院:** [`docs/zh/academy/index.md`](docs/zh/academy/index.md)
82-
- **架构:** [`docs/zh/architecture/index.md`](docs/zh/architecture/index.md)
8381
- **实践手册:** [`docs/zh/playbook/index.md`](docs/zh/playbook/index.md)
8482
- **参考:** [`docs/zh/reference/index.md`](docs/zh/reference/index.md)
85-
- **研究:** [`docs/zh/research/index.md`](docs/zh/research/index.md)
86-
- **实践手册内的快速开始:** [`docs/zh/getting-started/quickstart.md`](docs/zh/getting-started/quickstart.md)
87-
- **学习路径:** [`docs/zh/guides/learning-path.md`](docs/zh/guides/learning-path.md)
88-
- **性能分析指南:** [`docs/zh/guides/profiling-guide.md`](docs/zh/guides/profiling-guide.md)
89-
- **验证与 Sanitizer:** [`docs/zh/guides/validation.md`](docs/zh/guides/validation.md)
9083
- **英文入口:** `README.md``docs/en/`
9184

9285
## 技术栈
9386

9487
- **语言:** C++20
95-
- **构建:** CMake 3.22+、Ninja
88+
- **构建:** CMake 3.20+、Ninja
9689
- **测试:** Google Test、RapidCheck
9790
- **基准测试:** Google Benchmark
9891
- **文档:** VitePress + GitHub Pages

benchmarks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cmake --build build/release
3333
4. Compare the two runs:
3434

3535
```bash
36-
python3 scripts/compare_benchmarks.py simd-baseline.json simd-candidate.json --threshold 10
36+
python3 tools/performance/benchmark_compare.py simd-baseline.json simd-candidate.json --threshold 10
3737
```
3838

3939
The script prints a per-benchmark table with baseline time, candidate time, and

cmake/ExampleTemplate.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ function(hpc_add_example)
4040

4141
# Enable sanitizers if configured
4242
hpc_enable_sanitizers(${ARG_NAME})
43+
44+
# Canonical headers (include/hpc/)
45+
target_link_libraries(${ARG_NAME} PRIVATE hpc_headers)
4346

4447
# Add include directories (target-based, not directory-based!)
4548
if(ARG_INCLUDE_DIRS)
@@ -74,6 +77,7 @@ function(hpc_add_example)
7477
target_link_libraries(${bench_name} PRIVATE
7578
benchmark::benchmark
7679
benchmark::benchmark_main
80+
hpc_headers
7781
)
7882

7983
if(ARG_INCLUDE_DIRS)
@@ -173,6 +177,7 @@ function(hpc_add_benchmark)
173177
target_link_libraries(${ARG_NAME} PRIVATE
174178
benchmark::benchmark
175179
benchmark::benchmark_main
180+
hpc_headers
176181
)
177182

178183
if(ARG_INCLUDE_DIRS)

docs/en/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Use the preset-driven path first. It is the shortest route that still preserves
211211

212212
| Surface | Detail |
213213
| --- | --- |
214-
| C++ standard | C++17 minimum, C++20 where beneficial |
214+
| C++ standard | C++20 (required) |
215215
| Build system | CMake 3.20+ with presets |
216216
| Platforms | Linux primary; macOS and Windows via cross-platform headers |
217217
| Compilers | GCC 11+, Clang 14+, MSVC 2022+ |

docs/zh/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ layout: home
211211

212212
| 层面 | 详情 |
213213
| --- | --- |
214-
| C++ 标准 | C++17 最低,C++20 在有益处时使用 |
214+
| C++ 标准 | C++20(必需) |
215215
| 构建系统 | CMake 3.20+,基于 preset |
216216
| 平台 | 以 Linux 为主;macOS 和 Windows 通过跨平台头文件支持 |
217217
| 编译器 | GCC 11+、Clang 14+、MSVC 2022+ |

0 commit comments

Comments
 (0)