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

Refactors parallax subsystem #10924

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

EvilDragonfiend
Copy link
Contributor

@EvilDragonfiend EvilDragonfiend commented Apr 28, 2024

About The Pull Request

Refactors parallax subsystem

Unless I didn't read the profile wrong, it is 200% efficient than old parallax code.

What's different?

  • Parallax code has been using screen_loc and changing it directly
  • screen_loc has two issues:
    • it will not render an image when a thing is away from your screen
    • calculating the offset values has been done quite manually, and has been taking it as a raw text
  • view_o() proc was called everytime, and this proc resets all parallax appearance and re-adds what it was already.
    • changing your view size makes glitch because parallax image amount is based on your view size
    • Initialize() is enough to handle this
  • Parallax is now based on using transform = matrix() to change its location, and screen_loc = "CENTER-7,CENTER-7" will never be changed

Effectiveness

  • CPU use efficiency is 200% better
  • animating is much smoother than before

NOTE

I have no data on how efficient this is on live servers, so I removed some frozen parallax code. I should change that later with gethered data.

Why It's Good For The Game

Bacon has been blaming it, and I figured it was actually awfully coded.

Testing Photographs and Procedure

https://www.youtube.com/watch?v=QhK7EflY1do&ab_channel=EvilDragon

Changelog

🆑
code: improved parallax code
/:cl:

@@ -1,34 +1,47 @@
SUBSYSTEM_DEF(parallax)
name = "Parallax"
wait = 2
wait = 1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's even faster with wait = 1

Copy link
Member

Choose a reason for hiding this comment

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

It also will get called 2x as frequently, although since its an SS_BACKGROUND system this will result in an increased CPU usage only when there is enough time to spare anyway. The idea for making it wait = 2 was that the slight delay is barely noticable at slow speeds

@EvilDragonfiend EvilDragonfiend added Needs Testmerge Test Merged This PR is currently in rotation labels Apr 28, 2024
@EvilDragonfiend
Copy link
Contributor Author

Going to test this for a round. I will see how this is different.

@PowerfulBacon
Copy link
Member

Include what you actually did to improve the performance and the methodology behind it, reviewers need to be able to go in and immediately know what you are trying to do rather than be forced to read 500 lines to figure out the intentions

@EvilDragonfiend
Copy link
Contributor Author

Include what you actually did to improve the performance and the methodology behind it, reviewers need to be able to go in and immediately know what you are trying to do rather than be forced to read 500 lines to figure out the intentions

I kinda forgot it. Addressed now.

@EvilDragonfiend EvilDragonfiend removed the Test Merged This PR is currently in rotation label Apr 28, 2024
@EvilDragonfiend
Copy link
Contributor Author

Round 48473, currently on.

@@ -1,34 +1,47 @@
SUBSYSTEM_DEF(parallax)
name = "Parallax"
wait = 2
wait = 1
Copy link
Member

Choose a reason for hiding this comment

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

It also will get called 2x as frequently, although since its an SS_BACKGROUND system this will result in an increased CPU usage only when there is enough time to spare anyway. The idea for making it wait = 2 was that the slight delay is barely noticable at slow speeds

Comment on lines +66 to +70
wait = initial(wait)
if(throttle_ghost_pop && length(GLOB.clients) >= throttle_ghost_pop)
wait++
if(throttle_all_pop && length(GLOB.clients) >= throttle_all_pop)
wait *= 2
Copy link
Member

Choose a reason for hiding this comment

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

The throttling was probably the most important part of the entire subsystem, the lag mitigation from the enumeration is great, but at high-pops a good majority of the time was spent processing the parallax for ghosts. Ghosts are extremely problematic at high pop because they are extremely fast and extremely plentiful. They cause everyones parallax to get lag mitigated. You really, really, should not delete the freezing of parallax layers for ghosts at high-pop since it will just bring back parallax's running slowly for humans at higher population limits.

@EvilDragonfiend EvilDragonfiend marked this pull request as draft May 2, 2024 12:41
@EvilDragonfiend EvilDragonfiend marked this pull request as ready for review May 5, 2024 08:24
@EvilDragonfiend
Copy link
Contributor Author

Tiny clean up left

  • Reviving parallax freeze()
  • Fixing some comment
  • FIxing some PR content

I didn't check CPU usage correctly yet.

@EvilDragonfiend
Copy link
Contributor Author

Single testing on round 48561, pop +20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants