{"action":"created","issue":{"url":"https://api.github.com/repos/evennia/evennia/issues/620","labels_url":"https://api.github.com/repos/evennia/evennia/issues/620/labels{/name}","comments_url":"https://api.github.com/repos/evennia/evennia/issues/620/comments","events_url":"https://api.github.com/repos/evennia/evennia/issues/620/events","html_url":"https://github.com/evennia/evennia/issues/620","id":49867907,"number":620,"title":"Profiling performance","user":{"login":"luyijun","id":7847144,"avatar_url":"https://avatars.githubusercontent.com/u/7847144?v=3","gravatar_id":"","url":"https://api.github.com/users/luyijun","html_url":"https://github.com/luyijun","followers_url":"https://api.github.com/users/luyijun/followers","following_url":"https://api.github.com/users/luyijun/following{/other_user}","gists_url":"https://api.github.com/users/luyijun/gists{/gist_id}","starred_url":"https://api.github.com/users/luyijun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luyijun/subscriptions","organizations_url":"https://api.github.com/users/luyijun/orgs","repos_url":"https://api.github.com/users/luyijun/repos","events_url":"https://api.github.com/users/luyijun/events{/privacy}","received_events_url":"https://api.github.com/users/luyijun/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":33,"created_at":"2014-11-24T08:59:10Z","updated_at":"2015-02-25T16:57:43Z","closed_at":null,"body":"When I use evennia, I feel it's not fast enough. So I did some tests and profiled the performance. In one test, I put in 50 bots, let them connect in (It took nearly 20 seconds. They have been created before, so in this test they just connected in.) and then did \"look\" every 2 seconds on average for nearly 4 minutes. They did nothing else. The cpu usage was about 45%. (In another test, I put in 100 bots and the cpu usage raised to nearly 100%)\r\n\r\nFinally the cProfile gave me a report. It says there were 69771477 function calls (69178981 primitive calls) in 223.856 seconds, and these are first 4 functions that took most time.\r\n\r\n    ncalls    tottime   percall cumtime percall filename:lineno(function)\r\n    763       110.182   0.144   110.19  0.144   {select.select}\r\n    55716     5.563     0       24.365  0       {method 'fetchmany' of 'sqlite3.Cursor' objects}\r\n    520160    5.294     0       14.907  0       dateparse.py:61(parse_datetime)\r\n    4161280   5.249     0       5.249   0       dateparse.py:84(<genexpr>)\r\n\r\nI am surprised that the \"select\" took nearly 50% of time. It seems that the database or cache doesn't work well. Are there any issues?\r\n\r\nI ran these tests on my local machine which is a mac mini with 2.5G core i5 cpu and 16G memory."},"comment":{"url":"https://api.github.com/repos/evennia/evennia/issues/comments/76001325","html_url":"https://github.com/evennia/evennia/issues/620#issuecomment-76001325","issue_url":"https://api.github.com/repos/evennia/evennia/issues/620","id":76001325,"user":{"login":"luyijun","id":7847144,"avatar_url":"https://avatars.githubusercontent.com/u/7847144?v=3","gravatar_id":"","url":"https://api.github.com/users/luyijun","html_url":"https://github.com/luyijun","followers_url":"https://api.github.com/users/luyijun/followers","following_url":"https://api.github.com/users/luyijun/following{/other_user}","gists_url":"https://api.github.com/users/luyijun/gists{/gist_id}","starred_url":"https://api.github.com/users/luyijun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luyijun/subscriptions","organizations_url":"https://api.github.com/users/luyijun/orgs","repos_url":"https://api.github.com/users/luyijun/repos","events_url":"https://api.github.com/users/luyijun/events{/privacy}","received_events_url":"https://api.github.com/users/luyijun/received_events","type":"User","site_admin":false},"created_at":"2015-02-25T16:57:43Z","updated_at":"2015-02-25T16:57:43Z","body":"Thank you!\r\n\r\nI made some tests and found something: If there are lots of characters in the same room, the server will be very busy. When a character calls a command, the command handler needs to get all cmdsets of all objects in the same location to merge its cmdset. So if there are many objects in the same location, the command handler needs do a lot of works.\r\n\r\nHere are two of my tests:\r\n\r\nI made a new command which just passes and does nothing at all. When I used c_login_nodig in ACTIONS, the cpu usage of the server was very high, but when I used c_login, the cpu usage of the server was very low. The main difference between c_login_nodig and c_login is the number of characters in same locations.\r\n\r\nI have some ideas which may help to solve this problem.\r\n\r\nWe can classify objects' cmdset into different cmdset types. Each cmdset type has its own cmdset, and the command handler merges objects' cmdsets according to their cmdset types. If all objects in the same location are of the same cmdset type, the command handler only needs to merge one cmdset. \r\n\r\nAnd we can merged cmdset of all objects in the same location and put it on the location. When an object enters or leaves or changes its cmdset, the cmdset of the location needs update. When someone calls a command, the command handler only needs to merge the cmdset of the location."}}