Maki Posted December 4, 2011 Group: Members Topic Count: 146 Topics Per Day: 0.03 Content Count: 1195 Reputation: 467 Joined: 11/15/11 Last Seen: April 11, 2023 Share Posted December 4, 2011 Ind I find the way this function is used very concerning. it is called on every hit/flee calculation (on every physical damage hit -- except on mob.c but there it doesn't bother anyone), to me, it is the culprit of increased latency on busy WoEs. In battle.c it is called to know how many units are attacking this target, it loops through all units in the map (YES ON EVERY DAMN HIT!) to check if their target is the person being damaged. This topic aims at discussing a replacement for this method. Post if you have any ideas. I just came up with something, let me know what you think: Making it save it's last run and last returned value; to then add a minimum interval between runs, so a target being hit by, say, 10 mobs with high aspd doesn't unnecessarily run this too often. It would use a bit more memory and save a reasonable amount of CPU. What do you think? Quote Link to comment Share on other sites More sharing options...
Maki Posted December 4, 2011 Group: Members Topic Count: 146 Topics Per Day: 0.03 Content Count: 1195 Reputation: 467 Joined: 11/15/11 Last Seen: April 11, 2023 Author Share Posted December 4, 2011 GodLesZ I just came up with something, let me know what you think: It would use a bit more memory and save a reasonable amount of CPU. What do you think? These could be done on many places in eAthena (more memory vs less CPU). Of course, I'm pretty forward to this, but the interval shouldnt bee more than 3 sec to prevent incorrect results in a hudge battle. We could also provide a new directive "MORE_MEM_LESS_CPU" and surround optimisations like this. And, we could add an uchar to each mob instance, increment on unit_attack() and decrement on unit_stop_attack(). This will cost again more memory, but less cpu because no iteration through all mobs on the map would be needed. Quote Link to comment Share on other sites More sharing options...
Maki Posted December 4, 2011 Group: Members Topic Count: 146 Topics Per Day: 0.03 Content Count: 1195 Reputation: 467 Joined: 11/15/11 Last Seen: April 11, 2023 Author Share Posted December 4, 2011 Ind great suggestions, a real-time counter would work much better indeed, also liked your performance directive idea Quote Link to comment Share on other sites More sharing options...
Maki Posted December 4, 2011 Group: Members Topic Count: 146 Topics Per Day: 0.03 Content Count: 1195 Reputation: 467 Joined: 11/15/11 Last Seen: April 11, 2023 Author Share Posted December 4, 2011 GodLesZ Glad to here If you are in the mood, feel free to start the implementation. I had to write a damn software documantation until end of work, so I'm a bit busy for now :S We should add a bug tracker issue for this and ask others for battle tests. I'm not sure if every attack stop points to unit_stop_attack(), so we should test this with different scenarios (simple attack, target dead, dead by status, dead by skills, dead by @command, ect). Quote Link to comment Share on other sites More sharing options...
Maki Posted December 4, 2011 Group: Members Topic Count: 146 Topics Per Day: 0.03 Content Count: 1195 Reputation: 467 Joined: 11/15/11 Last Seen: April 11, 2023 Author Share Posted December 4, 2011 Ind indeed there are quite a few areas that 'frees' the target without reaching unit_stop_attack, we'd need to create a 'release' function to manage the counter Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.