Skip to content
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

Increase Stat() buffer size #547

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ func parseStat(r io.Reader, fileName string) (Stat, error) {
err error
)

// Increase default scanner buffer to handle very long `intr` lines.
buf := make([]byte, 0, 8*1024)
SuperQ marked this conversation as resolved.
Show resolved Hide resolved
scanner.Buffer(buf, 1024*1024)

for scanner.Scan() {
line := scanner.Text()
parts := strings.Fields(scanner.Text())
Expand Down
2 changes: 1 addition & 1 deletion stat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestStat(t *testing.T) {
}

// intr
if want, have := uint64(8885917), s.IRQTotal; want != have {
if want, have := uint64(73777505), s.IRQTotal; want != have {
t.Errorf("want irq/total %d, have %d", want, have)
}
if want, have := uint64(1), s.IRQ[8]; want != have {
Expand Down
2 changes: 1 addition & 1 deletion testdata/fixtures.ttar

Large diffs are not rendered by default.