{"action":"created","issue":{"url":"https://api.github.com/repos/mongodb/mongo/issues/622","labels_url":"https://api.github.com/repos/mongodb/mongo/issues/622/labels{/name}","comments_url":"https://api.github.com/repos/mongodb/mongo/issues/622/comments","events_url":"https://api.github.com/repos/mongodb/mongo/issues/622/events","html_url":"https://github.com/mongodb/mongo/pull/622","id":26708409,"number":622,"title":"SERVER-9580 Changed spinning code that waits for more data on tailable cursors for event based awakening","user":{"login":"jsbattig","id":1790597,"avatar_url":"https://avatars.githubusercontent.com/u/1790597?v=3","gravatar_id":"","url":"https://api.github.com/users/jsbattig","html_url":"https://github.com/jsbattig","followers_url":"https://api.github.com/users/jsbattig/followers","following_url":"https://api.github.com/users/jsbattig/following{/other_user}","gists_url":"https://api.github.com/users/jsbattig/gists{/gist_id}","starred_url":"https://api.github.com/users/jsbattig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsbattig/subscriptions","organizations_url":"https://api.github.com/users/jsbattig/orgs","repos_url":"https://api.github.com/users/jsbattig/repos","events_url":"https://api.github.com/users/jsbattig/events{/privacy}","received_events_url":"https://api.github.com/users/jsbattig/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-01-31T19:21:29Z","updated_at":"2015-01-15T22:50:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mongodb/mongo/pulls/622","html_url":"https://github.com/mongodb/mongo/pull/622","diff_url":"https://github.com/mongodb/mongo/pull/622.diff","patch_url":"https://github.com/mongodb/mongo/pull/622.patch"},"body":"Current implementation in tailable cursor imposes on the reader a wait of at least 2ms when cursor is exhausted even if new fresh data is inserted from another session.\r\nWhen using MongoDB to fuel a service-bus implementation, this imposes a very expensive 2ms penalty on the majority of the requests going thru the bus.\r\n\r\nA more scalable model implies using event notification while waiting for more data to avoid this unnecesary wait.\r\n\r\nThis wait has to be designed in a such a way to avoid imposing a too onerous cost on insertion of documents on collection object but yet achieving the goal of quick awakening of tailing cursors when waiting for more data.\r\n\r\nOn the collection side important to be noted that I have used an rwlock which is in the list of no-no for kernel, but I think it's justified in this case as it can allow concurrent sessions inserting documents to reduce contention when they notify subscribers.\r\nAn exclusive lock is acquired when new cursors register subscribers to wait for new documents when tailing.\r\nThere's an optimization on collection object to avoid creating the list<> that contains the subscribers unless it's necesary (first subscriber subscribing to collection)."},"comment":{"url":"https://api.github.com/repos/mongodb/mongo/issues/comments/70177876","html_url":"https://github.com/mongodb/mongo/pull/622#issuecomment-70177876","issue_url":"https://api.github.com/repos/mongodb/mongo/issues/622","id":70177876,"user":{"login":"jsbattig","id":1790597,"avatar_url":"https://avatars.githubusercontent.com/u/1790597?v=3","gravatar_id":"","url":"https://api.github.com/users/jsbattig","html_url":"https://github.com/jsbattig","followers_url":"https://api.github.com/users/jsbattig/followers","following_url":"https://api.github.com/users/jsbattig/following{/other_user}","gists_url":"https://api.github.com/users/jsbattig/gists{/gist_id}","starred_url":"https://api.github.com/users/jsbattig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsbattig/subscriptions","organizations_url":"https://api.github.com/users/jsbattig/orgs","repos_url":"https://api.github.com/users/jsbattig/repos","events_url":"https://api.github.com/users/jsbattig/events{/privacy}","received_events_url":"https://api.github.com/users/jsbattig/received_events","type":"User","site_admin":false},"created_at":"2015-01-15T22:50:46Z","updated_at":"2015-01-15T22:50:46Z","body":"Ben, I would love to do it, but we are buried with work at Convey so I\r\ndoubt I will be able to get to this potentially for a couple of weeks.\r\n\r\nI do recommended the whole package is reviewed by your team, as I think\r\nit's a critical enhancement to a big issue with tailable cursors.\r\n\r\nOn Thu, Jan 15, 2015 at 1:40 PM, Ben McCann <notifications@github.com>\r\nwrote:\r\n\r\n> @jsbattig <https://github.com/jsbattig> looks like the PR needs to be\r\n> rebased in order to be mergable\r\n>\r\n> —\r\n> Reply to this email directly or view it on GitHub\r\n> <https://github.com/mongodb/mongo/pull/622#issuecomment-70147680>.\r\n>"}}