{"id":21089025,"url":"https://github.com/hanabu/rust-diesel-oltp-benchmark","last_synced_at":"2026-05-17T20:37:47.103Z","repository":{"id":261624660,"uuid":"881920667","full_name":"hanabu/rust-diesel-oltp-benchmark","owner":"hanabu","description":"TPC-C like database benchmark implemented in Rust Diesel ORM","archived":false,"fork":false,"pushed_at":"2025-04-09T15:10:13.000Z","size":124,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-31T10:09:23.391Z","etag":null,"topics":["benchmark","diesel-rs","rust","sql","tpc-c"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanabu.png","metadata":{"files":{"readme":"README.ja.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-01T13:56:50.000Z","updated_at":"2025-04-09T15:10:17.000Z","dependencies_parsed_at":"2024-12-16T16:22:35.533Z","dependency_job_id":"70d11c9c-a74f-4ecc-967b-3aff1777caa2","html_url":"https://github.com/hanabu/rust-diesel-oltp-benchmark","commit_stats":null,"previous_names":["hanabu/rust-diesel-oltp-benchmark"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hanabu/rust-diesel-oltp-benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanabu%2Frust-diesel-oltp-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanabu%2Frust-diesel-oltp-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanabu%2Frust-diesel-oltp-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanabu%2Frust-diesel-oltp-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanabu","download_url":"https://codeload.github.com/hanabu/rust-diesel-oltp-benchmark/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanabu%2Frust-diesel-oltp-benchmark/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33154079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmark","diesel-rs","rust","sql","tpc-c"],"created_at":"2024-11-19T21:22:43.200Z","updated_at":"2026-05-17T20:37:47.072Z","avatar_url":"https://github.com/hanabu.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![en](https://img.shields.io/badge/lang-en-blue.svg)](README.md)\n[![ja](https://img.shields.io/badge/lang-ja-green.svg)](README.ja.md)\n\n# TPC-C like database benchmark written in Rust Diesel ORM\n\n[TPC-C](https://www.tpc.org/tpcc/) OLTP benchmark を Rust の [Diesel ORM](https://diesel.rs/) で実装したもの。\n\n## 動機\n\n[AWS EFS](https://aws.amazon.com/efs/) に [SQLite](https://www.sqlite.org/) database を載せたときにどのぐらい遅いか測ってみたい。妥当な database benchmark を設計するだけの経験を持っていないため、先人の知恵の詰まっているであろう TPCの標準 benchmark 仕様で計ってみた。\n\n## 使い方\n\nBenchmark は HTTP server となる測定対象部 (SUT, System Under Test) と、HTTP client となる模擬 client (Remote Terminal Emulator) からなる。先に SUT を起動しておいた状態で、RTE から連続して request 行って測定する。\n\n```console\n$ cd diesel-tpc-c/sut\n\n(Run SQLite backend)\n$ cargo run --release\n\n(Run PostgreSQL backend)\n$ export DATABASE_URL=postgres://user:password@db_host/db_name\n$ cargo run --release --no-default-features --features=postgres\n```\n\n上記のように SUT を起動しておいた状態で、RTE から benchmark を実行。\n\n- `-s` : Scale factor (倉庫の数)\n- `-c` : 同時に接続する接続数\n- `-d` : 測定時間(秒)\n\n```console\n$ cd diesel-tpc-c/rte\n\n(Prepare database)\n$ cargo run -- prepare -s 1 http://localhost:3000\n\n(Run benchmark)\n$ cargo run -- run -c 1 -d 30 http://localhost:3000\n...\n[INFO  rte] Start benchmark\n[INFO  rte] Finished\n2403.0 tpm  ( 2403 new_order transactions in 60.000 secs )\n\n##                calls , e2e total,  begin   ,  query   ,  commit\n##             ( counts ) (sec/call) (sec/call) (sec/call) (sec/call)\nnew_order:          2817,  0.011591,  0.000069,  0.001447,  0.009043\npayment:            2816,  0.009881,  0.000063,  0.000538,  0.008327\norder_status:        256,  0.002263,  0.000043,  0.001324,  0.000070\ndelivery:            256,  0.012014,  0.000069,  0.001776,  0.009159\nstock_level:        2560,  0.001402,  0.000040,  0.000624,  0.000071\ncustomer_by_name:   1828,  0.001150,  0.000048,  0.000160,  0.000069\n```\n\n上記の結果例では、`2403.0 tpm` が benchmark の測定値になる。  \nTPC-C 標準では、new\\_order, payment, order\\_status, delivery, stock\\_level の 5つの transaction を一定の割合で呼び出したときの 1分あたりの new_order 実行数を測定指標としている。\n\n## TPC-C 標準への準拠\n\nなるべく TPC-C 5.11 の仕様に合わせて実装しているが、以下の点は標準に従っていない。\n\n- 仕様では、RTE は key 入力待ち時間を模擬することになっているが、本実装では待たずに連続して request を行っている\n- 仕様では、RTE の画面表示も規定されているが、画面表示は実装していない (画面表示に必要な項目は、SUT からの応答として JSON 形式で返してはいる)\n- Scale factor\u003e1 で複数の倉庫を扱う場合に、他の倉庫 (remote warehouse) の在庫引き当てをする処理が規定されているが、本実装では正しく実装していない\n- 他にも非準拠はあるかも\n\n----\n\n## SQLite on EFS\n\nSSD を載せた PC 上で走らせること比較して、network file system である EFS で走らせた場合、1/10 ～ 1/20 程度の性能。比較すると遅いが、使えなくはないレベル感。\n\n1並列: Benchmark 実行 70秒間で 524 transactions, EFS burst credit を 105MB 消費。SQLite database の file size は 約90MB。\n\n```\n149.0 tpm  ( 149 new_order transactions in 60.000 secs )\n##                calls , e2e total,  begin   ,  query   ,  commit\n##             ( counts ) (sec/call) (sec/call) (sec/call) (sec/call)\nnew_order:           172,  0.179153,  0.025044,  0.055892,  0.080491\npayment:             171,  0.107907,  0.024298,  0.008262,  0.060720\norder_status:         16,  0.080568,  0.000043,  0.062220,  0.004832\ndelivery:             15,  0.186698,  0.025183,  0.017058,  0.129534\nstock_level:         150,  0.071711,  0.000042,  0.052575,  0.004807\ncustomer_by_name:    108,  0.055207,  0.000041,  0.034713,  0.005373\n```\n\n2並列: Benchmark 実行 70秒間で 146 transactions, EFS burst credit を 143MB 消費。SQLite database の file size は 約90MB。  \n同時に並行して request すると lock 競合して遅くなるうえに、cache が効かないため EFS の IO 量も増加。\n\n```\n39.0 tpm  ( 39 new_order transactions in 60.000 secs )\n##                calls , e2e total,  begin   ,  query   ,  commit\n##             ( counts ) (sec/call) (sec/call) (sec/call) (sec/call)\nnew_order:            49,  0.895723,  0.193402,  0.238216,  0.425100\npayment:              48,  0.716544,  0.193371,  0.039067,  0.470254\norder_status:          5,  0.119379,  0.000038,  0.101246,  0.005766\ndelivery:              4,  1.225100,  0.233055,  0.294449,  0.683861\nstock_level:          40,  1.338246,  0.000037,  1.318307,  0.006060\ncustomer_by_name:     27,  0.210721,  0.000040,  0.187270,  0.009398\n```\n\n条件は以下:\n\n- AWS ap-northeast-1 Tokyo region\n- SUTの実行環境 : AWS Lambda Arm64, 1792MB, AmazonLinux 2023 runtime\n- RTEの設定 : Scale factor=1\n- EFS: burst throughput mode\n- SQLite-3.48.0, Diesel-2.2.8, Rust-1.85.0\n\n### EFS で SQLite を使う場合の注意\n\n- [WAL mode](https://www.sqlite.org/wal.html) は使用できない。WAL は mmap による共有 memory を必要とするが、NFS では利用できないため。WAL mode で使うと SQLite file が壊れるため `PRAGMA journal_mode = DELETE;` で利用する。\n- [cache size](https://www.sqlite.org/pragma.html#pragma_cache_size) は大きくしたほうが良い。上記の TPC-C benchmark では cache size 2MB -\u003e 32MiB で 約40tpm -\u003e 約120tpm へ改善。\n- 複数の query を `BEGIN TRANSACTION; ... COMMIT;` にまとめるとよい。File lock が transaction 単位にまとめて 1回 で済む。EFS は network 経由で file lock のため遅延が大きく、file lock 回数削減は性能に影響が出やすい。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanabu%2Frust-diesel-oltp-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanabu%2Frust-diesel-oltp-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanabu%2Frust-diesel-oltp-benchmark/lists"}