No More Gambling


4 Quality Tier 1 modules now give you a full +100% Quality chance. But also +900% Crafting Cost.

Overhaul
7 months ago
2.0
3.29K
Factorio: Space Age Icon Space Age Mod
Manufacturing

b ✔ Stutter every Second

8 months ago
(updated 8 months ago)

With Mod enabled the Game stutters every Second; without Mod solid 60 UPS 5ms Update top, after enabling mod 55 UPS with 80ms Update Time top.
Used Quality in only two Assemblers, just to try the mod out.

8 months ago

How many assemblers do you have total?

8 months ago

I also have noticed the lag, but chalked it up to that I am on a not-super-powerful macbook atm.
I have likely on the order of about a thousand crafting machines, of which maybe 100 have quality modules. However, this was happening even when only a handful had quality modules installed.

My suspicion is the rescan check that occurs twice a second, here is not inexpensive.

While I am not intimately familiar with the plumbing of the mod, it looks like most of the creation/copy-paste/flip/etc hooks should catch modifications, so maybe the frequency on this could be reduced or configurable?
Additionally, if the intent of this is to perform the initial cost changes on mod install, perhaps that could go into a migration script, and then further module installations or removals would be processed as normal? (or maybe there is not a hook available for module changes on crafting machines, which necessitates the frequent rescans?)

8 months ago

Oh, yeah I wouldn't have expected any performance issues with just a few thousand assemblers. The problem is basically that Factorio doesn't have any events for "modules was inserted into machine", so I have to do the scanning. I guess the slow part is counting the quality modules, but I do not see an obvious way to make that faster. Number of quality modules themselves doesn't matter at all, this mod only modifies the recipes, not the actual crafting.

What I haven't tried yet is only updating a limited amount of machines per frame, that would depend on the results from the find_entities command being persistent across frames.

8 months ago

Perhaps (assuming this is the problem; I know there's speed profiling capabilities in Factorio but not sure how to access them) you could leverage the focused area of player(s), whether in presence or using the remote view, and only scan machines within some range of the current focus? I suppose if someone were using macros or other super-fast input there's a possibility a change could be missed, but that would massively reduce the amount of scanning needed. Kind of similar to the FFF re: combining roboport areas to speed up work orders, you could get bounding boxes of active player focus and simply scan entities found in those regions.

Then maybe once every 10-60 seconds or w/e run a global scan like current for any stragglers. While there is possibility for someone to exploit that gap, ultimately it's a person's experience and if they really want free high-quality items, there are already ways to cheat it in so not sure that's really worth trying to defend against.

Of course, no idea how much work all this would take, guessing probably not insignificant.... >.>

8 months ago

Got home and can confirm, even with an RTX 3080 and an i7-13700, still has the stutter.
The time usage stats show that this mod consistently doubles my game update time. The time usage stats report it adding an average of 3ms per tick, but sometimes as much as 70-80ms), so definitely enough to cause a noticeable stutter/glitch.

It also appears to drop my FPS to about 50-55, so a pretty sizeable hit.

8 months ago

Hmm... weird, I didn't notice any performance impact in my own game on a far less powerful computer. Could it be possible that there is a mod active that uses a similar technique and the two mods interfere with each other?

7 months ago

Hmmm very strange, I do not believe any of my other mods affect recipes in this recurring manner. I disabled all mods except this one to test that, but am still seeing the same lag behavior and reduced FPS. The average and max ms for updates were 3ms and 95ms respectively, so for whatever reason, it does seem like my game versions get this behavior exclusively from this mod, for whatever reason....

Very bizarre!

7 months ago
(updated 7 months ago)

Okay I did some throughout performance testing.

What I do now is:
- Scan in a large area around the player camera.
- Scan chunks where entities were placed (for example by bots).
- Scan additional 250 chunks per second, regardless of activity.

It can take quite a long time for some crafting machines to update after a bot inserted a quality module, but only if the player isn't looking and if there is no construction going on nearby.

This improved performance by around 100x.

Honestly I still don't really understand it, because the amount of entities checked shouldn't be reduced by that much, my best guess is that find_entities_filtered is actually extremely slow if you omit the area parameter.

7 months ago

Yep that seems to have resolved it, thanks so much!

New response