{"id":18119794,"url":"https://github.com/mostlygeek/go-sqlite3-locking","last_synced_at":"2025-08-02T16:12:58.798Z","repository":{"id":66828437,"uuid":"142326384","full_name":"mostlygeek/go-sqlite3-locking","owner":"mostlygeek","description":"Test sqlite3 locking vs golang sync.Mutex","archived":false,"fork":false,"pushed_at":"2018-08-23T19:51:21.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T11:18:40.852Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mostlygeek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-07-25T16:30:22.000Z","updated_at":"2025-03-11T16:10:00.000Z","dependencies_parsed_at":"2023-03-16T12:15:44.263Z","dependency_job_id":null,"html_url":"https://github.com/mostlygeek/go-sqlite3-locking","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mostlygeek/go-sqlite3-locking","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostlygeek%2Fgo-sqlite3-locking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostlygeek%2Fgo-sqlite3-locking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostlygeek%2Fgo-sqlite3-locking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostlygeek%2Fgo-sqlite3-locking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mostlygeek","download_url":"https://codeload.github.com/mostlygeek/go-sqlite3-locking/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostlygeek%2Fgo-sqlite3-locking/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268416634,"owners_count":24246945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-01T05:17:04.533Z","updated_at":"2025-08-02T16:12:58.772Z","avatar_url":"https://github.com/mostlygeek.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Test sqlite3 locking situations\n\nTesting performance and behaviour of doing locking in go's runtime vs sqlite's runtime.\nThe test sets up parallel readers and writers.  Each reader will try to read from the database as\nfast as possible.  Writers will clear a work queue of updates to do.  Print some interesting\nASCII art of the access patterns.\n\nSo far the fastest configuration after [adding db.SetMaxConns(1)](https://github.com/mostlygeek/go-sqlite3-locking/commit/f35ab6ca464b0fe0b3e2a71e76037bf9ebc551ee) is: `./test-sqlite -wal -type none`.  \n\n## Installing dependencies:\n\nThis will fetch and prebuild go-sqlit3:\n\n`$ go install github.com/mattn/go-sqlite3`\n\n\n## Running it:\n\n```\n# building it\n$ go build . -o test-sqlite\n\n# cli help\n$ ./test-sqlite -h\nUsage of ./test-sqlite:\n  -readers int\n        Number of parallel readers  (default 2)\n  -rows int\n        Number of total DB rows, lower number = more contention (default 10)\n  -type string\n        Locking type: [none, mutex, rwmutex] (default \"none\")\n  -updates int\n        How many UPDATE dml operations to perform over numRows (default 500)\n  -wal\n        Use WAL mode for database\n  -writers int\n        Number of parallel writers (default 2)\n\n# (default) no locking, retries\n$ ./test-sqlite\n\n# using sync.Mutex\n$ ./test-sqlite -type mutex\n\n# using sync.RWMutex\n$ ./test-sqlite -type rwmutex\n```\n\n## Output\n\nA lot of fun ASCII symbols will be printed for the test, one for each retry, write and read.  This makes it easier to visualize what's happening.\n\n```\n$ ./test-sqlite -type rwmutex -updates 25\nLegend\n---------------------------\nWrite       :  .\nWrite Retry :  |\nRead        :  -\nRead Retry  :  |\n\nRunning sync.RWMutex test\n--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--\n\nDuration:  4.106226ms\n```\n\n## Try it with:\n\n```\n# more writers than readers\n$ ./test-sqlite -updates 500 -writers 4 -readers 3 -type mutex\n$ ./test-sqlite -updates 500 -writers 4 -readers 3 -type rwmutex\n\n# more readers than writers\n$ ./test-sqlite -updates 500 -writers 4 -readers 5 -type mutex\n$ ./test-sqlite -updates 500 -writers 4 -readers 5 -type rwmutex\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostlygeek%2Fgo-sqlite3-locking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmostlygeek%2Fgo-sqlite3-locking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostlygeek%2Fgo-sqlite3-locking/lists"}