Skip to content

Commit

Permalink
perf(shwap/store): create ODS and Q4 files in parallel
Browse files Browse the repository at this point in the history
This yields additional 27% improvement on the Put operation for the store.
The discrepancy seems to grow with the block size.
  • Loading branch information
Wondertan committed Aug 14, 2024
1 parent ae3205b commit 4ee148f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions store/file/ods_q4.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,32 @@ func CreateODSQ4(
roots *share.AxisRoots,
eds *rsmt2d.ExtendedDataSquare,
) error {
errCh := make(chan error)
go func() {
// doing this async shaves off ~27% of time for 128 ODS
// for bigger ODSes the discrepancy is even bigger
err := CreateQ4(pathQ4, roots, eds)
if err != nil {
err = fmt.Errorf("сreating Q4 file: %w", err)
}

errCh <- err
}()

if err := CreateODS(pathODS, roots, eds); err != nil {
return fmt.Errorf("failed to create ODS file: %w", err)
return fmt.Errorf("creating ODS file: %w", err)
}

if err := CreateQ4(pathQ4, roots, eds); err != nil {
return fmt.Errorf("failed to create Q4 file: %w", err)
err := <-errCh
if err != nil {
return err
}

return nil
}

// OpenODSQ4 lazily opens ODS and Q4 files under the given FS paths
// and combines them into ODSQ4.
// OpenODSQ4 opens ODS file under the given FS path. The Q4 is opened lazily
// on demand.
func OpenODSQ4(pathODS, pathQ4 string) (*ODSQ4, error) {
ods, err := OpenODS(pathODS)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func BenchmarkStore(b *testing.B) {
roots, err := share.NewAxisRoots(eds)
require.NoError(b, err)

// BenchmarkStore/put_128-16 100 10481547 ns/op
// BenchmarkStore/put_128-16 186 6623266 ns/op
b.Run("put 128", func(b *testing.B) {
edsStore, err := NewStore(paramsNoCache(), b.TempDir())
require.NoError(b, err)
Expand Down

0 comments on commit 4ee148f

Please sign in to comment.