Jump to content

unit_counttargeted


Maki

Recommended Posts


  • Group:  Members
  • Topic Count:  146
  • Topics Per Day:  0.03
  • Content Count:  1195
  • Reputation:   467
  • Joined:  11/15/11
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  146
  • Topics Per Day:  0.03
  • Content Count:  1195
  • Reputation:   467
  • Joined:  11/15/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  146
  • Topics Per Day:  0.03
  • Content Count:  1195
  • Reputation:   467
  • Joined:  11/15/11
  • Last Seen:  

Ind

great suggestions, a real-time counter would work much better indeed, also liked your performance directive idea

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  146
  • Topics Per Day:  0.03
  • Content Count:  1195
  • Reputation:   467
  • Joined:  11/15/11
  • Last Seen:  

GodLesZ

Glad to here smile.png

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).

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  146
  • Topics Per Day:  0.03
  • Content Count:  1195
  • Reputation:   467
  • Joined:  11/15/11
  • Last Seen:  

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...