{"id":16512932,"url":"https://github.com/daskol/spinlock","last_synced_at":"2025-09-09T06:13:47.556Z","repository":{"id":88393016,"uuid":"139770895","full_name":"daskol/spinlock","owner":"daskol","description":"Spinlock implementation in Go and inline assembler.","archived":false,"fork":false,"pushed_at":"2018-07-26T16:39:12.000Z","size":6,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T11:25:11.050Z","etag":null,"topics":["amd64","assembler","assembly","cas","golang","spinlock"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daskol.png","metadata":{"files":{"readme":"README.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}},"created_at":"2018-07-04T22:33:09.000Z","updated_at":"2024-08-28T03:02:01.000Z","dependencies_parsed_at":"2023-03-04T03:15:17.652Z","dependency_job_id":null,"html_url":"https://github.com/daskol/spinlock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskol%2Fspinlock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskol%2Fspinlock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskol%2Fspinlock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskol%2Fspinlock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daskol","download_url":"https://codeload.github.com/daskol/spinlock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238597386,"owners_count":19498396,"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","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":["amd64","assembler","assembly","cas","golang","spinlock"],"created_at":"2024-10-11T16:06:40.094Z","updated_at":"2025-02-13T04:32:13.194Z","avatar_url":"https://github.com/daskol.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spinlock\n\n*Spinlock implementation in Go and inline assembler.*\n\n## Overview\n\nPackage spinlock provides a low level implementation of spinlock in assembly.\nAlso, it provides fallback to implementation based on built-in atomics.\n\nOn my private laptop benchmark results are the following. Measured time is wall\ntime.\n\n```\n    goos: linux\n    goarch: amd64\n    pkg: github.com/daskol/spinlock\n    BenchmarkMutex/1-4                       50000000\t        37.7 ns/op\n    BenchmarkMutex/2-4                       30000000\t        52.4 ns/op\n    BenchmarkMutex/4-4                       20000000\t        64.4 ns/op\n    BenchmarkMutex/8-4                       20000000\t        83.8 ns/op\n    BenchmarkMutex/16-4                      20000000\t        91.2 ns/op\n    BenchmarkSpinlockInAsm/1-4              100000000\t        22.1 ns/op\n    BenchmarkSpinlockInAsm/2-4              100000000\t        22.1 ns/op\n    BenchmarkSpinlockInAsm/4-4              100000000\t        22.1 ns/op\n    BenchmarkSpinlockInAsm/8-4              100000000\t        22.8 ns/op\n    BenchmarkSpinlockInAsm/16-4             100000000\t        23.6 ns/op\n    BenchmarkSpinlockInGo/1-4                50000000\t        28.0 ns/op\n    BenchmarkSpinlockInGo/2-4                50000000\t        27.8 ns/op\n    BenchmarkSpinlockInGo/4-4                50000000\t        28.1 ns/op\n    BenchmarkSpinlockInGo/8-4                50000000\t        28.7 ns/op\n    BenchmarkSpinlockInGo/16-4               50000000\t        29.5 ns/op\n    BenchmarkSpinlockThin/1-4               100000000\t        17.8 ns/op\n    BenchmarkSpinlockThin/2-4               100000000\t        17.5 ns/op\n    BenchmarkSpinlockThin/4-4               100000000\t        17.6 ns/op\n    BenchmarkSpinlockThin/8-4               100000000\t        18.0 ns/op\n    BenchmarkSpinlockThin/16-4              100000000\t        18.4 ns/op\n    PASS\n    ok  \tgithub.com/daskol/spinlock\t39.539s\n```\n\nThe fastest implementation based on free function Lock()/Unlock(). However, it\nis two times slower than spinlock implemented in modern C++.\n\n```\n    Run on (4 X 3400 MHz CPU s)\n    CPU Caches:\n      L1 Data 32K (x2)\n      L1 Instruction 32K (x2)\n      L2 Unified 256K (x2)\n      L3 Unified 4096K (x1)\n    ---------------------------------------------------------------\n    Benchmark                        Time           CPU Iterations\n    ---------------------------------------------------------------\n    run/real_time/threads:1          9 ns          9 ns   74377642\n    run/real_time/threads:2          9 ns         19 ns   74705518\n    run/real_time/threads:4         11 ns         44 ns   64348172\n    run/real_time/threads:8         10 ns         43 ns   7931257\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaskol%2Fspinlock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaskol%2Fspinlock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaskol%2Fspinlock/lists"}