diff options
| author | Patrick Schmidt <patrick.schmidt@innogames.com> | 2023-01-20 13:12:30 +0100 |
|---|---|---|
| committer | Chris Lu <chrislusf@users.noreply.github.com> | 2023-09-05 10:33:27 -0700 |
| commit | cdd817edf97fca305bb490b139d6a9b185d58f66 (patch) | |
| tree | 53731462674169d7bcfc66c839ae8d3634ecf176 /weed/s3api/auth_credentials.go | |
| parent | f07876cb23bfbf435d91506d60bb5e7a50e5888e (diff) | |
| download | seaweedfs-cdd817edf97fca305bb490b139d6a9b185d58f66.tar.xz seaweedfs-cdd817edf97fca305bb490b139d6a9b185d58f66.zip | |
Improve S3 request signing performance
This change is caching HMAC hashers for repeated use in subsequent
requests and chunks, so they don't have to be initialized from
scratch every time.
On my local computer this gives me ~5-6 times faster signature
calculation and ~5-6.5% more throughput in S3 requests. The smaller
the payload the better the throughput gets.
Diffstat (limited to 'weed/s3api/auth_credentials.go')
| -rw-r--r-- | weed/s3api/auth_credentials.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/weed/s3api/auth_credentials.go b/weed/s3api/auth_credentials.go index 876acd7cf..f2d057b90 100644 --- a/weed/s3api/auth_credentials.go +++ b/weed/s3api/auth_credentials.go @@ -2,12 +2,13 @@ package s3api import ( "fmt" - "github.com/seaweedfs/seaweedfs/weed/s3api/s3account" "net/http" "os" "strings" "sync" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3account" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb" @@ -31,6 +32,8 @@ type IdentityAccessManagement struct { identities []*Identity isAuthEnabled bool domain string + hashes map[string]*sync.Pool + hashMu sync.RWMutex } type Identity struct { @@ -77,6 +80,7 @@ func (action Action) getPermission() Permission { func NewIdentityAccessManagement(option *S3ApiServerOption) *IdentityAccessManagement { iam := &IdentityAccessManagement{ domain: option.DomainName, + hashes: make(map[string]*sync.Pool), } if option.Config != "" { if err := iam.loadS3ApiConfigurationFromFile(option.Config); err != nil { |
