Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

perf(s3/lifecycle): defer pool Put on ShardID hasher

Chris Luec83a87d683f
diff --git a/weed/s3api/s3lifecycle/shard.go b/weed/s3api/s3lifecycle/shard.go
index 080be9cdf8..7aed347151 100644
--- a/weed/s3api/s3lifecycle/shard.go
+++ b/weed/s3api/s3lifecycle/shard.go
@@ -22,12 +22,12 @@ var shardHashPool = sync.Pool{
// the same shard. Implementation: top 4 bits of sha256(bucket || "/" || key).
func ShardID(bucket, key string) int {
h := shardHashPool.Get().(hash.Hash)
+ defer shardHashPool.Put(h)
h.Reset()
h.Write([]byte(bucket))
h.Write([]byte{'/'})
h.Write([]byte(key))
var buf [sha256.Size]byte
sum := h.Sum(buf[:0])
- shardHashPool.Put(h)
return int(sum[0] >> 4)
}