{"action":"created","issue":{"url":"https://api.github.com/repos/xamarin/xamarin-macios/issues/5025","repository_url":"https://api.github.com/repos/xamarin/xamarin-macios","labels_url":"https://api.github.com/repos/xamarin/xamarin-macios/issues/5025/labels{/name}","comments_url":"https://api.github.com/repos/xamarin/xamarin-macios/issues/5025/comments","events_url":"https://api.github.com/repos/xamarin/xamarin-macios/issues/5025/events","html_url":"https://github.com/xamarin/xamarin-macios/issues/5025","id":372544586,"node_id":"MDU6SXNzdWUzNzI1NDQ1ODY=","number":5025,"title":"[RFC] Improve instance creation performance by generating a factory class to create objects","user":{"login":"rolfbjarne","id":249268,"node_id":"MDQ6VXNlcjI0OTI2OA==","avatar_url":"https://avatars0.githubusercontent.com/u/249268?v=4","gravatar_id":"","url":"https://api.github.com/users/rolfbjarne","html_url":"https://github.com/rolfbjarne","followers_url":"https://api.github.com/users/rolfbjarne/followers","following_url":"https://api.github.com/users/rolfbjarne/following{/other_user}","gists_url":"https://api.github.com/users/rolfbjarne/gists{/gist_id}","starred_url":"https://api.github.com/users/rolfbjarne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rolfbjarne/subscriptions","organizations_url":"https://api.github.com/users/rolfbjarne/orgs","repos_url":"https://api.github.com/users/rolfbjarne/repos","events_url":"https://api.github.com/users/rolfbjarne/events{/privacy}","received_events_url":"https://api.github.com/users/rolfbjarne/received_events","type":"User","site_admin":false},"labels":[{"id":361456714,"node_id":"MDU6TGFiZWwzNjE0NTY3MTQ=","url":"https://api.github.com/repos/xamarin/xamarin-macios/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":770328998,"node_id":"MDU6TGFiZWw3NzAzMjg5OTg=","url":"https://api.github.com/repos/xamarin/xamarin-macios/labels/iOS","name":"iOS","color":"edd60e","default":false},{"id":770328881,"node_id":"MDU6TGFiZWw3NzAzMjg4ODE=","url":"https://api.github.com/repos/xamarin/xamarin-macios/labels/macOS","name":"macOS","color":"edd60e","default":false},{"id":1099971643,"node_id":"MDU6TGFiZWwxMDk5OTcxNjQz","url":"https://api.github.com/repos/xamarin/xamarin-macios/labels/performance","name":"performance","color":"c6c2f9","default":false},{"id":845037938,"node_id":"MDU6TGFiZWw4NDUwMzc5Mzg=","url":"https://api.github.com/repos/xamarin/xamarin-macios/labels/request-for-comments","name":"request-for-comments","color":"053efc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/xamarin/xamarin-macios/milestones/9","html_url":"https://github.com/xamarin/xamarin-macios/milestone/9","labels_url":"https://api.github.com/repos/xamarin/xamarin-macios/milestones/9/labels","id":2969797,"node_id":"MDk6TWlsZXN0b25lMjk2OTc5Nw==","number":9,"title":"Future","description":"Reviewed but not assigned to a specific milestone","creator":{"login":"spouliot","id":260465,"node_id":"MDQ6VXNlcjI2MDQ2NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/260465?v=4","gravatar_id":"","url":"https://api.github.com/users/spouliot","html_url":"https://github.com/spouliot","followers_url":"https://api.github.com/users/spouliot/followers","following_url":"https://api.github.com/users/spouliot/following{/other_user}","gists_url":"https://api.github.com/users/spouliot/gists{/gist_id}","starred_url":"https://api.github.com/users/spouliot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spouliot/subscriptions","organizations_url":"https://api.github.com/users/spouliot/orgs","repos_url":"https://api.github.com/users/spouliot/repos","events_url":"https://api.github.com/users/spouliot/events{/privacy}","received_events_url":"https://api.github.com/users/spouliot/received_events","type":"User","site_admin":false},"open_issues":160,"closed_issues":259,"state":"open","created_at":"2017-12-10T22:47:28Z","updated_at":"2018-10-22T14:27:55Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2018-10-22T14:27:54Z","updated_at":"2018-10-22T18:01:57Z","closed_at":null,"author_association":"MEMBER","body":"### Problem\r\n\r\nUsing reflection is slow, and we use reflection to create instances of NSObject (and their subclasses):\r\n\r\nhttps://github.com/xamarin/xamarin-macios/blob/d899d4fb707738fec5706d7e88351713b744c87a/src/ObjCRuntime/Runtime.cs#L1145\r\n\r\n### Suggestion\r\n\r\nGenerate factory class that implements a particular interface, and then we can call a method on that interface to create the instance we need instead of using reflection.\r\n\r\nI've implemented a proof-of-concept (with performance numbers) here: https://github.com/rolfbjarne/xamarin-macios/commit/c6c9e2a8ba2fe5ae8ca8b38027c84b902473fa7b (the POC manually implements the factory class for a single class to make things simple).\r\n\r\nPro: object creation becomes ~40% faster.\r\nCon: a lot of extra generated code.\r\n\r\n---\r\n\r\nMy current opinion is that we currently don't know if the slow object creation is enough of a problem to warrant this fix."},"comment":{"url":"https://api.github.com/repos/xamarin/xamarin-macios/issues/comments/431917193","html_url":"https://github.com/xamarin/xamarin-macios/issues/5025#issuecomment-431917193","issue_url":"https://api.github.com/repos/xamarin/xamarin-macios/issues/5025","id":431917193,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMTkxNzE5Mw==","user":{"login":"spouliot","id":260465,"node_id":"MDQ6VXNlcjI2MDQ2NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/260465?v=4","gravatar_id":"","url":"https://api.github.com/users/spouliot","html_url":"https://github.com/spouliot","followers_url":"https://api.github.com/users/spouliot/followers","following_url":"https://api.github.com/users/spouliot/following{/other_user}","gists_url":"https://api.github.com/users/spouliot/gists{/gist_id}","starred_url":"https://api.github.com/users/spouliot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spouliot/subscriptions","organizations_url":"https://api.github.com/users/spouliot/orgs","repos_url":"https://api.github.com/users/spouliot/repos","events_url":"https://api.github.com/users/spouliot/events{/privacy}","received_events_url":"https://api.github.com/users/spouliot/received_events","type":"User","site_admin":false},"created_at":"2018-10-22T18:01:57Z","updated_at":"2018-10-22T18:01:57Z","author_association":"CONTRIBUTOR","body":"> I considered this...\r\n\r\nYeah, I was pretty sure of it :-)\r\n\r\na) `protected internal` should solve this (at least for the platform assemblies);\r\nb) likely but less reflection is better than more ;-) ;\r\nc) yes, but it makes **Don't link** use the same, faster code (which might become more important depending on how the interpreter will be used);"}}
{"actor":{"display_login":"spouliot"}}