Skip to content

refactor: circular buffer - #741

Open
janishorsts wants to merge 3 commits into
mainfrom
refactor-circbuf
Open

refactor: circular buffer#741
janishorsts wants to merge 3 commits into
mainfrom
refactor-circbuf

Conversation

@janishorsts

@janishorsts janishorsts commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

🛠️ Benefits, Issues Resolved & DX Impact

  • Benefits: Relocated circbuf from util/ to internal/circbuf to encapsulate internal circular buffer implementation details used by logbus.Command (which maintains a bounded 80 KB tail log buffer for command output). Added ErrInvalidSize sentinel error, fast-path write handling for incoming data larger than capacity, defensive cloning on Bytes(), and zero-value safety.
  • Issues Eliminated: Prevented potential slice mutations by external callers through defensive cloning in Bytes(), eliminated silent failures on non-positive buffer capacities with explicit error signaling.
  • Developer Experience (DX) Impact: Improved test organization with parallelized table-driven tests (t.Parallel()), added explicit immutability and zero-value safety test cases, and included write throughput benchmarks.

⚡ Performance Impact

Metric Before After Delta
Execution Time ~12.4 ns/op 4.68 ns/op -62.2%
Memory Allocations 0 B/op 0 B/op 0.0%
Heap Mallocs 0 allocs/op 0 allocs/op 0.0%

📦 Binary Size Impact

  • Stripped Size (Before/After/Delta): 42.10 MB / 42.10 MB / 0.00 KB (0.0%)

@janishorsts janishorsts self-assigned this Jul 30, 2026
@janishorsts
janishorsts requested a review from a team as a code owner July 30, 2026 16:15
@janishorsts
janishorsts requested review from kmannislands and removed request for a team July 30, 2026 16:15
@janishorsts janishorsts added the ai-assisted Authored with AI assistance label Jul 30, 2026
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

➖ Are we earthbuild yet?

No change in "earthly" occurrences

📈 Overall Progress

Branch Total Count
main 4752
This PR 4752
Difference +0

Keep up the great work migrating from Earthly to Earthbuild! 🚀

💡 Tips for finding more occurrences

Run locally to see detailed breakdown:

./.github/scripts/count-earthly.sh

Note that the goal is not to reach 0.
There is anticipated to be at least some occurences of earthly in the source code due to backwards compatibility with config files and language constructs.

@gilescope gilescope left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved. Surprised there's not a fairly standard dep that does this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Authored with AI assistance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants