{"action":"opened","number":1798,"pull_request":{"url":"https://api.github.com/repos/npgsql/npgsql/pulls/1798","id":167057223,"html_url":"https://github.com/npgsql/npgsql/pull/1798","diff_url":"https://github.com/npgsql/npgsql/pull/1798.diff","patch_url":"https://github.com/npgsql/npgsql/pull/1798.patch","issue_url":"https://api.github.com/repos/npgsql/npgsql/issues/1798","number":1798,"state":"open","locked":false,"title":"Reimplement connection pool as lock-free","user":{"login":"roji","id":1862641,"avatar_url":"https://avatars0.githubusercontent.com/u/1862641?v=4","gravatar_id":"","url":"https://api.github.com/users/roji","html_url":"https://github.com/roji","followers_url":"https://api.github.com/users/roji/followers","following_url":"https://api.github.com/users/roji/following{/other_user}","gists_url":"https://api.github.com/users/roji/gists{/gist_id}","starred_url":"https://api.github.com/users/roji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roji/subscriptions","organizations_url":"https://api.github.com/users/roji/orgs","repos_url":"https://api.github.com/users/roji/repos","events_url":"https://api.github.com/users/roji/events{/privacy}","received_events_url":"https://api.github.com/users/roji/received_events","type":"User","site_admin":false},"body":"@anpete, @damageboy, would you care to review as this is a tricky and sensitive piece of code?\r\n\r\nIt basically reimplements all the standard ADO.NET functionality without taking any locks:\r\n\r\n* The fast path for allocation only scans the array and does `Interlocked.Exchange` to get a connector out, as in the minimal implementation @anpete provided. Releasing is similar except for some very minor added overhead.\r\n* MaxPoolSize is respected. Trying to allocate more will block your open attempt, by enqueuing a TaskCompletionSort in a ConcurrentQueue. This queue is checked first when releasing, effectively \"handing off\" the connection from the releaser to the opener without passing through the idle array.\r\n* A pruning thread runs periodically, scanning the idle list to see if any have been there for too long, and closes them if so (without going under MinPoolSize).\r\n* Performance counter updating is still there, although if they're disabled they're supposed to add very little performance.\r\n\r\nI'll benchmark this tomorrow to see how it behaves. I'd also really appreciate a review, because:\r\n\r\n![one-does-not-simply](https://user-images.githubusercontent.com/1862641/35788897-25d53670-09ed-11e8-82fe-ac665c159fcd.jpg)\r\n","created_at":"2018-02-05T04:51:31Z","updated_at":"2018-02-05T04:51:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/npgsql/npgsql/pulls/1798/commits","review_comments_url":"https://api.github.com/repos/npgsql/npgsql/pulls/1798/comments","review_comment_url":"https://api.github.com/repos/npgsql/npgsql/pulls/comments{/number}","comments_url":"https://api.github.com/repos/npgsql/npgsql/issues/1798/comments","statuses_url":"https://api.github.com/repos/npgsql/npgsql/statuses/da4c51c2bf9554bcda97bfe4e13a56f701003b5f","head":{"label":"roji:lockfree-pool","ref":"lockfree-pool","sha":"da4c51c2bf9554bcda97bfe4e13a56f701003b5f","user":{"login":"roji","id":1862641,"avatar_url":"https://avatars0.githubusercontent.com/u/1862641?v=4","gravatar_id":"","url":"https://api.github.com/users/roji","html_url":"https://github.com/roji","followers_url":"https://api.github.com/users/roji/followers","following_url":"https://api.github.com/users/roji/following{/other_user}","gists_url":"https://api.github.com/users/roji/gists{/gist_id}","starred_url":"https://api.github.com/users/roji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roji/subscriptions","organizations_url":"https://api.github.com/users/roji/orgs","repos_url":"https://api.github.com/users/roji/repos","events_url":"https://api.github.com/users/roji/events{/privacy}","received_events_url":"https://api.github.com/users/roji/received_events","type":"User","site_admin":false},"repo":{"id":6353001,"name":"Npgsql","full_name":"roji/Npgsql","owner":{"login":"roji","id":1862641,"avatar_url":"https://avatars0.githubusercontent.com/u/1862641?v=4","gravatar_id":"","url":"https://api.github.com/users/roji","html_url":"https://github.com/roji","followers_url":"https://api.github.com/users/roji/followers","following_url":"https://api.github.com/users/roji/following{/other_user}","gists_url":"https://api.github.com/users/roji/gists{/gist_id}","starred_url":"https://api.github.com/users/roji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roji/subscriptions","organizations_url":"https://api.github.com/users/roji/orgs","repos_url":"https://api.github.com/users/roji/repos","events_url":"https://api.github.com/users/roji/events{/privacy}","received_events_url":"https://api.github.com/users/roji/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/roji/Npgsql","description":null,"fork":true,"url":"https://api.github.com/repos/roji/Npgsql","forks_url":"https://api.github.com/repos/roji/Npgsql/forks","keys_url":"https://api.github.com/repos/roji/Npgsql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/roji/Npgsql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/roji/Npgsql/teams","hooks_url":"https://api.github.com/repos/roji/Npgsql/hooks","issue_events_url":"https://api.github.com/repos/roji/Npgsql/issues/events{/number}","events_url":"https://api.github.com/repos/roji/Npgsql/events","assignees_url":"https://api.github.com/repos/roji/Npgsql/assignees{/user}","branches_url":"https://api.github.com/repos/roji/Npgsql/branches{/branch}","tags_url":"https://api.github.com/repos/roji/Npgsql/tags","blobs_url":"https://api.github.com/repos/roji/Npgsql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/roji/Npgsql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/roji/Npgsql/git/refs{/sha}","trees_url":"https://api.github.com/repos/roji/Npgsql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/roji/Npgsql/statuses/{sha}","languages_url":"https://api.github.com/repos/roji/Npgsql/languages","stargazers_url":"https://api.github.com/repos/roji/Npgsql/stargazers","contributors_url":"https://api.github.com/repos/roji/Npgsql/contributors","subscribers_url":"https://api.github.com/repos/roji/Npgsql/subscribers","subscription_url":"https://api.github.com/repos/roji/Npgsql/subscription","commits_url":"https://api.github.com/repos/roji/Npgsql/commits{/sha}","git_commits_url":"https://api.github.com/repos/roji/Npgsql/git/commits{/sha}","comments_url":"https://api.github.com/repos/roji/Npgsql/comments{/number}","issue_comment_url":"https://api.github.com/repos/roji/Npgsql/issues/comments{/number}","contents_url":"https://api.github.com/repos/roji/Npgsql/contents/{+path}","compare_url":"https://api.github.com/repos/roji/Npgsql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/roji/Npgsql/merges","archive_url":"https://api.github.com/repos/roji/Npgsql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/roji/Npgsql/downloads","issues_url":"https://api.github.com/repos/roji/Npgsql/issues{/number}","pulls_url":"https://api.github.com/repos/roji/Npgsql/pulls{/number}","milestones_url":"https://api.github.com/repos/roji/Npgsql/milestones{/number}","notifications_url":"https://api.github.com/repos/roji/Npgsql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/roji/Npgsql/labels{/name}","releases_url":"https://api.github.com/repos/roji/Npgsql/releases{/id}","deployments_url":"https://api.github.com/repos/roji/Npgsql/deployments","created_at":"2012-10-23T13:46:24Z","updated_at":"2017-12-13T01:43:14Z","pushed_at":"2018-02-05T04:44:10Z","git_url":"git://github.com/roji/Npgsql.git","ssh_url":"git@github.com:roji/Npgsql.git","clone_url":"https://github.com/roji/Npgsql.git","svn_url":"https://github.com/roji/Npgsql","homepage":"","size":53528,"stargazers_count":2,"watchers_count":2,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1,"open_issues":0,"watchers":2,"default_branch":"dev"}},"base":{"label":"npgsql:dev","ref":"dev","sha":"f2e2d21eb7773170fe918b3f049c8861505e0a50","user":{"login":"npgsql","id":5766497,"avatar_url":"https://avatars2.githubusercontent.com/u/5766497?v=4","gravatar_id":"","url":"https://api.github.com/users/npgsql","html_url":"https://github.com/npgsql","followers_url":"https://api.github.com/users/npgsql/followers","following_url":"https://api.github.com/users/npgsql/following{/other_user}","gists_url":"https://api.github.com/users/npgsql/gists{/gist_id}","starred_url":"https://api.github.com/users/npgsql/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npgsql/subscriptions","organizations_url":"https://api.github.com/users/npgsql/orgs","repos_url":"https://api.github.com/users/npgsql/repos","events_url":"https://api.github.com/users/npgsql/events{/privacy}","received_events_url":"https://api.github.com/users/npgsql/received_events","type":"Organization","site_admin":false},"repo":{"id":2883574,"name":"npgsql","full_name":"npgsql/npgsql","owner":{"login":"npgsql","id":5766497,"avatar_url":"https://avatars2.githubusercontent.com/u/5766497?v=4","gravatar_id":"","url":"https://api.github.com/users/npgsql","html_url":"https://github.com/npgsql","followers_url":"https://api.github.com/users/npgsql/followers","following_url":"https://api.github.com/users/npgsql/following{/other_user}","gists_url":"https://api.github.com/users/npgsql/gists{/gist_id}","starred_url":"https://api.github.com/users/npgsql/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npgsql/subscriptions","organizations_url":"https://api.github.com/users/npgsql/orgs","repos_url":"https://api.github.com/users/npgsql/repos","events_url":"https://api.github.com/users/npgsql/events{/privacy}","received_events_url":"https://api.github.com/users/npgsql/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/npgsql/npgsql","description":"Npgsql is the .NET data provider for PostgreSQL.","fork":false,"url":"https://api.github.com/repos/npgsql/npgsql","forks_url":"https://api.github.com/repos/npgsql/npgsql/forks","keys_url":"https://api.github.com/repos/npgsql/npgsql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/npgsql/npgsql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/npgsql/npgsql/teams","hooks_url":"https://api.github.com/repos/npgsql/npgsql/hooks","issue_events_url":"https://api.github.com/repos/npgsql/npgsql/issues/events{/number}","events_url":"https://api.github.com/repos/npgsql/npgsql/events","assignees_url":"https://api.github.com/repos/npgsql/npgsql/assignees{/user}","branches_url":"https://api.github.com/repos/npgsql/npgsql/branches{/branch}","tags_url":"https://api.github.com/repos/npgsql/npgsql/tags","blobs_url":"https://api.github.com/repos/npgsql/npgsql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/npgsql/npgsql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/npgsql/npgsql/git/refs{/sha}","trees_url":"https://api.github.com/repos/npgsql/npgsql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/npgsql/npgsql/statuses/{sha}","languages_url":"https://api.github.com/repos/npgsql/npgsql/languages","stargazers_url":"https://api.github.com/repos/npgsql/npgsql/stargazers","contributors_url":"https://api.github.com/repos/npgsql/npgsql/contributors","subscribers_url":"https://api.github.com/repos/npgsql/npgsql/subscribers","subscription_url":"https://api.github.com/repos/npgsql/npgsql/subscription","commits_url":"https://api.github.com/repos/npgsql/npgsql/commits{/sha}","git_commits_url":"https://api.github.com/repos/npgsql/npgsql/git/commits{/sha}","comments_url":"https://api.github.com/repos/npgsql/npgsql/comments{/number}","issue_comment_url":"https://api.github.com/repos/npgsql/npgsql/issues/comments{/number}","contents_url":"https://api.github.com/repos/npgsql/npgsql/contents/{+path}","compare_url":"https://api.github.com/repos/npgsql/npgsql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/npgsql/npgsql/merges","archive_url":"https://api.github.com/repos/npgsql/npgsql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/npgsql/npgsql/downloads","issues_url":"https://api.github.com/repos/npgsql/npgsql/issues{/number}","pulls_url":"https://api.github.com/repos/npgsql/npgsql/pulls{/number}","milestones_url":"https://api.github.com/repos/npgsql/npgsql/milestones{/number}","notifications_url":"https://api.github.com/repos/npgsql/npgsql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/npgsql/npgsql/labels{/name}","releases_url":"https://api.github.com/repos/npgsql/npgsql/releases{/id}","deployments_url":"https://api.github.com/repos/npgsql/npgsql/deployments","created_at":"2011-11-30T14:13:32Z","updated_at":"2018-02-01T21:13:41Z","pushed_at":"2018-02-05T00:14:04Z","git_url":"git://github.com/npgsql/npgsql.git","ssh_url":"git@github.com:npgsql/npgsql.git","clone_url":"https://github.com/npgsql/npgsql.git","svn_url":"https://github.com/npgsql/npgsql","homepage":"http://www.npgsql.org","size":54824,"stargazers_count":1129,"watchers_count":1129,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":450,"mirror_url":null,"archived":false,"open_issues_count":157,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":450,"open_issues":157,"watchers":1129,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/npgsql/npgsql/pulls/1798"},"html":{"href":"https://github.com/npgsql/npgsql/pull/1798"},"issue":{"href":"https://api.github.com/repos/npgsql/npgsql/issues/1798"},"comments":{"href":"https://api.github.com/repos/npgsql/npgsql/issues/1798/comments"},"review_comments":{"href":"https://api.github.com/repos/npgsql/npgsql/pulls/1798/comments"},"review_comment":{"href":"https://api.github.com/repos/npgsql/npgsql/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/npgsql/npgsql/pulls/1798/commits"},"statuses":{"href":"https://api.github.com/repos/npgsql/npgsql/statuses/da4c51c2bf9554bcda97bfe4e13a56f701003b5f"}},"author_association":"OWNER","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":287,"deletions":327,"changed_files":7}}
{"actor":{"display_login":"roji"}}