From 3f7a1ac4d7653510336490254637bdfa430f6f88 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 9 Jul 2026 11:21:09 +0200 Subject: [PATCH 1/6] daemon/containerd/identitycache: use FreelistMapType for bolt db From the [DB.FreelistType] GoDoc: // FreelistType sets the backend freelist type. There are two options. Array which is simple but endures // dramatic performance degradation if database is large and fragmentation in freelist is common. // The alternative one is using hashmap, it is faster in almost all circumstances // but it doesn't guarantee that it offers the smallest page id available. In normal case it is safe. // The default type is array FreelistType FreelistType While the default is still `FreelistArrayType`, the package shows that the intent is to make `FreelistMapType` the default in future; https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#pkg-constants // TODO(ahrtr): eventually we should (step by step) // 1. default to `FreelistMapType`; // 2. remove the `FreelistArrayType`, do not export `FreelistMapType` // and remove field `FreelistType' from both `DB` and `Options`; [DB.FreelistType]: https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#DB.FreelistType Signed-off-by: Sebastiaan van Stijn --- daemon/containerd/identitycache/bbolt.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/containerd/identitycache/bbolt.go b/daemon/containerd/identitycache/bbolt.go index 80d14d2269..579e51ee1c 100644 --- a/daemon/containerd/identitycache/bbolt.go +++ b/daemon/containerd/identitycache/bbolt.go @@ -31,7 +31,9 @@ func NewBoltDBBackend(root string) (Backend, error) { if err := os.MkdirAll(cacheDir, 0o700); err != nil { return nil, err } - db, err := safeOpen(filepath.Join(cacheDir, "identity-cache.db"), 0o600, nil) + db, err := safeOpen(filepath.Join(cacheDir, "identity-cache.db"), 0o600, &bolt.Options{ + FreelistType: bolt.FreelistMapType, + }) if err != nil { return nil, err } From f74379995a7b8c27b43cb0acf880476d59fd66bb Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 9 Jul 2026 11:22:10 +0200 Subject: [PATCH 2/6] daemon: configureLocalContentStore: use FreelistMapType for bolt db From the [DB.FreelistType] GoDoc: // FreelistType sets the backend freelist type. There are two options. Array which is simple but endures // dramatic performance degradation if database is large and fragmentation in freelist is common. // The alternative one is using hashmap, it is faster in almost all circumstances // but it doesn't guarantee that it offers the smallest page id available. In normal case it is safe. // The default type is array FreelistType FreelistType While the default is still `FreelistArrayType`, the package shows that the intent is to make `FreelistMapType` the default in future; https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#pkg-constants // TODO(ahrtr): eventually we should (step by step) // 1. default to `FreelistMapType`; // 2. remove the `FreelistArrayType`, do not export `FreelistMapType` // and remove field `FreelistType' from both `DB` and `Options`; [DB.FreelistType]: https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#DB.FreelistType Signed-off-by: Sebastiaan van Stijn --- daemon/content.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/content.go b/daemon/content.go index b06ba3747b..fda72a9369 100644 --- a/daemon/content.go +++ b/daemon/content.go @@ -20,7 +20,9 @@ func (daemon *Daemon) configureLocalContentStore(ns string) (*namespacedContent, if err := os.MkdirAll(filepath.Join(daemon.root, "content"), 0o700); err != nil { return nil, nil, errors.Wrap(err, "error creating dir for content store") } - db, err := bolt.Open(filepath.Join(daemon.root, "content", "metadata.db"), 0o600, nil) + db, err := bolt.Open(filepath.Join(daemon.root, "content", "metadata.db"), 0o600, &bolt.Options{ + FreelistType: bolt.FreelistMapType, + }) if err != nil { return nil, nil, errors.Wrap(err, "error opening bolt db for content metadata store") } From 3272a787c193d763ed0fd4d5b14a9fab4e1970b5 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 9 Jul 2026 11:23:20 +0200 Subject: [PATCH 3/6] daemon: builder-next: NewSnapshotter: use FreelistMapType for bolt db From the [DB.FreelistType] GoDoc: // FreelistType sets the backend freelist type. There are two options. Array which is simple but endures // dramatic performance degradation if database is large and fragmentation in freelist is common. // The alternative one is using hashmap, it is faster in almost all circumstances // but it doesn't guarantee that it offers the smallest page id available. In normal case it is safe. // The default type is array FreelistType FreelistType While the default is still `FreelistArrayType`, the package shows that the intent is to make `FreelistMapType` the default in future; https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#pkg-constants // TODO(ahrtr): eventually we should (step by step) // 1. default to `FreelistMapType`; // 2. remove the `FreelistArrayType`, do not export `FreelistMapType` // and remove field `FreelistType' from both `DB` and `Options`; [DB.FreelistType]: https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#DB.FreelistType Signed-off-by: Sebastiaan van Stijn --- daemon/internal/builder-next/adapters/snapshot/snapshot.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/internal/builder-next/adapters/snapshot/snapshot.go b/daemon/internal/builder-next/adapters/snapshot/snapshot.go index 931ec738ee..8eb991b933 100644 --- a/daemon/internal/builder-next/adapters/snapshot/snapshot.go +++ b/daemon/internal/builder-next/adapters/snapshot/snapshot.go @@ -62,7 +62,9 @@ type snapshotter struct { // NewSnapshotter creates a new snapshotter func NewSnapshotter(opt Opt, prevLM leases.Manager, ns string) (_ snapshot.Snapshotter, _ *leaseutil.Manager, retErr error) { dbPath := filepath.Join(opt.Root, "snapshots.db") - db, err := bolt.Open(dbPath, 0o600, nil) + db, err := bolt.Open(dbPath, 0o600, &bolt.Options{ + FreelistType: bolt.FreelistMapType, + }) if err != nil { return nil, nil, errors.Wrapf(err, "failed to open database file %s", dbPath) } From e005ac05d0d3383894e28fe11636f65feadc197a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 9 Jul 2026 11:23:59 +0200 Subject: [PATCH 4/6] daemon: builder-next: openHistoryDB: use FreelistMapType for bolt db From the [DB.FreelistType] GoDoc: // FreelistType sets the backend freelist type. There are two options. Array which is simple but endures // dramatic performance degradation if database is large and fragmentation in freelist is common. // The alternative one is using hashmap, it is faster in almost all circumstances // but it doesn't guarantee that it offers the smallest page id available. In normal case it is safe. // The default type is array FreelistType FreelistType While the default is still `FreelistArrayType`, the package shows that the intent is to make `FreelistMapType` the default in future; https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#pkg-constants // TODO(ahrtr): eventually we should (step by step) // 1. default to `FreelistMapType`; // 2. remove the `FreelistArrayType`, do not export `FreelistMapType` // and remove field `FreelistType' from both `DB` and `Options`; [DB.FreelistType]: https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#DB.FreelistType Signed-off-by: Sebastiaan van Stijn --- daemon/internal/builder-next/controller.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/daemon/internal/builder-next/controller.go b/daemon/internal/builder-next/controller.go index 9ba7f16668..d4f913d2cf 100644 --- a/daemon/internal/builder-next/controller.go +++ b/daemon/internal/builder-next/controller.go @@ -235,7 +235,9 @@ func newSnapshotterController(ctx context.Context, rt http.RoundTripper, opt Opt } func openHistoryDB(root string, fn string, cfg *config.BuilderHistoryConfig) (*bolt.DB, *bkconfig.HistoryConfig, error) { - db, err := bolt.Open(filepath.Join(root, fn), 0o600, nil) + db, err := bolt.Open(filepath.Join(root, fn), 0o600, &bolt.Options{ + FreelistType: bolt.FreelistMapType, + }) if err != nil { return nil, nil, err } @@ -285,7 +287,9 @@ func newGraphDriverController(ctx context.Context, rt http.RoundTripper, opt Opt return nil, err } - db, err := bolt.Open(filepath.Join(root, "containerdmeta.db"), 0o644, nil) + db, err := bolt.Open(filepath.Join(root, "containerdmeta.db"), 0o644, &bolt.Options{ + FreelistType: bolt.FreelistMapType, + }) if err != nil { return nil, errors.WithStack(err) } From 7c6a49c3b19b0c6b6e15c6177691d7f90ad669b0 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 9 Jul 2026 11:24:46 +0200 Subject: [PATCH 5/6] daemon/volume/service: NewStore: use FreelistMapType for bolt db From the [DB.FreelistType] GoDoc: // FreelistType sets the backend freelist type. There are two options. Array which is simple but endures // dramatic performance degradation if database is large and fragmentation in freelist is common. // The alternative one is using hashmap, it is faster in almost all circumstances // but it doesn't guarantee that it offers the smallest page id available. In normal case it is safe. // The default type is array FreelistType FreelistType While the default is still `FreelistArrayType`, the package shows that the intent is to make `FreelistMapType` the default in future; https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#pkg-constants // TODO(ahrtr): eventually we should (step by step) // 1. default to `FreelistMapType`; // 2. remove the `FreelistArrayType`, do not export `FreelistMapType` // and remove field `FreelistType' from both `DB` and `Options`; [DB.FreelistType]: https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#DB.FreelistType Signed-off-by: Sebastiaan van Stijn --- daemon/volume/service/store.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/daemon/volume/service/store.go b/daemon/volume/service/store.go index 2f8779c61f..0590fa4b5d 100644 --- a/daemon/volume/service/store.go +++ b/daemon/volume/service/store.go @@ -104,7 +104,10 @@ func NewStore(rootPath string, drivers *drivers.Store, opts ...StoreOpt) (*Volum var err error dbPath := filepath.Join(volPath, "metadata.db") - vs.db, err = bolt.Open(dbPath, 0o600, &bolt.Options{Timeout: 1 * time.Second}) + vs.db, err = bolt.Open(dbPath, 0o600, &bolt.Options{ + Timeout: 1 * time.Second, + FreelistType: bolt.FreelistMapType, + }) if err != nil { return nil, errors.Wrapf(err, "error while opening volume store metadata database (%s)", dbPath) } From a064db5d089a9c9a4c9b91cfe6e24175c0cba5b4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 9 Jul 2026 11:25:59 +0200 Subject: [PATCH 6/6] daemon/libnetwork/internal/kvstore: use FreelistMapType for bolt db From the [DB.FreelistType] GoDoc: // FreelistType sets the backend freelist type. There are two options. Array which is simple but endures // dramatic performance degradation if database is large and fragmentation in freelist is common. // The alternative one is using hashmap, it is faster in almost all circumstances // but it doesn't guarantee that it offers the smallest page id available. In normal case it is safe. // The default type is array FreelistType FreelistType While the default is still `FreelistArrayType`, the package shows that the intent is to make `FreelistMapType` the default in future; https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#pkg-constants // TODO(ahrtr): eventually we should (step by step) // 1. default to `FreelistMapType`; // 2. remove the `FreelistArrayType`, do not export `FreelistMapType` // and remove field `FreelistType' from both `DB` and `Options`; [DB.FreelistType]: https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#DB.FreelistType Signed-off-by: Sebastiaan van Stijn --- daemon/libnetwork/internal/kvstore/boltdb/boltdb.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/daemon/libnetwork/internal/kvstore/boltdb/boltdb.go b/daemon/libnetwork/internal/kvstore/boltdb/boltdb.go index d9d27f9fb5..885eba3484 100644 --- a/daemon/libnetwork/internal/kvstore/boltdb/boltdb.go +++ b/daemon/libnetwork/internal/kvstore/boltdb/boltdb.go @@ -45,7 +45,8 @@ func New(path, bucket string) (store.Store, error) { // bbolt package returns an ErrTimeout straight away. That way, the // daemon, and unit tests, will fail fast and loudly instead of // silently introducing delays. - Timeout: time.Nanosecond, + Timeout: time.Nanosecond, + FreelistType: bolt.FreelistMapType, }) if err != nil { if errors.Is(err, berrors.ErrTimeout) {