Skip to content

Conversation

@amery
Copy link
Contributor

@amery amery commented Jul 16, 2025

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

  • Configured fieldalignment linter in .golangci.yml
  • Optimized all struct layouts using official Go fieldalignment tool
  • Fixed struct literal initialization after field reordering
  • Added comprehensive documentation for field alignment workflow

Tooling Improvements

  • Pinned golangci-lint to v1.64.8 to avoid v2 configuration issues
  • Documented schema validation for IDE compatibility
  • Updated troubleshooting guide with current configuration status
  • Added technical terms to cspell dictionary

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

  • Core library: 4 main source files optimized
  • Tests: 9 test files with struct alignment fixes
  • Configuration: .golangci.yml, Makefile, cspell.json
  • Documentation: AGENT.md with detailed field alignment guidance

Test Plan

  • make tidy-root passes cleanly with no fieldalignment errors
  • All struct field alignments are optimized for memory efficiency
  • Field alignment linter is properly configured and working
  • Configuration functions despite IDE schema warnings

Impact

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

    • Expanded documentation on linting, code quality, and troubleshooting, including details about struct field alignment and configuration nuances.
    • Updated spell-check dictionary to recognise new technical terms.
  • Chores

    • Updated the default version of the linting tool for improved reliability.
    • Corrected linter configuration to ensure proper activation of field alignment checks.
  • Style

    • Reordered struct fields across multiple test and implementation files for improved consistency, grouping by type, size, or alphabetically, and added explanatory comments.
    • Updated test case initialisations for clarity and readability.
  • Refactor

    • Adjusted field order in several internal structs to optimise memory layout and maintain consistency. No changes to functionality.

amery added 2 commits July 16, 2025 21:28
- 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>
@amery amery added the enhancement New feature or request label Jul 16, 2025
@amery amery requested a review from karasz July 16, 2025 21:33
@coderabbitai
Copy link

coderabbitai bot commented Jul 16, 2025

Walkthrough

This update reorganises struct field orders across multiple Go source and test files to optimise memory alignment and adds clarifying comments. It also corrects the .golangci.yml linter configuration syntax, updates documentation in AGENT.md regarding linting and code quality, pins the golangci-lint version in the Makefile, and extends the spell checker dictionary.

Changes

Files/Groups Change Summary
addrs_test.go, as_test.go, compounderror_test.go, errgroup_test.go, panic_test.go, panicerror_test.go, spinlock_test.go, waitgroup_test.go, slices_test.go Reordered struct fields in test case definitions for better alignment and added descriptive comments.
slices.go, stack.go, sync.go Reordered struct fields and added comments on field sizes and ordering.
.golangci.yml Corrected govet linter settings syntax for enabling fieldalignment.
AGENT.md Expanded documentation on field alignment, linter configuration, troubleshooting, and spell checking.
Makefile Updated golangci-lint version pin from v1.64 to v1.64.8.
internal/build/cspell.json Added "fieldalignment" and "GOXTOOLS" to the custom spell checker dictionary.

Possibly related PRs

Poem

🐇
Hop, hop! The structs are neat,
Fields aligned, a tidy feat.
Linting rules now crystal clear,
Docs and spelling—no more fear!
With every hop, our code grows tight,
Memory snug and linter right.
Hooray for order—what a sight!

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pr-amery-fieldalignment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@deepsource-io
Copy link

deepsource-io bot commented Jul 16, 2025

Here's the code health analysis summary for commits 2fb4e5a..4314cfa. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Shell LogoShell✅ SuccessView Check ↗
DeepSource Go LogoGo✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@codecov
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link

@coderabbitai coderabbitai bot left a 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 above

Field order changed; ensure no positional literals remain.


182-187: Same concern as above

Field 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” list

Ensure each bullet ends with a period to satisfy markdownlint rules.


453-459: Same punctuation issue in the “golangci-lint schema validation” list

Add trailing full stops for consistency.

🧹 Nitpick comments (4)
compounderror_test.go (1)

9-13: Field order change is fine – consider a brief comment

Reordering compoundErrorErrorTestCase fields 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 compliance

Project 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 stale

Hard-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

📥 Commits

Reviewing files that changed from the base of the PR and between 2fb4e5a and 4314cfa.

📒 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: Govet fieldalignment enabled with correct YAML list syntax – LGTM

The 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 good

Keeps spell-checker quiet for the newly introduced linter name.


45-45: Added “GOXTOOLS” to custom word list – accepted

Matches tooling nomenclature; no issues spotted.

slices_test.go (1)

158-164: Struct field shuffle is harmless

Named initialisers protect against breakage; tests remain clear.

Makefile (1)

19-22: Pinned golangci-lint to v1.64.8 – reproducibility improved

Locking the exact patch version avoids unexpected linter upgrades and aligns with the .golangci.yml v1 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 name field after the setup function 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 name field, 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 name field 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 safe

I searched the entire codebase for un-keyed composite literals of waitGroupGoTestCase and 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 tests

Re-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-dependence

Switching 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 concerns

The comments documenting field sizes are helpful; otherwise nothing functional changes.

panicerror_test.go (1)

82-89: Re-ordering introduces keyed/boolean split – fine

The boolean now sits last; initialisers already use keyed fields, so behaviour is unchanged.

as_test.go (2)

11-20: Struct layout now satisfies fieldalignment – looks good

The 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 – good

The asErrorTestCase struct follows the same pattern, so alignment is consistent across tests.

Copy link
Contributor

@karasz karasz left a comment

Choose a reason for hiding this comment

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

LGTM

@karasz karasz merged commit f6adf21 into main Jul 17, 2025
17 checks passed
@karasz karasz deleted the pr-amery-fieldalignment branch July 17, 2025 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants