ID:2564169
 
Resolved
The way that objects were checked for available verbs when right-clicking the map was inefficient, resulting in long delays for context menus to appear in some cases, and even longer delays if client verbs were made known to the client and then removed. The parser has been upgraded to handle this situation better, drastically cutting down the delay.
BYOND Version:513
Operating System:Windows 10 Pro
Web Browser:Firefox 75.0
Applies to:Dream Seeker
Status: Resolved (513.1521)

This issue has been resolved.
Descriptive Problem Summary:
Essentially, if there's verbs you don't have access to, your right click lag increases.

This is especially applicable in SS13, where server administrators have many verbs for doing various commands that normal users do not have.

Myself and mybluecorners, who worked on this, think that even just having these verbs exist contributes to right click lag, but this test case only proves that having them removed contributes.

This might or might not impact fps as well, we perceived a fps increase in testing but it could be a fluke.

Old thread, where you asked for a test case:
http://www.byond.com/forum/post/1326139

Numbered Steps to Reproduce Problem:
Obtain a bunch of verbs, and then remove them from yourself.

Expected Results:
No discernible difference.

Actual Results:
Much increased time, scaling with the amount of verbs.

Does the problem occur:
Every time? Or how often? every time
In other games? likely
In other user accounts? yes
On other computers? yes

When does the problem NOT occur?
When the verbs never existed in the first place

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked?
This has occurred since at least 2014, re: the thread above.

Workarounds:
Removing every removable verb and replacing them with menus of procs brought up on certain keypresses.

Test Case:
https://drive.google.com/ open?id=1sz6BvZCg0sjvnJSwg4MTLjKIPuTGPj2a
OR
https://mega.nz/file/ YqY2nKKK#ytnyLTYr6ImYLx3qjz--LyrHHB4IoVjgMKmkttsxRVU
OR
https://www.mediafire.com/file/sheloqxriydy8f1/ rightclickstuff.zip/file

To use:
1. Right click in the world as normal, notice the amount of time.
2. Toggle your verbs using the 'Toggle Verbs' verb.
3. Right click again in the world, notice it takes much more time.
4. Feel free to toggle back and forth to see the difference.
Lummox JR resolved issue with message:
The way that objects were checked for available verbs when right-clicking the map was inefficient, resulting in long delays for context menus to appear in some cases, and even longer delays if client verbs were made known to the client and then removed. The parser has been upgraded to handle this situation better, drastically cutting down the delay.
Thanks for providing such a clean test case. It made this bug a lot easier to understand and see in action, so I was able to use that to find a fix.

Effectively what was happening here was that because you had client verbs with a single "atom in world" argument, once the verbs were known to the client but subsequently removed, the parser (which is used to handle populating right-click menus) was put in a state where it knew the verb existed but had to figure out if any objects could be used as src—which meant looping through all objects known to the client. And it did this for every verb, and for every item on that square of the map where you right-clicked, for O(NVW) performance where N is the number of atoms on that tile, V is the number of removed verbs, W is the number of atoms in the world.

My fix for this was to change the routines that let up to this search-the-world point, since at that point we'd only be checking a single atom against a single verb. So I turned the O(NVW) performance into O(NV) performance, which is way better since W was always the biggest of those numbers.