{"action":"created","issue":{"url":"https://api.github.com/repos/grpc/grpc/issues/1758","labels_url":"https://api.github.com/repos/grpc/grpc/issues/1758/labels{/name}","comments_url":"https://api.github.com/repos/grpc/grpc/issues/1758/comments","events_url":"https://api.github.com/repos/grpc/grpc/issues/1758/events","html_url":"https://github.com/grpc/grpc/pull/1758","id":81316526,"number":1758,"title":"Revamped iomgr's callback mechanism","user":{"login":"dgquintas","id":120217,"avatar_url":"https://avatars.githubusercontent.com/u/120217?v=3","gravatar_id":"","url":"https://api.github.com/users/dgquintas","html_url":"https://github.com/dgquintas","followers_url":"https://api.github.com/users/dgquintas/followers","following_url":"https://api.github.com/users/dgquintas/following{/other_user}","gists_url":"https://api.github.com/users/dgquintas/gists{/gist_id}","starred_url":"https://api.github.com/users/dgquintas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgquintas/subscriptions","organizations_url":"https://api.github.com/users/dgquintas/orgs","repos_url":"https://api.github.com/users/dgquintas/repos","events_url":"https://api.github.com/users/dgquintas/events{/privacy}","received_events_url":"https://api.github.com/users/dgquintas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/grpc/grpc/labels/cla:%20yes","name":"cla: yes","color":"009800"},{"url":"https://api.github.com/repos/grpc/grpc/labels/core","name":"core","color":"006b75"},{"url":"https://api.github.com/repos/grpc/grpc/labels/DO%20NOT%20MERGE","name":"DO NOT MERGE","color":"e11d21"},{"url":"https://api.github.com/repos/grpc/grpc/labels/performance","name":"performance","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"ctiller","id":10120821,"avatar_url":"https://avatars.githubusercontent.com/u/10120821?v=3","gravatar_id":"","url":"https://api.github.com/users/ctiller","html_url":"https://github.com/ctiller","followers_url":"https://api.github.com/users/ctiller/followers","following_url":"https://api.github.com/users/ctiller/following{/other_user}","gists_url":"https://api.github.com/users/ctiller/gists{/gist_id}","starred_url":"https://api.github.com/users/ctiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ctiller/subscriptions","organizations_url":"https://api.github.com/users/ctiller/orgs","repos_url":"https://api.github.com/users/ctiller/repos","events_url":"https://api.github.com/users/ctiller/events{/privacy}","received_events_url":"https://api.github.com/users/ctiller/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/grpc/grpc/milestones/25","html_url":"https://github.com/grpc/grpc/milestones/Beta","labels_url":"https://api.github.com/repos/grpc/grpc/milestones/25/labels","id":1134869,"number":25,"title":"Beta","description":"","creator":{"login":"ctiller","id":10120821,"avatar_url":"https://avatars.githubusercontent.com/u/10120821?v=3","gravatar_id":"","url":"https://api.github.com/users/ctiller","html_url":"https://github.com/ctiller","followers_url":"https://api.github.com/users/ctiller/followers","following_url":"https://api.github.com/users/ctiller/following{/other_user}","gists_url":"https://api.github.com/users/ctiller/gists{/gist_id}","starred_url":"https://api.github.com/users/ctiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ctiller/subscriptions","organizations_url":"https://api.github.com/users/ctiller/orgs","repos_url":"https://api.github.com/users/ctiller/repos","events_url":"https://api.github.com/users/ctiller/events{/privacy}","received_events_url":"https://api.github.com/users/ctiller/received_events","type":"User","site_admin":false},"open_issues":96,"closed_issues":4,"state":"open","created_at":"2015-05-26T22:29:20Z","updated_at":"2015-05-28T23:52:51Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2015-05-27T07:05:58Z","updated_at":"2015-05-29T00:05:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/grpc/grpc/pulls/1758","html_url":"https://github.com/grpc/grpc/pull/1758","diff_url":"https://github.com/grpc/grpc/pull/1758.diff","patch_url":"https://github.com/grpc/grpc/pull/1758.patch"},"body":"This is a tentative (see discussion below) pull request for the modification of the way the iomgr deals with callbacks.\r\n\r\nIn particular, the allocation of the callback (now exposed and called grpc_iomgr_cb) is the responsibility of the iomgr user. In some cases, this allows the user to reduce the number of mallocs and/or group them into single chunk.\r\n\r\n**Discussion**: In instances where it isn't possible to anticipate the number of necesary callback allocations,  the callback needs to be allocated \"in situ\" right before passing it over to the iomgr. The release of these allocations is currently performed conditionally inside iomgr (depending on whether the callback has been marked as \"externally managed\"). \r\nThe alternative is to make the deallocation part of the callback itself. However, this introduces a non trivial amount of complexity due to not always having control over the callback function. For instance, fd_posix.c:notify_on creates a callback whose function comes from the outside (closure->cb). In other cases, even when we have access to the callback function, such as credentials.c:on_simulated_token_fetch_done, they'd have to be modified to receive a pointer to its enclosing grpc_iomgr_cb. \r\nBoth these scenarios can be addressed by creating wrapper around callbacks that'd run whichever callback function and then free itself. However, a functionally equivalent approach is have the iomgr conditionally free(), as described.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/grpc/grpc/issues/comments/106634857","html_url":"https://github.com/grpc/grpc/pull/1758#issuecomment-106634857","issue_url":"https://api.github.com/repos/grpc/grpc/issues/1758","id":106634857,"user":{"login":"dgquintas","id":120217,"avatar_url":"https://avatars.githubusercontent.com/u/120217?v=3","gravatar_id":"","url":"https://api.github.com/users/dgquintas","html_url":"https://github.com/dgquintas","followers_url":"https://api.github.com/users/dgquintas/followers","following_url":"https://api.github.com/users/dgquintas/following{/other_user}","gists_url":"https://api.github.com/users/dgquintas/gists{/gist_id}","starred_url":"https://api.github.com/users/dgquintas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgquintas/subscriptions","organizations_url":"https://api.github.com/users/dgquintas/orgs","repos_url":"https://api.github.com/users/dgquintas/repos","events_url":"https://api.github.com/users/dgquintas/events{/privacy}","received_events_url":"https://api.github.com/users/dgquintas/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T00:05:54Z","updated_at":"2015-05-29T00:05:54Z","body":"@nicolasnoble Agreed. Will do once the code changes behind this pull req. crystallize."}}