docs(comments): rewrite comments across all crates to the guidelines
Sweep every first-party crate source (1956 .rs files) to the project comment guidelines: delete redundant restatements, decorative banners, change narration, and end-of-line comments; keep and tighten the crucial ones (invariants, bug rationale, SAFETY blocks, ported-source attribution). No functional code changed. Every edit is proven comment-only against the prior tree by a comment-stripping lexer (string/char/raw-string aware) plus a separate doctest-fence check. Where removing a comment made rustfmt or clippy want to re-lay-out adjacent code, the minimal triggering comment is restored so code tokens stay byte-identical. Gates green: cargo fmt --all --check (0 diffs), cargo check and cargo clippy --workspace --all-targets (0 warnings). Adds scripts/check_codegen_comment_guidelines.py — the enforcement gate for these guidelines (flags banners, end-of-line comments, change narration, and commented-out code).
This commit is contained in:
@@ -1,29 +1,20 @@
|
||||
//! Isolated RSS test for incremental reindexing.
|
||||
//!
|
||||
//! This test lives in its own integration-test file (and therefore its own
|
||||
//! Bazel `rust_test` target / process) so that its whole-process RSS samples
|
||||
//! are not polluted by the other allocation-heavy tests in
|
||||
//! `memory_integration.rs` (e.g. `test_fresh_build_rss`,
|
||||
//! `test_build_batch_peak_rss_is_bounded`, `test_compact_reduces_rss_vs_uncompacted`).
|
||||
//! `libtest` runs a test binary's tests concurrently across `num_cpus` threads,
|
||||
//! but VmRSS is measured per-*process*. Sharing a binary with the other
|
||||
//! allocation-heavy tests in `memory_integration.rs` made this test observe
|
||||
//! their allocator churn, intermittently pushing the measured incremental
|
||||
//! growth delta over the 20 MB budget on aarch64 fastbuild CI (~31 MB).
|
||||
//!
|
||||
//! Background: `libtest` runs tests in a single binary concurrently across
|
||||
//! `num_cpus` threads, and VmRSS is measured per-*process*. When this test
|
||||
//! ran inside `memory_integration.rs` it observed allocator churn from the
|
||||
//! other tests on the same process, intermittently pushing the measured
|
||||
//! "incremental growth" delta over the 20 MB budget on aarch64 fastbuild CI
|
||||
//! (`run_1_of_2` and `run_2_of_2` both failed at ~31 MB).
|
||||
//!
|
||||
//! Keep this file to a single test. If you need to add another RSS-sensitive
|
||||
//! test, give it its own file too rather than reintroducing the
|
||||
//! noisy-neighbor problem.
|
||||
//! Hence its own integration-test file, and therefore its own Bazel
|
||||
//! `rust_test` target and process. Keep this file to a single test; any other
|
||||
//! RSS-sensitive test needs a file of its own rather than a noisy neighbor.
|
||||
|
||||
use kigi_codebase_graph::{FileEvent, IndexManager, IndexManagerConfig};
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use tempfile::tempdir;
|
||||
|
||||
/// Read current process RSS in bytes. Supports Linux and macOS.
|
||||
/// Returns `None` on unsupported platforms.
|
||||
fn rss_bytes() -> Option<usize> {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
@@ -65,7 +56,6 @@ fn fmt_rss(rss: Option<f64>) -> String {
|
||||
rss.map_or("N/A".to_string(), |v| format!("{:.1}MB", v))
|
||||
}
|
||||
|
||||
/// Create N Rust source files in `dir`, each with `defs_per_file` function defs.
|
||||
fn create_rust_files(dir: &Path, count: usize, defs_per_file: usize) {
|
||||
for i in 0..count {
|
||||
let mut content = String::new();
|
||||
@@ -122,7 +112,6 @@ fn test_bulk_incremental_indexing_memory() {
|
||||
);
|
||||
println!("RSS after incremental: {}", fmt_rss(rss_after_incremental));
|
||||
|
||||
// Incremental reindexing should not grow memory significantly.
|
||||
if let (Some(after_inc), Some(after_build)) = (rss_after_incremental, rss_after_build) {
|
||||
let growth = after_inc - after_build;
|
||||
assert!(
|
||||
|
||||
@@ -80,9 +80,7 @@ fn create_binary_files(dir: &Path, count: usize, size: usize) {
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Tests
|
||||
// =========================================================================
|
||||
|
||||
#[test]
|
||||
#[serial_test::serial]
|
||||
@@ -221,11 +219,14 @@ fn test_builder_skips_binary_and_oversized_in_bulk() {
|
||||
let root = dir.path();
|
||||
|
||||
// Mix of valid, binary, and oversized files
|
||||
create_rust_files(root, 100, 5); // 100 valid files
|
||||
create_binary_files(root, 50, 10_000); // 50 binary files
|
||||
// 100 valid files
|
||||
create_rust_files(root, 100, 5);
|
||||
// 50 binary files
|
||||
create_binary_files(root, 50, 10_000);
|
||||
|
||||
// One oversized file
|
||||
let big = "fn x() {}\n".repeat(600_000); // ~6MB
|
||||
// ~6MB
|
||||
let big = "fn x() {}\n".repeat(600_000);
|
||||
fs::write(root.join("oversized.rs"), &big).unwrap();
|
||||
drop(big);
|
||||
|
||||
@@ -234,7 +235,8 @@ fn test_builder_skips_binary_and_oversized_in_bulk() {
|
||||
|
||||
// Only the 100 valid files should be indexed
|
||||
assert_eq!(files, 100);
|
||||
assert!(defs >= 500); // 100 files × 5 defs
|
||||
// 100 files × 5 defs
|
||||
assert!(defs >= 500);
|
||||
}
|
||||
|
||||
/// Measure RSS growth from a single `get_snapshot()` call on a representative index.
|
||||
@@ -248,7 +250,8 @@ fn test_builder_skips_binary_and_oversized_in_bulk() {
|
||||
fn test_single_snapshot_rss() {
|
||||
let dir = tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
create_rust_files(root, 500, 10); // 500 files, 5 000 defs
|
||||
// 500 files, 5 000 defs
|
||||
create_rust_files(root, 500, 10);
|
||||
|
||||
let config = IndexManagerConfig::new(root.to_path_buf())
|
||||
.without_cache_load()
|
||||
@@ -353,7 +356,8 @@ fn test_repeated_snapshots_rss_bounded() {
|
||||
fn test_fresh_build_rss() {
|
||||
let dir = tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
create_rust_files(root, 500, 10); // 500 files, 5 000 defs
|
||||
// 500 files, 5 000 defs
|
||||
create_rust_files(root, 500, 10);
|
||||
|
||||
let rss_before = rss_mb();
|
||||
|
||||
@@ -451,7 +455,8 @@ fn test_cache_load_rss() {
|
||||
fn test_build_batch_size_produces_correct_index() {
|
||||
let dir = tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
create_rust_files(root, 200, 5); // 200 files, 1 000 defs
|
||||
// 200 files, 1 000 defs
|
||||
create_rust_files(root, 200, 5);
|
||||
|
||||
// Build with a very small batch size (10 files per merge batch)
|
||||
let batched = IndexBuilder::new()
|
||||
@@ -587,9 +592,7 @@ fn test_build_batch_peak_rss_is_bounded() {
|
||||
assert_eq!(b_refs, u_refs, "reference count must match");
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Structural compaction tests
|
||||
// =============================================================================
|
||||
|
||||
/// Verify that an index survives a save/load round-trip after compact().
|
||||
///
|
||||
@@ -601,7 +604,8 @@ fn test_build_batch_peak_rss_is_bounded() {
|
||||
fn test_compact_then_save_load_roundtrip() {
|
||||
let dir = tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
create_rust_files(root, 50, 4); // 50 files, 200 defs
|
||||
// 50 files, 200 defs
|
||||
create_rust_files(root, 50, 4);
|
||||
|
||||
// build() calls compact() internally via build_fast()
|
||||
let original = IndexBuilder::new().build(root).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user