{"action":"closed","issue":{"url":"https://api.github.com/repos/mgravell/protobuf-net/issues/377","repository_url":"https://api.github.com/repos/mgravell/protobuf-net","labels_url":"https://api.github.com/repos/mgravell/protobuf-net/issues/377/labels{/name}","comments_url":"https://api.github.com/repos/mgravell/protobuf-net/issues/377/comments","events_url":"https://api.github.com/repos/mgravell/protobuf-net/issues/377/events","html_url":"https://github.com/mgravell/protobuf-net/issues/377","id":314117067,"node_id":"MDU6SXNzdWUzMTQxMTcwNjc=","number":377,"title":"Avoid MetaType lookup overhead","user":{"login":"szehetner","id":32911487,"node_id":"MDQ6VXNlcjMyOTExNDg3","avatar_url":"https://avatars0.githubusercontent.com/u/32911487?v=4","gravatar_id":"","url":"https://api.github.com/users/szehetner","html_url":"https://github.com/szehetner","followers_url":"https://api.github.com/users/szehetner/followers","following_url":"https://api.github.com/users/szehetner/following{/other_user}","gists_url":"https://api.github.com/users/szehetner/gists{/gist_id}","starred_url":"https://api.github.com/users/szehetner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szehetner/subscriptions","organizations_url":"https://api.github.com/users/szehetner/orgs","repos_url":"https://api.github.com/users/szehetner/repos","events_url":"https://api.github.com/users/szehetner/events{/privacy}","received_events_url":"https://api.github.com/users/szehetner/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-13T13:55:59Z","updated_at":"2018-06-10T23:31:25Z","closed_at":"2018-06-10T23:31:24Z","author_association":"CONTRIBUTOR","body":"While profiling my system I found that a large part of the total serialization/deserialization time is spent in the TypeModel.GetKey method. Ranging from ~10% for larger types up to ~40% for smaller types. The reason for that is that I have a few hundred different types in the default RuntimeModel and GetKey does a linear search in BasicList to find the right MetaType.\r\n\r\nRight now I'm using a workaround to create (and cache) a new RuntimeModel per type (for a few known types at least), which then has a short type list and fast lookup, but this doesn't feel like the right approach. Ideally there would be a way to avoid that MetaType lookup altogether.\r\n\r\nI know I can get the MetaType via RuntimeTypeModel.Add, but I couldn't find a way to invoke the serializer with that MetaType directly (like e.g. RuntimeTypeModel.Serialize does it), as all the relevant methods are internal. I know all types upfront after startup, so I could map Type->MetaType myself (e.g. in a simple dictionary or just store the MetaType instances wherever the serializer is called).\r\n\r\nIs there a way to do this currently? Or would anything speak against just adding a few public Serialize/Deserialize methods on MetaType directly?"}}
{"actor":{"display_login":"mgravell"}}