-
Notifications
You must be signed in to change notification settings - Fork 0
Enable field alignment optimization and fix all structs #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add field alignment configuration to .golangci.yml - Run fieldalignment tool to optimize struct memory layout - Fix struct literal initialization after field reordering - Add comprehensive documentation for field alignment workflow - Document fieldalignment tool usage in AGENT.md All struct field alignments are now optimized for memory efficiency. The fieldalignment linter is enabled and working correctly. Signed-off-by: Alejandro Mery <amery@apptly.co>
- Update Makefile to use golangci-lint v1.64.8 (latest v1 patch) - Add comprehensive golangci-lint configuration documentation to AGENT.md - Document v1/v2 schema compatibility issues and IDE warnings - Explain field alignment integration and troubleshooting steps - Update troubleshooting section with current configuration status This prevents v2 configuration format issues while maintaining all functionality. Field alignment linter works correctly with the pinned version. Signed-off-by: Alejandro Mery <amery@apptly.co>
WalkthroughThis update reorganises struct field orders across multiple Go source and test files to optimise memory alignment and adds clarifying comments. It also corrects the Changes
Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Here's the code health analysis summary for commits Analysis Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (11)
waitgroup_test.go (2)
83-89: Same concern as aboveField order changed; ensure no positional literals remain.
182-187: Same concern as aboveField order changed; ensure no positional literals remain.
panic_test.go (3)
111-113: No further action – same rationale as previous comment.
198-201: No further action – same rationale as previous comment.
392-395: No further action – same rationale as previous comment.addrs_test.go (1)
183-194: Duplicate of the previous observation.panicerror_test.go (3)
134-138: No functional impact; mirrors earlier pattern.
223-227: No functional impact; mirrors earlier pattern.
296-298: No functional impact; mirrors earlier pattern.AGENT.md (2)
346-350: Same punctuation issue in the “Schema Validation Issues” listEnsure each bullet ends with a period to satisfy markdownlint rules.
453-459: Same punctuation issue in the “golangci-lint schema validation” listAdd trailing full stops for consistency.
🧹 Nitpick comments (4)
compounderror_test.go (1)
9-13: Field order change is fine – consider a brief commentReordering
compoundErrorErrorTestCasefields has no semantic impact because literals use keyed fields.
A one-line comment noting the ordering rationale (alignment vs. readability) could help future reviewers.sync.go (1)
42-47: Field reordering implemented correctly.The WaitGroup field reordering aligns with the field alignment optimization effort. Consider adding size comments similar to other structs in this PR for consistency.
AGENT.md (1)
289-300: Bulleted list punctuation – add full stops for markdown-lint complianceProject guidelines require every bullet to end with a period.
The five bullets under Field Alignment Notes currently lack trailing punctuation.- - Analyze all struct definitions in the project - - Reorder fields to minimize memory padding - - Automatically update source files with optimized field ordering + - Analyse all struct definitions in the project. + - Reorder fields to minimise memory padding. + - Automatically update source files with optimised field ordering.as_test.go (1)
11-18: Byte-count comments could become staleHard-coding “16 bytes” in comments will be wrong on any non-64-bit build and might drift if Go changes pointer sizes. Consider removing the byte counts or re-phrasing generically (e.g. “pointer-sized”).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
.golangci.yml(1 hunks)AGENT.md(2 hunks)Makefile(1 hunks)addrs_test.go(2 hunks)as_test.go(3 hunks)compounderror_test.go(1 hunks)errgroup_test.go(3 hunks)internal/build/cspell.json(2 hunks)panic_test.go(5 hunks)panicerror_test.go(4 hunks)slices.go(1 hunks)slices_test.go(1 hunks)spinlock_test.go(3 hunks)stack.go(1 hunks)sync.go(2 hunks)waitgroup_test.go(3 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENT.md
internal/build/cspell.json
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENT.md
**/*.go
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENT.md
**/*_test.go
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENT.md
**/*.{md,go}
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENT.md
**/*.md
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENT.md
AGENT.md
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENT.md
🧠 Learnings (16)
📓 Common learnings
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: ALWAYS run `make tidy` before committing: Go code formatting, whitespace clean-up, Markdown files checked with CSpell, LanguageTool, and markdownlint.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to AGENT.md : Update AGENT.md to reflect any changes in development workflow or standards.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*.go : Enforce strict linting rules via revive: max function length 40 lines, max function results 3, max arguments 5, cognitive complexity 7, cyclomatic complexity 10 (configured in internal/build/revive.toml).
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*.{md,go} : Markdown and Go source files must be checked with CSpell for spelling (British English, custom word list).
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*.md : Review documentation changes for missing articles, punctuation, and hyphenation issues.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to internal/build/cspell.json : Add technical terms to internal/build/cspell.json for spelling and grammar tools.
.golangci.yml (2)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*.go : Enforce strict linting rules via revive: max function length 40 lines, max function results 3, max arguments 5, cognitive complexity 7, cyclomatic complexity 10 (configured in internal/build/revive.toml).
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: ALWAYS run `make tidy` before committing: Go code formatting, whitespace clean-up, Markdown files checked with CSpell, LanguageTool, and markdownlint.
internal/build/cspell.json (6)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to internal/build/cspell.json : Add technical terms to internal/build/cspell.json for spelling and grammar tools.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*.{md,go} : Markdown and Go source files must be checked with CSpell for spelling (British English, custom word list).
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Only use the Go standard library and minimal golang.org/x packages; zero external dependencies.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Helper functions like `S[T]()` should be used to create test slices in Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Table-driven tests are preferred for Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Comprehensive coverage for generic functions is expected in tests.
compounderror_test.go (2)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Comprehensive coverage for generic functions is expected in tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Table-driven tests are preferred for Go tests.
slices_test.go (3)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Helper functions like `S[T]()` should be used to create test slices in Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Table-driven tests are preferred for Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Comprehensive coverage for generic functions is expected in tests.
Makefile (3)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: ALWAYS run `make tidy` before committing: Go code formatting, whitespace clean-up, Markdown files checked with CSpell, LanguageTool, and markdownlint.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*.go : Enforce strict linting rules via revive: max function length 40 lines, max function results 3, max arguments 5, cognitive complexity 7, cyclomatic complexity 10 (configured in internal/build/revive.toml).
Learnt from: karasz
PR: darvaza-proxy/core#74
File: internal/build/get_version.sh:21-30
Timestamp: 2024-10-01T08:39:29.235Z
Learning: In `get_version.sh`, focus on addressing necessary changes, such as Shellcheck warnings, and avoid suggesting optional readability improvements or stylistic changes unless they address critical issues.
slices.go (2)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Helper functions like `S[T]()` should be used to create test slices in Go tests.
Learnt from: amery
PR: darvaza-proxy/core#86
File: list.go:83-89
Timestamp: 2024-11-16T07:43:16.106Z
Learning: In `list.go`, the `List[T]` methods `Len` and `ForEach` handle a nil receiver gracefully.
sync.go (1)
Learnt from: amery
PR: darvaza-proxy/core#105
File: sync.go:11-12
Timestamp: 2025-04-17T20:14:08.093Z
Learning: In the darvaza.org/core module, the SpinLock type is being deprecated in favor of darvaza.org/x/sync/spinlock. The implementation must remain in place (not an alias) to avoid circular dependencies, as the new package likely imports from core.
errgroup_test.go (2)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Table-driven tests are preferred for Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Comprehensive coverage for generic functions is expected in tests.
spinlock_test.go (3)
Learnt from: amery
PR: darvaza-proxy/core#105
File: sync.go:11-12
Timestamp: 2025-04-17T20:14:08.093Z
Learning: In the darvaza.org/core module, the SpinLock type is being deprecated in favor of darvaza.org/x/sync/spinlock. The implementation must remain in place (not an alias) to avoid circular dependencies, as the new package likely imports from core.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Table-driven tests are preferred for Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Helper functions like `S[T]()` should be used to create test slices in Go tests.
panic_test.go (3)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Table-driven tests are preferred for Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Comprehensive coverage for generic functions is expected in tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Helper functions like `S[T]()` should be used to create test slices in Go tests.
waitgroup_test.go (5)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Table-driven tests are preferred for Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Comprehensive coverage for generic functions is expected in tests.
Learnt from: amery
PR: darvaza-proxy/core#79
File: internal/build/gen_mk.sh:161-169
Timestamp: 2024-10-01T19:43:25.764Z
Learning: When suggesting refactoring of build scripts, consider the possibility of nested `go.mod` files within subdirectories like `./cmd/`, and ensure that the proposed changes handle nested modules correctly.
Learnt from: amery
PR: darvaza-proxy/core#79
File: internal/build/gen_mk.sh:161-169
Timestamp: 2024-10-08T15:33:35.792Z
Learning: When suggesting refactoring of build scripts, consider the possibility of nested `go.mod` files within subdirectories like `./cmd/`, and ensure that the proposed changes handle nested modules correctly.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Helper functions like `S[T]()` should be used to create test slices in Go tests.
addrs_test.go (3)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Table-driven tests are preferred for Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Comprehensive coverage for generic functions is expected in tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Helper functions like `S[T]()` should be used to create test slices in Go tests.
panicerror_test.go (3)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Comprehensive coverage for generic functions is expected in tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Table-driven tests are preferred for Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Helper functions like `S[T]()` should be used to create test slices in Go tests.
AGENT.md (19)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to AGENT.md : Update AGENT.md to reflect any changes in development workflow or standards.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to README.md : Update README.md to reflect significant changes in functionality or API.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*.md : Review documentation changes for missing articles, punctuation, and hyphenation issues.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: ALWAYS run `make tidy` before committing: Go code formatting, whitespace clean-up, Markdown files checked with CSpell, LanguageTool, and markdownlint.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Update documentation when adding new tools or changing workflows.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*.go : Enforce strict linting rules via revive: max function length 40 lines, max function results 3, max arguments 5, cognitive complexity 7, cyclomatic complexity 10 (configured in internal/build/revive.toml).
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*.md : When editing Markdown files, ensure compliance with LanguageTool (articles, punctuation, hyphenation), CSpell (spelling), and markdownlint (formatting).
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*.md : Markdown files must comply with markdownlint rules, including 80-character line limits and strict formatting.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*.{md,go} : Markdown and Go source files must be checked with CSpell for spelling (British English, custom word list).
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Always run `make tidy` before committing to ensure proper formatting.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Only use the Go standard library and minimal golang.org/x packages; zero external dependencies.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Table-driven tests are preferred for Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Comprehensive coverage for generic functions is expected in tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Ensure no linting violations remain before committing.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Always use `pnpm` instead of `npm` for any JavaScript/TypeScript tooling.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to internal/build/cspell.json : Add technical terms to internal/build/cspell.json for spelling and grammar tools.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Keep the pre-commit checklist current with project practices.
Learnt from: amery
PR: darvaza-proxy/core#79
File: internal/build/gen_mk.sh:161-169
Timestamp: 2024-10-08T15:33:35.792Z
Learning: When suggesting refactoring of build scripts, consider the possibility of nested `go.mod` files within subdirectories like `./cmd/`, and ensure that the proposed changes handle nested modules correctly.
Learnt from: amery
PR: darvaza-proxy/core#79
File: internal/build/gen_mk.sh:161-169
Timestamp: 2024-10-01T19:43:25.764Z
Learning: When suggesting refactoring of build scripts, consider the possibility of nested `go.mod` files within subdirectories like `./cmd/`, and ensure that the proposed changes handle nested modules correctly.
as_test.go (3)
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Table-driven tests are preferred for Go tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Comprehensive coverage for generic functions is expected in tests.
Learnt from: CR
PR: darvaza-proxy/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-10T13:13:22.040Z
Learning: Applies to **/*_test.go : Helper functions like `S[T]()` should be used to create test slices in Go tests.
🧬 Code Graph Analysis (1)
errgroup_test.go (1)
sync.go (1)
ErrGroup(128-135)
🔇 Additional comments (21)
.golangci.yml (1)
7-9: Govetfieldalignmentenabled with correct YAML list syntax – LGTMThe new list syntax (
enable: [fieldalignment]) is parsed correctly by golangci-lint v1.x and switches on the vet analyser as intended.
No further action required.internal/build/cspell.json (2)
32-32: Dictionary extended with “fieldalignment” – looks goodKeeps spell-checker quiet for the newly introduced linter name.
45-45: Added “GOXTOOLS” to custom word list – acceptedMatches tooling nomenclature; no issues spotted.
slices_test.go (1)
158-164: Struct field shuffle is harmlessNamed initialisers protect against breakage; tests remain clear.
Makefile (1)
19-22: Pinned golangci-lint to v1.64.8 – reproducibility improvedLocking the exact patch version avoids unexpected linter upgrades and aligns with the
.golangci.ymlv1 schema.stack.go (1)
28-37: Excellent field alignment optimization implementation.The struct field reordering correctly groups fields by type and size, with accurate comments describing the memory layout. The string fields (16 bytes each) are placed first, followed by uintptr fields (8 bytes each), and finally the int field (8 bytes), all ordered alphabetically within their respective type groups. This optimises memory alignment whilst maintaining readability.
slices.go (1)
281-287: Proper field alignment implementation.The field reordering correctly places the smaller function pointer field (8 bytes) before the larger slice field (24 bytes), with accurate size documentation. The alphabetical ordering within the struct maintains consistency whilst optimising memory layout.
sync.go (1)
128-135: ErrGroup field reordering improves logical grouping.The field reordering groups related context fields together (ctx, Parent) and places function pointers before larger structs. This enhances both memory alignment and logical organisation of the struct.
spinlock_test.go (3)
10-14: Test case struct field reordering maintains consistency.Moving the
namefield after thesetupfunction field aligns with the field alignment optimization pattern applied across test case structs in this PR.
52-55: Consistent field ordering applied.The field reordering matches the pattern established in other test case structs, placing function fields before string fields.
128-132: Field alignment pattern consistently applied.The struct field reordering follows the same pattern as other test case structs, optimising memory layout by placing function fields before string fields.
errgroup_test.go (3)
10-14: Test case struct field reordering follows established pattern.The field reordering places function fields before the string
namefield, consistent with the field alignment optimization pattern applied across test case structs in this PR.
65-71: Consistent field alignment applied to test case struct.Moving the
namefield after the function fields maintains the established pattern for test case struct field ordering, optimising memory layout.
175-180: Field alignment pattern maintained across test structs.The field reordering follows the same pattern as other test case structs, placing function fields before string fields for optimal memory alignment.
waitgroup_test.go (1)
11-16: Struct reordering confirmed safeI searched the entire codebase for un-keyed composite literals of
waitGroupGoTestCaseand found no occurrences. The new field order won’t break existing tests—changes approved.panic_test.go (2)
8-16: Field-size grouping is fine, but not performance-critical in testsRe-ordering for alignment is harmless here; tests favour clarity over cache-lines, yet the grouping is consistent with the rest of the codebase.
398-403: 👍 Explicit keyed literals avoid order-dependenceSwitching to keyed literals (
name:,value:) removes any risk introduced by field re-ordering.addrs_test.go (1)
12-20: Clearer grouping, but remember tests are exempt from mem-layout concernsThe comments documenting field sizes are helpful; otherwise nothing functional changes.
panicerror_test.go (1)
82-89: Re-ordering introduces keyed/boolean split – fineThe boolean now sits last; initialisers already use keyed fields, so behaviour is unchanged.
as_test.go (2)
11-20: Struct layout now satisfiesfieldalignment– looks goodThe re-ordering groups the 16-byte interface & string fields first and pushes the single-byte bool to the end, eliminating padding; the linter should now be silent. No other impacts on the table-driven tests.
154-163: Consistent re-ordering applied here as well – goodThe
asErrorTestCasestruct follows the same pattern, so alignment is consistent across tests.
karasz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
This PR implements field alignment optimization for the core library, improving memory efficiency by optimizing struct field layouts across the codebase.
Changes
Field Alignment Optimization
.golangci.ymlTooling Improvements
Technical Details
Memory Efficiency: All struct field alignments are now optimized to minimize memory padding and improve cache locality.
Linter Integration: The fieldalignment analyzer is properly configured and working correctly with the pinned golangci-lint version.
Version Stability: Using v1.64.8 prevents v2 configuration format issues while maintaining all functionality.
Files Changed
Test Plan
make tidy-rootpasses cleanly with no fieldalignment errorsImpact
Memory savings: Significant reduction in struct padding across the codebase
Maintainability: Automated field alignment detection prevents future regressions
Documentation: Clear workflow for manual field alignment optimization
Summary by CodeRabbit
Documentation
Chores
Style
Refactor