Skip to content
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

[WIP] (proof-of-concept) sqlite port of etcd #16328

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

logicalhan
Copy link

@logicalhan logicalhan commented Jul 31, 2023

[DO NOT MERGE] This is just a demonstrative PR, demonstrating the proof-of-concept of:

  • extracting out bolt and putting it behind an interface
  • implementing the interface using bolt
  • implementing the interface using sqlite

If you want to run etcd using sqlite, please apply this patch and run:

  • make
  • rm -rf default.etcd
  • ./bin/etcd

You can benchmark the performance of etcd using etcdctl by running ./bin/etcdctl check perf.

Note that this implementation of etcd-on-sqlite uses a pure golang version of sqlite, which is roughly half as fast as the full blown C implementation. Even so, the etcdctl performance tests suggest that the full golang version of sqlite seems roughly on par with bolt (if not a tad bit faster). For speed, we may want to consider using github.com/mattn/go-sqlite3, which compiles with CGO. However, this does break all of our build scripts and github actions since we presume that etcd can be compiled with CGO disabled.

All github actions (unmodified) are passing.

@ahrtr ahrtr marked this pull request as draft July 31, 2023 07:01
Han Kang added 4 commits July 31, 2023 07:03
Change-Id: I2dc656d216732582693346a5d79186c73af7c5ec
Signed-off-by: Han Kang <[email protected]>
Change-Id: Ied315a6089c9ee280d4e2ea33179831c29bc7c0b
Signed-off-by: Han Kang <[email protected]>
Signed-off-by: Han Kang <[email protected]>
use non-cgo implementation first, so that builds continue to function

Change-Id: I05aa62ad56a771552e81d397e59570737767346f
Signed-off-by: Han Kang <[email protected]>
@xiang90
Copy link
Contributor

xiang90 commented Aug 10, 2023

Normal ops do not matter that much. They are bounded by gRPC and disk performance more likely as etcd batches requests aggressively and the read path would probably not even hit disk io...

Compaction and snapshot performance and isolation probably matters more.

@siyuanfoundation
Copy link
Contributor

siyuanfoundation commented Dec 11, 2023

I did some memory profiling of the sqlite backend.
This is what I did:

  1. start etcd with sqlite bin/etcd --experimental-backend-type=sqlite --data-dir=sqlite.etcd --quota-backend-bytes=10737418240 --enable-pprof or bbolt backend bin/etcd --data-dir=bolt.etcd --quota-backend-bytes=10737418240 --enable-pprof.
  2. populate the db with go run tools/benchmark/main.go put --total=10000000 --key-size=64 --val-size=512.
  3. kill and restart etcd with sqlite or bbolt backend.
  4. profile with go tool pprof -http=":8000" pprofbin http://127.0.0.1:2379/debug/pprof/heap?debug=1

They both consume similar amount of memory. Even though sqlite should have much lower memory footprint in theory, there is not clear advantage of using sqlite over bbolt.

  • in-use memory profile with sqlite:
    8bHERJmx6R7UVbJ
    3VTTkaL8qeCMLeM

  • in-use memory profile with bbolt:
    BCpmxLtmMvuZc6R
    7mZHZRaEpWxjDhy

Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 17, 2024
@williamcaban
Copy link

williamcaban commented Apr 2, 2024

What are the next steps for this? Is there any follow-up discussion or plans for possible adoption? Specifically, are there noticeable benefits when handling defragmentation?

@stale stale bot removed the stale label Apr 2, 2024
@k8s-ci-robot
Copy link

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants