[#1462] writecache: Persist objects in batches

`Update` becomes a botleneck under a heavy load.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-06-02 20:06:36 +03:00 committed by LeL
parent 6ad87e7959
commit 43e776dfb1

View file

@ -81,7 +81,7 @@ func (c *cache) persistSmallObjects(objs []objectInfo) {
cacheSize = newSize
}
err := c.db.Update(func(tx *bbolt.Tx) error {
err := c.db.Batch(func(tx *bbolt.Tx) error {
b := tx.Bucket(defaultBucket)
for i := 0; i < overflowIndex; i++ {
err := b.Put([]byte(objs[i].addr), objs[i].data)