{"action":"opened","issue":{"url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1537","labels_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1537/labels{/name}","comments_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1537/comments","events_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1537/events","html_url":"https://github.com/akkadotnet/akka.net/issues/1537","id":121908502,"number":1537,"title":"Akka.Remote performance - ActorPath.TryParse","user":{"login":"rogeralsing","id":647031,"avatar_url":"https://avatars.githubusercontent.com/u/647031?v=3","gravatar_id":"","url":"https://api.github.com/users/rogeralsing","html_url":"https://github.com/rogeralsing","followers_url":"https://api.github.com/users/rogeralsing/followers","following_url":"https://api.github.com/users/rogeralsing/following{/other_user}","gists_url":"https://api.github.com/users/rogeralsing/gists{/gist_id}","starred_url":"https://api.github.com/users/rogeralsing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogeralsing/subscriptions","organizations_url":"https://api.github.com/users/rogeralsing/orgs","repos_url":"https://api.github.com/users/rogeralsing/repos","events_url":"https://api.github.com/users/rogeralsing/events{/privacy}","received_events_url":"https://api.github.com/users/rogeralsing/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/akkadotnet/akka.net/labels/akka-actor","name":"akka-actor","color":"c7def8"},{"url":"https://api.github.com/repos/akkadotnet/akka.net/labels/akka-remote","name":"akka-remote","color":"c7def8"},{"url":"https://api.github.com/repos/akkadotnet/akka.net/labels/enhancement","name":"enhancement","color":"207de5"},{"url":"https://api.github.com/repos/akkadotnet/akka.net/labels/up%20for%20grabs","name":"up for grabs","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-13T08:57:49Z","updated_at":"2015-12-13T08:57:49Z","closed_at":null,"body":"After investigating the performance in Akka.Remote, We have found a few big hogs.\r\n\r\nOne of them is `ActorPath.TryParse` this is called multiple times for each remote message sent.\r\nFirst to resolve what actor to talk to, and then to resolve who is the sender. and then possibly for other `ActorRefs` contained in the message sent.\r\n\r\nWe use `Uri.TryCreate` which is far too expensive for this.\r\n\r\nSo we have three options here.\r\n\r\n**Cache all ActorPaths:**\r\nI do this in my experimental branch, this gives huge performance gains.\r\nBUT, there is a risk of the static cache growing with thousands or millions of ActorPaths eventually if the system lives for a long time..\r\n\r\n**Create a faster parser:**\r\nJVM Akka does not use URI at all for parsing, this was introduced by me very early on, just for being lazy.\r\nWe can probably do a better custom parser as ActorPaths wil not contain all the special stuff found in real URI's.\r\n\r\n**A combination of the two above:**\r\nWe can possibly cache on address only, e.g. if we can substring the address part of a path really fast and use that as a key, then we could cache the address alone. and then take the reminder of the string and create the actor path from that.\r\n\r\nWhatever option we go for needs to be extensively performance tested. \r\n\r\n"}}