Skip to content

Commit

Permalink
use fixed buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Jul 25, 2024
1 parent ae37088 commit bd7ee98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions store/file/ods.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func OpenODSFile(path string) (*ODSFile, error) {
}, nil
}

const bufSize = 64 << 10

// CreateODSFile creates a new file. File has to be closed after usage.
func CreateODSFile(
path string,
Expand All @@ -73,7 +75,7 @@ func CreateODSFile(
return nil, fmt.Errorf("file create: %w", err)
}

bufSize := int(eds.Width()) * share.Size
// buffering gives us ~4x speed up
buf := bufio.NewWriterSize(f, bufSize)

h, err := writeODSFile(buf, eds, roots)
Expand Down Expand Up @@ -145,7 +147,7 @@ func writeQ1(w io.Writer, eds *rsmt2d.ExtendedDataSquare) error {
func writeAxisRoots(w io.Writer, roots *share.AxisRoots) error {
for _, root := range roots.RowRoots {
if _, err := w.Write(root); err != nil {
return fmt.Errorf("writing columm roots: %w", err)
return fmt.Errorf("writing row roots: %w", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion store/file/q1q4_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func CreateQ1Q4File(path string, roots *share.AxisRoots, eds *rsmt2d.ExtendedDat
return nil, err
}

bufSize := int(eds.Width()) * int(ods.hdr.shareSize)
// buffering gives us ~4x speed up
buf := bufio.NewWriterSize(ods.fl, bufSize)

err = writeQ4(buf, eds)
Expand Down

0 comments on commit bd7ee98

Please sign in to comment.