Skip to content

reset offset and refactor bench - #4

Merged
kazeburo merged 1 commit into
mainfrom
feature/offset-reset-and-refactor-bench
Sep 21, 2026
Merged

kazeburo merged 1 commit into
mainfrom
feature/offset-reset-and-refactor-bench

Conversation

@kazeburo

@kazeburo kazeburo commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

PR Type

Enhancement, Tests


Description

  • Reset scanner offsets before every scan

  • Reuse iteration stop error sentinel

  • Add scanner reuse regression coverage

  • Refactor benchmarks with realistic log data


Diagram Walkthrough

flowchart LR
  Scan["Scanner.Scan"] --> Reset["Reset offset"]
  Reset --> Process["Process input lines"]
  Iter["Scanner.Iter"] --> Sentinel["Shared stop sentinel"]
  Bench["Benchmarks"] --> Data["Generated log data"]
  Data --> Bench
Loading

File Walkthrough

Relevant files
Bug fix
linebuf.go
Reset offsets and reuse iteration sentinel                             

linebuf.go

  • Adds a shared iteration-stop error sentinel.
  • Resets scanner offsets before each scan.
  • Preserves iteration error reporting behavior.
+6/-3     
Tests
linebuf_test.go
Expand scanner tests and benchmark realism                             

linebuf_test.go

  • Adds scanner reuse offset regression coverage.
  • Replaces synthetic numeric benchmark data.
  • Generates realistic structured log benchmark lines.
  • Reuses scanner configuration across benchmark iterations.
+61/-39 
Configuration changes
Makefile
Increase benchmark execution duration                                       

Makefile

  • Extends benchmark duration from two to five seconds.
+1/-1     

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Comparison

Base: main
PR: feature/offset-reset-and-refactor-bench

BenchmarkScan results
goos: linux
goarch: amd64
pkg: github.com/monitoring-forge/linebuf
cpu: AMD EPYC 9V74 80-Core Processor                
               │ base-bench.txt │             pr-bench.txt              │
               │     sec/op     │    sec/op     vs base                 │
Scan_bufio-4        117.9µ ± 5%    544.2µ ± 4%  +361.40% (p=0.000 n=10)
Scan_linebuf-4      94.49µ ± 1%   520.39µ ± 1%  +450.74% (p=0.000 n=10)
Scan_iter-4         104.1µ ± 6%    524.3µ ± 1%  +403.78% (p=0.000 n=10)
geomean             105.1µ         529.5µ       +403.99%

               │ base-bench.txt │               pr-bench.txt                │
               │      B/op      │     B/op      vs base                     │
Scan_bufio-4       4.000Ki ± 0%   0.000Ki ± 0%  -100.00% (p=0.000 n=10)
Scan_linebuf-4     4.062Ki ± 0%   0.000Ki ± 0%  -100.00% (p=0.000 n=10)
Scan_iter-4        4.078Ki ± 0%   0.000Ki ± 0%  -100.00% (p=0.000 n=10)
geomean            4.047Ki                      ?                       ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean

               │ base-bench.txt │              pr-bench.txt               │
               │   allocs/op    │ allocs/op   vs base                     │
Scan_bufio-4         1.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=10)
Scan_linebuf-4       2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=10)
Scan_iter-4          3.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=10)
geomean              1.817                    ?                       ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean

@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

No code suggestions found for the PR.

@kazeburo
kazeburo merged commit 0011c98 into main Sep 21, 2026
4 checks passed
@kazeburo
kazeburo deleted the feature/offset-reset-and-refactor-bench branch September 21, 2026 13:14
@github-actions github-actions Bot mentioned this pull request Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant