-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow write speeds #134
Comments
40-70 ms is an eternity. To start troubleshooting the issue the first thing I'd try is removing bolthold from the equation entirely. Just do inserts directly into boltdb, and see if it's still taking that long. |
I actually switched to the sister version - badgerhold - and it went down to 20ms... Still crazy long IMO. How much time is considered normal in your experience for a single write? Just so I have a vague target for my debugging. I'll try doing it directly to Bolt instead and see what happens |
I'll throw together some quick timings on my machine, which has spinning metal and ssd's. BadgerDB's storage format is designed specifically to take advantage of SSD's where as Bolt doesn't. https://dgraph.io/blog/post/badger/ Looking at dgraph's benchmarks you should see inserts at around 9ms depending on the size of the insert. And if there are index inserts, then you should double that number 9ms for the main insert, and another 9 ms for the index insert. |
So I tried to access bolt directly via boltholdstore.db.Bolt()... All I can say is wow. I wrote my own pretty straightforward put transaction with a bucket NextSequence. The tx.commit part of the tx alone takes ~60ms. That's just crazy. I was working on my own database previously and was getting about 70 us (0.07ms) per write with Badger. Granted, badger is faster than Bolt... but... a thousand times faster is definitely fishy. No clue what could be slowing it down but I'll continue to poke around. It seems at this point that this isn't a bolthold thing at least. Though, it's still possible that some init setting is causing this slow write speed. Not sure. I'll do another test setting up my own bolt db instead of accessing it through bolthold and see if it makes a difference. Can't imagine it will, but then at least then I can totally rule out bolthold. |
Thanks for relaying the info. I know boltdb and badger have very different goals, where as bolt aims for simplicity and (https://github.com/boltdb/bolt#leveldb-rocksdb) and badger is designed for with a file format catered towards SSDs. |
BadgerDB doesn't sync writes with the default config as far as i know. package main
import (
"fmt"
"time"
"github.com/timshannon/badgerhold"
)
type PostType struct {
Name string `json:"name"`
PluralName string `json:"pluralName"`
PostTypeID uint64 `json:"postTypeID" boltholdKey:"PostTypeID"`
Fields FieldMap `json:"fields"`
}
type FieldMap map[uint64]Field
type Field struct {
Name string
Kind string
Slug string
Options string
}
func main() {
options := badgerhold.DefaultOptions
options.Dir = "data"
options.ValueDir = "data"
options.SyncWrites = false
d, err := badgerhold.Open(options)
if err != nil {
panic(err)
}
pt := PostType{}
for i := 0; i < 100; i++ {
x := time.Now()
err = d.Insert(badgerhold.NextSequence(), &pt)
fmt.Println(err)
fmt.Println("Creation time: ", time.Since(x))
}
} With this config i get (badgerhold): With activated sync writes and badgerhold (saver): With Bolthold: With bolthold and NoSync flag=true: This is on a relatively slow pc: |
Same test on my Notebook: With this config i get (badgerhold): With activated sync writes and badgerhold (saver): With Bolthold: With bolthold and NoSync flag=true: |
Is it normal to need ~40-70ms for one write on an SSD and a decent processor?
Creation time usually hangs out around 40-70ms
The text was updated successfully, but these errors were encountered: