{"action":"created","issue":{"url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/4157","repository_url":"https://api.github.com/repos/pioneerspacesim/pioneer","labels_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/4157/labels{/name}","comments_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/4157/comments","events_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/4157/events","html_url":"https://github.com/pioneerspacesim/pioneer/issues/4157","id":258399434,"number":4157,"title":"NameGen calls very often","user":{"login":"ColdSpirit0","id":16982207,"avatar_url":"https://avatars2.githubusercontent.com/u/16982207?v=4","gravatar_id":"","url":"https://api.github.com/users/ColdSpirit0","html_url":"https://github.com/ColdSpirit0","followers_url":"https://api.github.com/users/ColdSpirit0/followers","following_url":"https://api.github.com/users/ColdSpirit0/following{/other_user}","gists_url":"https://api.github.com/users/ColdSpirit0/gists{/gist_id}","starred_url":"https://api.github.com/users/ColdSpirit0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ColdSpirit0/subscriptions","organizations_url":"https://api.github.com/users/ColdSpirit0/orgs","repos_url":"https://api.github.com/users/ColdSpirit0/repos","events_url":"https://api.github.com/users/ColdSpirit0/events{/privacy}","received_events_url":"https://api.github.com/users/ColdSpirit0/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-09-18T08:17:20Z","updated_at":"2017-09-18T13:28:26Z","closed_at":"2017-09-18T13:26:18Z","author_association":"CONTRIBUTOR","body":"Two posts from #4134:\r\n---\r\n[First:](https://github.com/pioneerspacesim/pioneer/pull/4134#issuecomment-328246894)\r\nI created a log with command `src/pioneer 2>pioneer.log`, started game on Earth and closed game after that.  When I read the log, I saw many (unuseful?) calls of import. To count relative amount of calls I used command:\r\n``` sh\r\n# command not count calls of import, but count occurences of that module in the log\r\n# real count of calls in 2-6 smaller than in output\r\ngrep -Po '(?<=\\[).*(?=\\])' pioneer.log | sort | uniq -c | sort -nr > parsed.log\r\n```\r\n\r\nI put here top ten of the list:\r\n```\r\n  24307 NameGen\r\n   1035 Event\r\n    402 Engine\r\n    354 Lang\r\n    331 EquipSet\r\n    223 Game\r\n    144 Serializer\r\n    138 Format\r\n    120 ShipDef\r\n    120 Comms\r\n```\r\nNameGen looks very popular =) \r\nDont know what functions requires it, but I think it should be moderated.\r\n\r\nI added pioneer.log and parsed.log to dropbox, also I made a custom style for vim to watch pioneer.log, you can see it all here: [importfix](https://www.dropbox.com/sh/t7aoly2123tmy42/AABVwQh0aNRdab3n5h56fGhFa?dl=0)\r\n\r\n---\r\n[Second:](https://github.com/pioneerspacesim/pioneer/pull/4134#issuecomment-328247614)\r\nI got all callers of NameGen and count it:\r\n```sh\r\ngrep -Po '(?<=\\[NameGen\\]: import started, caller: ).*(?=$)' pioneer.log | sort | uniq -c | sort -nr\r\n```\r\n\r\noutput:\r\n```\r\n   4529 core\r\n    954 modules/Taxi/Taxi.lua\r\n    421 modules/Assassination/Assassination.lua\r\n    169 modules/TradeShips.lua\r\n      1 modules/GoodsTrader/GoodsTrader.lua\r\n      1 modules/BreakdownServicing/BreakdownServicing.lua\r\n      1 libs/Character.lua\r\n```\r\nCore means somewhere in C++ code. Now output shows exact count of `import(\"NameGen\")` calls at loading time + ~5 seconds of game."},"comment":{"url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/comments/330220477","html_url":"https://github.com/pioneerspacesim/pioneer/issues/4157#issuecomment-330220477","issue_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/4157","id":330220477,"user":{"login":"impaktor","id":619390,"avatar_url":"https://avatars1.githubusercontent.com/u/619390?v=4","gravatar_id":"","url":"https://api.github.com/users/impaktor","html_url":"https://github.com/impaktor","followers_url":"https://api.github.com/users/impaktor/followers","following_url":"https://api.github.com/users/impaktor/following{/other_user}","gists_url":"https://api.github.com/users/impaktor/gists{/gist_id}","starred_url":"https://api.github.com/users/impaktor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/impaktor/subscriptions","organizations_url":"https://api.github.com/users/impaktor/orgs","repos_url":"https://api.github.com/users/impaktor/repos","events_url":"https://api.github.com/users/impaktor/events{/privacy}","received_events_url":"https://api.github.com/users/impaktor/received_events","type":"User","site_admin":false},"created_at":"2017-09-18T13:28:26Z","updated_at":"2017-09-18T13:28:26Z","author_association":"OWNER","body":"I assume NameGen is only called upon creating a system, once the BBS have been populated, there's no reason to keep calling NameGen at all, I think.\r\n\r\nAn optimization that could be done, is to only populate the BBS of a station when landing on it, instead of the entire system."}}
{"actor":{"display_login":"impaktor"}}