mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
A benchmark of its own (docs/Databases/FerretDB/1/SpeedTest/embedded, a Go module, no cgo) loads the speed test's cards into SQLite set up as FerretDB sets it and into Pebble, Badger, bbolt, BuntDB, Nutsdb and Clover, and asks each the six questions WeKan asks of cards, at 15,377 and 153,768 cards. A board's cards take the same time on every engine that is not slower, because decoding the JSON dominates; the key-value stores win single reads and writes by microseconds that a FerretDB call hides; Pebble is 12x slower on fetching a board, Clover 90-190x slower in total, and bbolt with its default fsync 100-160x slower on writes. The README accounts for every entry of the awesome-go section. Thanks to Raymond-Voogt and xet7 !
32 lines
859 B
Go
32 lines
859 B
Go
package main
|
|
|
|
import "strings"
|
|
|
|
// The key layout a handler on a key-value store would have to build: the document
|
|
// under d/<id>, and the index of (boardId, archived) as keys b/<board>/<0|1>/<id>
|
|
// with no value. A scan of the prefix b/<board>/0/ is "the unarchived cards of a
|
|
// board" and counting its keys is the count.
|
|
func docKey(id string) []byte { return []byte("d/" + id) }
|
|
|
|
func boardPrefix(board string) []byte { return []byte("b/" + board + "/0/") }
|
|
|
|
func indexKey(c Card) []byte {
|
|
a := "0"
|
|
if c.Archived {
|
|
a = "1"
|
|
}
|
|
return []byte("b/" + c.Board + "/" + a + "/" + c.ID)
|
|
}
|
|
|
|
func idFromIndexKey(k []byte) string {
|
|
s := string(k)
|
|
return s[strings.LastIndexByte(s, '/')+1:]
|
|
}
|
|
|
|
// prefixEnd is the first key after every key with the prefix.
|
|
func prefixEnd(p []byte) []byte {
|
|
end := append([]byte(nil), p...)
|
|
end[len(end)-1]++
|
|
return end
|
|
}
|