Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vending_products register continue check #4962

Merged

Conversation

Drulikar
Copy link
Contributor

@Drulikar Drulikar commented Nov 19, 2023

About the pull request

This PR cherry picks cmss13-devs/cmss13-pve#68 but removes the extra logging. That PR was attempting to resolve server hitching, but the hitching seems to have gone away with it and a TGS update.

I am not currently able to discern any noticeable differences from this change, however the change looks correct for the continue check to ever work correctly. See Testing Notes below.

Let me know if you do find a change this does improve, or maybe somewhere else we should expect superfluous calls to getFlatIcon.

Explain why it's good for the game

The continue check as written looks like it would never work, whereas now the string that will be used for inserting into the list sprites is the same string we check before creating new icons.

Testing Photographs and Procedure

Testing Notes

Debugging only:

Lobby (LV-624):
One event of registering (master -> init Assets -> vending_products)
55 getFlatIcon calls (.124 total cpu)

Game Start:
No changes

After opening CO vendors and cig vendor:
No changes

Alt+click self:
77 getFlatIcon calls (.353 total cpu)

Alt+click self again:
No changes


After continue change:

Lobby (LV-624):
One event of registering (master -> init Assets -> vending_products)
55 getFlatIcon calls (.117 total cpu)

Game Start:
No changes

After opening CO vendors and cig vendor:
No changes

Alt+click self:
77 getFlatIcon calls (.346 total cpu)

Alt+click self again:
No changes


Debugging only w/ SVN:

Lobby (LV-624):
One event of registering (master -> init Assets -> vending_products)
55 getFlatIcon calls (.124 total cpu)

Game Start:
No changes

After opening CO vendors and cig vendor:
a GET was performed for first CO vendor and first cig vendor opened (never again)

Alt+click self:
77 getFlatIcon calls (.351 total cpu)
A GET is performed for every item listed

Alt+click self again:
A GET is performed for every item listed


After continue change w/ SVN:

Lobby (LV-624):
One event of registering (master -> init Assets -> vending_products)
55 getFlatIcon calls (.120 total cpu)

Game Start:
No changes

After opening CO vendors and cig vendor:
a GET was performed for first CO vendor and first cig vendor opened (never again)

Alt+click self:
77 getFlatIcon calls (.347 total cpu)
A GET is performed for every item listed

Alt+click self again:
A GET is performed for every item listed

Changelog

🆑 Morrow
code: Corrected a check to avoid repeat work in /datum/asset/spritesheet/vending_products/register()
/:cl:

morrowwolf and others added 2 commits November 18, 2023 22:50
(cherry picked from commit b841a7466cb919b6ce57222e9585470dd241f6cb)
@github-actions github-actions bot added the Code Improvement Make the code longer label Nov 19, 2023
@fira
Copy link
Member

fira commented Nov 19, 2023

Is this really needed? If the sprite is regenerated incorrectly it would hit the CRASH() in Insert() at end no?

@Drulikar
Copy link
Contributor Author

Drulikar commented Nov 20, 2023

Is this really needed? If the sprite is regenerated incorrectly it would hit the CRASH() in Insert() at end no?

As I said, I currently cannot replicate a situation where this is applicable. But as written, the existing code checking if (sprites[icon_file]) continue would never work as intended. This PR fixes that.

If you're worried about this suppressing problems I'm happy to add
log_debug("[imgid] has already been registered!") or stack_trace("[imgid] has already been registered!") before the continue.

Merely relying on that super late crash to stop the call is after all the expensive work has already been done is not helpful. Our goal is to prevent superfluous calls to getFlatIcon.

@Drulikar
Copy link
Contributor Author

Places like: https://github.com/cmss13-devs/cmss13/pull/4962/files#diff-870b63bb2fc175b1b768c1bb1fb981a02a8d03ba42f2473de87344d048358100L358-L373 further down in the file are correctly continuing. That same code was copied here but was not corrected to be what actually is the key being inserted.

@Drulikar Drulikar requested a review from fira November 20, 2023 00:57
Copy link
Member

@fira fira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I mean the change makes sense in general, it's just it looks like it's not really going to do anything or we'd get the crash warnings already

Copy link
Contributor

This PR has been inactive for long enough to be automatically marked as stale. This means it is at risk of being auto closed in ~ 7 days, please address any outstanding review items and ensure your PR is finished, if these are all true and you are auto-staled anyway, you need to actively ask maintainers if your PR will be merged. Once you have done any of the previous actions then you should request a maintainer remove the stale label on your PR, to reset the stale timer. If you feel no maintainer will respond in that time, you may wish to close this PR youself, while you seek maintainer comment, as you will then be able to reopen the PR yourself

@github-actions github-actions bot added the Stale beg a maintainer to review your PR label Nov 28, 2023
@Birdtalon Birdtalon added this pull request to the merge queue Dec 1, 2023
Merged via the queue into cmss13-devs:master with commit 0772939 Dec 1, 2023
28 checks passed
cm13-github added a commit that referenced this pull request Dec 1, 2023
@Drulikar Drulikar deleted the Fix_Asset_Register_Continue_Check branch December 1, 2023 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Improvement Make the code longer Stale beg a maintainer to review your PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants