{"id":16839591,"url":"https://github.com/mxinden/elimination-backoff-stack","last_synced_at":"2025-04-11T05:21:34.404Z","repository":{"id":96661590,"uuid":"247485995","full_name":"mxinden/elimination-backoff-stack","owner":"mxinden","description":"Lock-free elimination back-off stack","archived":false,"fork":false,"pushed_at":"2022-01-06T06:36:05.000Z","size":113,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T03:24:57.869Z","etag":null,"topics":["concurrent-data-structure","lock-free","parallel","rust","stack"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/mxinden.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":"2020-03-15T14:46:53.000Z","updated_at":"2023-08-14T11:15:54.000Z","dependencies_parsed_at":"2023-03-20T22:06:36.365Z","dependency_job_id":null,"html_url":"https://github.com/mxinden/elimination-backoff-stack","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/mxinden%2Felimination-backoff-stack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxinden%2Felimination-backoff-stack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxinden%2Felimination-backoff-stack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxinden%2Felimination-backoff-stack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mxinden","download_url":"https://codeload.github.com/mxinden/elimination-backoff-stack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248346302,"owners_count":21088435,"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":["concurrent-data-structure","lock-free","parallel","rust","stack"],"created_at":"2024-10-13T12:32:56.573Z","updated_at":"2025-04-11T05:21:34.388Z","avatar_url":"https://github.com/mxinden.png","language":"Rust","readme":"**Work in progress**\n\nBefore you consider using this ask yourself the following questions:\n\n- *Is my workload running on a machine \u003e 8 cores?*\n\n    If not you likely won't see enough contention that an elimination back-off\n    stack outperforms a classic Treiber stack or even an `Arc\u003cMutex\u003cVec\u003cT\u003e\u003e\u003e`.\n\n- *Do I trust the author's use of atomics?*\n\n    If yes, take a look at all `grep -r -E \"compare_and_set\"` anyways.\n\n- *Do I need a single coordination point through a stack to solve my problem?*\n\n    Think about how you could solve your problem in a parallel fashion requiring\n    less coordination.\n\n\n# Lock-free elimination back-off stack\n\nA normal lock-free Treiber stack [1] linearizes concurrent access through a\nsingle atomic `head` pointer on which `push` and `pop` operations loop trying to\ncompare-and-swap it. Usually one uses exponential backoff to circumvent\ncontention. This results in a single sequential bottleneck and a lot of cache\ncoherence traffic.\n\nA [lock-free elimination back-off\nstack](https://people.csail.mit.edu/shanir/publications/Lock_Free.pdf) wraps\nsuch a lock-free Treiber stack, but instead of simply exponentially backing off\non compare-and-swap failures, it uses something called an `EliminationArray`.\nEach slot within such an `EliminationArray` enables a thread executing a `push`\noperation to hand its item over to a thread executing a `pop` operation. On\ncontention a thread tries to *exchange* on a randomly chosen slot within the\n`EliminationArray`. On failure of such an *exchange* it loops to the beginning\nretrying on the stack again.\n\nThe result is a lock-free stack that is both _linearizable_ and _parallel_.\n\n\n### Silly Benchmark\n\nCriterion test comparing:\n\n- `Arc\u003cMutex\u003cVec\u003c_\u003e\u003e\u003e`\n\n- `TreiberStack`\n\n- `EliminationBackoffStack` - Simply switching back and forth between stack and\nelimination array.\n\n- `EliminationBackoffStack` - Exponentially backing off from the stack to the\nelimination array both in space and time.\n\n\nX-Axis: Number of competing threads.\n\nY-Axis: Average time it took all threads to push and pop 1000 items each.\n\n\n![Performance](./.assets/lines.svg)\n\n\n[1] Treiber, R. Kent. Systems programming: Coping with parallelism. New York:\nInternational Business Machines Incorporated, Thomas J. Watson Research Center,\n1986.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxinden%2Felimination-backoff-stack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmxinden%2Felimination-backoff-stack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxinden%2Felimination-backoff-stack/lists"}