No Laggy Bed

Mod, 1.3, 1.4


(1.3) Fix the fps drop when you select a bed or workbench.
(1.3 Optional) Fix the fps drop when you open the Needs Tab of a pawn.
(1.4) Optimize Thoughts rendering in the Needs Tab of a pawn.

Important Notes for 1.4:Is it still needed in 1.4? I did some tests with the performance analyzer. (Bless Dubwise.)

TL;DR: In 1.4, Devs have fixed the culpirts of laggy beds and most of th...

Розробник: telardo

Дата створення: 6 Apr, 2022 @ 6:03am

Оновлено: 23 Oct, 2022 @ 5:20pm

Підписників: 60703


Розмір (розпакований) : 0.055 MB

(1.3) Fix the fps drop when you select a bed or workbench.
(1.3 Optional) Fix the fps drop when you open the Needs Tab of a pawn.
(1.4) Optimize Thoughts rendering in the Needs Tab of a pawn.

Important Notes for 1.4:
Is it still needed in 1.4? I did some tests with the performance analyzer. (Bless Dubwise.)

TL;DR: In 1.4, Devs have fixed the culpirts of laggy beds and most of the Needs Tab's. You can get a modicum of performance gain from Needs Tab with this mod in 1.4.

Long, boring technical facts are listed as follows.
For the part of beds, Devs use cached Designators in BuildCopyCommandUtility.FindAllowedDesignator() after resolving them once. They actually should do it that way long before, but it's a good fix.

For the part of Needs Tab, some people might have noticed, in the mod setting of this mod back in 1.3, there is a default-false option called "Optimize the Needs Tab". It's my effort addressing unoptimized thoughts rendering in that tab. Surprisingly (Maybe), devs also tried to fix this issue in 1.4. They use a cached mood offset of groups in PawnNeedsUIUtility.GetThoughtGroupsInDisplayOrder(), which is the main culprit here. However, there is still unneccessary computations in NeedsCardUtility.DrawThoughtGroup(), which calls ThoughtHandler.GetMoodThoughts() and ThoughtHandler.MoodOffsetOfGroup(). (TBH, if I were part of the devs, I may rewrite the ThoughtHandler from ground up. It's terrible.) That's what this mod trying to fix in 1.4. From my tests, that rendering method can be boosted from average 1.5ms to 1ms on a test pawn. Unsurpringly, it's not quite a visible boost compared with 1.3.

Story ends. Perhaps I should call it "No laggy Needs" in 1.4, LOL. It's a mixed feeling where sometimes you feel your effort is in vain, but at some moments, you feel good as if every game players becomes your subscribers. Anyway, embrace the change~ Thank you for the long journey with this mod and good luck.


Details:
Some players (usually heavy-modded) experience this fps issue in their game when selecting a bed or workbench. I wish this mod fixed it.
I also add an experimental fix for fps drop when opening the Needs Tab. You can activate it in mod setting page.

FAQ:
  1. Can be safely added to or removed from your current save.
  2. I suppose there are no compatibility issues. Contact me if you find one.

As usual, I don't need donations. You can rate my mods to support me~

Technical Details:

If you're not curious about where it comes from, stop here.
Long story short: this is a vanilla problem; more mods exacerbate it.

When you select a bed or a workbench, the game will try to find available linkable facilities like dressers and show them. BuildCopyCommandUtility.FindAllowedDesignator() scans all the designators in the database every frame to find a single build command. Typically, a game with a medium-size mod list contains thousands of designators. Hence, the game needs to validate millions of designators in 60 frames for a bed with 10ish linkables. The same case applies to workbenches. That's the main reason why selecting them slows down your game drastically. The situation worsens with more modded buildable things. For example, VE furniture series add tons of buildable things in the game. In this mod, I build copies for needed designators and cache them to avoid scanning.

Some people claim the mod SRTS Expanded is also the culprit. To some extent, they're right. SRTS has a harmony patch for research projects, which costs 0.005ms per call. It's not bad itself but calling it 10k times per frame is. To avoid this, I also add caching for Designator_Build.Visible. It eliminates calling that method as much as possible, and it's not a problem now. This caching should also speed up general gizmo drawing.

At last, I also replace GetRoom() in Building_Bed.DrawExtraSelectionOverlays() with a cached version. It's a small lift without getting them every frame.

No free lunch! So what's the price? Like other performance optimizers, it needs a little more memory to store the cache. It's not a big deal from my testing. Of course, there might be other impacts I didn't notice; if you find something, feel free to let me know.

Above is all my understandings of this problem. Please don't quote me on that~

Як завантажити моди?

Натисніть на кнопку вище та завантажте обраний мод з файлового сховища.

Як встановити мод?

Див. секцію "Як встановити".

Чи безпечний завантажуваний файл?

Моди перезаливаються нами з оригінального джерела, без жодних змін. Ми лише запаковуємо їх в звичайний архів. Додатково можете перевірити архів на наявність загроз за допомогою будь-якого антивірусу або онлайн-сканеру на кшталт virustotal.com. Також рекомендуємо робити резервні копії ваших сейвів, про всяк випадок.

There is a folder in the .zip archive. To install the mod, move the entire folder (not just its contents) into 'Mods' folder located under your RimWorld root isntallation folder.
So, for steam version of the game, the path would look like this: C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods
For any other distribution, firstly locate your rimworld installation path and then unpack the archive into the 'Mods' folder.
Then enable the mod in the game mods menu by double clicking on its name and restart the game