mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-31 17:30:42 +01:00
Manifest chunk resolution still signed proxied downloads with the process-wide read key, so a source filer requiring its own key 401'd on manifest-bearing files. A side security file that set only one access level also produced empty tokens for the other instead of inheriting the process-wide key, and the side file loader ignored the WEED_ environment overrides the filer itself honors. ResolveChunkManifest/ResolveOneChunkManifest keep their signatures; FilerJwt-aware variants thread the provider down to fetchWholeChunk, which prefers it on proxy URLs. The side loader now applies the same environment precedence and falls back to the process-wide signer per missing access level.
73 lines
2.4 KiB
Go
73 lines
2.4 KiB
Go
package filer
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"sync/atomic"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
|
)
|
|
|
|
func BenchmarkManifestResolutionRepeatedOpen(b *testing.B) {
|
|
for _, delay := range []time.Duration{0, 5 * time.Millisecond, 20 * time.Millisecond} {
|
|
b.Run(fmt.Sprintf("latency=%s", delay), func(b *testing.B) {
|
|
fixture := newManifestReadFixture(b, map[string][]*filer_pb.FileChunk{
|
|
"benchmark-cached": {resolveTestData("benchmark-data", 0)},
|
|
}, map[string]time.Duration{"benchmark-cached": delay})
|
|
var lookups atomic.Int32
|
|
lookup := func(ctx context.Context, fileID string) ([]string, error) {
|
|
lookups.Add(1)
|
|
return fixture.lookup(ctx, fileID)
|
|
}
|
|
chunk := newManifestCacheTestChunk("benchmark-cached")
|
|
cache := NewChunkManifestCache(MaxMountChunkManifestCacheEntries, MaxMountChunkManifestCacheBytes)
|
|
_, err := resolveOneChunkManifest(context.Background(), lookup, chunk, nil, cache, nil)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
fixture.loads.Store(0)
|
|
lookups.Store(0)
|
|
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
if _, err := resolveOneChunkManifest(context.Background(), lookup, chunk, nil, cache, nil); err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
b.StopTimer()
|
|
b.ReportMetric(float64(fixture.loads.Load())/float64(b.N), "fetches/op")
|
|
b.ReportMetric(float64(lookups.Load())/float64(b.N), "lookups/op")
|
|
})
|
|
}
|
|
}
|
|
|
|
func BenchmarkManifestResolutionWithoutCache(b *testing.B) {
|
|
for _, delay := range []time.Duration{0, 5 * time.Millisecond, 20 * time.Millisecond} {
|
|
b.Run(fmt.Sprintf("latency=%s", delay), func(b *testing.B) {
|
|
fixture := newManifestReadFixture(b, map[string][]*filer_pb.FileChunk{
|
|
"benchmark-uncached": {resolveTestData("benchmark-data", 0)},
|
|
}, map[string]time.Duration{"benchmark-uncached": delay})
|
|
var lookups atomic.Int32
|
|
lookup := func(ctx context.Context, fileID string) ([]string, error) {
|
|
lookups.Add(1)
|
|
return fixture.lookup(ctx, fileID)
|
|
}
|
|
chunk := newManifestCacheTestChunk("benchmark-uncached")
|
|
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
if _, err := ResolveOneChunkManifest(context.Background(), lookup, chunk, nil); err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
b.StopTimer()
|
|
b.ReportMetric(float64(fixture.loads.Load())/float64(b.N), "fetches/op")
|
|
b.ReportMetric(float64(lookups.Load())/float64(b.N), "lookups/op")
|
|
})
|
|
}
|
|
}
|