Use Minio's optimized SHA-256

internal/repository benchmarks on an Intel i7-3770k:

name               old speed      new speed       delta
PackerManager-8     209MB/s ± 1%    291MB/s ± 1%  +38.94%  (p=0.008 n=5+5)
SaveAndEncrypt-8    112MB/s ± 1%    135MB/s ± 1%  +20.25%  (p=0.008 n=5+5)
This commit is contained in:
greatroar 2020-03-19 11:27:19 +01:00
parent 070d43e290
commit 42a3db05b0
5 changed files with 9 additions and 4 deletions

View File

@ -2,7 +2,6 @@ package main
import (
"context"
"crypto/sha256"
"encoding/json"
"fmt"
"os"
@ -11,6 +10,8 @@ import (
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/walker"
"github.com/minio/sha256-simd"
"github.com/spf13/cobra"
)

1
go.mod
View File

@ -21,6 +21,7 @@ require (
github.com/kurin/blazer v0.5.3
github.com/marstr/guid v1.1.0 // indirect
github.com/minio/minio-go/v6 v6.0.43
github.com/minio/sha256-simd v0.1.1
github.com/ncw/swift v1.0.47
github.com/pkg/errors v0.8.1
github.com/pkg/profile v1.3.0

View File

@ -2,7 +2,6 @@ package repository
import (
"context"
"crypto/sha256"
"os"
"sync"
@ -14,6 +13,8 @@ import (
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/fs"
"github.com/restic/restic/internal/pack"
"github.com/minio/sha256-simd"
)
// Saver implements saving data in a backend.

View File

@ -3,7 +3,6 @@ package repository
import (
"bytes"
"context"
"crypto/sha256"
"encoding/json"
"fmt"
"io"
@ -17,6 +16,8 @@ import (
"github.com/restic/restic/internal/hashing"
"github.com/restic/restic/internal/pack"
"github.com/restic/restic/internal/restic"
"github.com/minio/sha256-simd"
"golang.org/x/sync/errgroup"
)

View File

@ -2,13 +2,14 @@ package restic
import (
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"github.com/restic/restic/internal/errors"
"github.com/minio/sha256-simd"
)
// Hash returns the ID for data.