The issue
I have a table (in modulescript form) which auto update itself to list survivors, zombies and locally also put these in the correct sub folder: Enemies.
Later I use a localscript to simply list the content of these lists:
Results
After playing 1 round, we all return to menu. No targets are listed anymore, yet running this simple code above will cause extreme lag spikes:
As you can see the table is empty, yet printing such a simple thing is apparently an extreme endevour for roblox. I tried deleting the script that prints this table, then the lagspikes disappear. So I’m confident it’s this simple script causing these lag spikes.
What could I be doing wrong? It’s not like other scripts could hog access to the table right?
Have you inspected the microprofiler by pausing it Ctrl+P? Are you willing to make a microprofiler dump using the Dump item at the top and upload it somewhere like Google Drive so that we can inspect it? I don’t know what dump size would be best, so choose however many frames you think will contain the bug in the output.
One reason I want to see the microprofiler is because lag from printing has previously and recently been caused by SettingsHub, which is a Roblox Core Script which handles the developer console. This will showin the microprofiler. The microprofiler can tell you what script the lag is coming from and possibly what operation in particular causes it, too.
Whoops, sorry. I forgot that where dumps are placed isn’t very clear.
Microprofiler dumps are placed in C:\Users\Your User Here and named something like microprofile-20180517-001100.html. You can upload those to a site like Google Drive and others can download and look at it in their browser.
When you call print, the developer console renders a new text label, that can cause lag if at extreme conditions, even if you hid it, but you can tweak that on the filter settings. Honestly, to be sure it won’t affect performance, the logs generated after playing the game can help, they are found on:
The lag should go away if you don’t print at all.
I think this is caused because the developer console probably sets the text of every TextLabel in order to shift the text up one line each time. Then it checks the TextBounds for something – probably to manually wrap the text if it needs to. Then it sets the Size, Position, TextWrapped, and TextColor. I could be wrong about this though – I haven’t inspected the source of the developer console.
By not opening the developer console, these lag spikes shouldn’t happen. PlaceRebuilder can access the logs in that folder to see them without opening the developer console.
This might be sufficient if PlaceRebuilder can find a way to watch the changes to the file in real time. I’m not sure what tools support this, but I’m sure they exist.
It’s from my main script, why does it have long WaitUntilCompleted bars?
They have it on other frames by these one stretches to end of frame every time, why?
I think the dump you provided was too small to capture what you’re talking about in this instance.
I’m not sure what WaitUntilCompleted or Present do, but I know it’s related to rendering. I think it might be described in Roblox’s microprofiler tutorial videos, or some staff might have commented about it before.
This reply seems to describe what’s going on here well.
Results of course won’t be the same every frame. You have to render and compute different things on each frame. It looks like maybe your GPU usage went up due to the explosion particles during those frames so you saw a longer Present than in other frames. Not 100% sure though.
What do you mean by “It’s from my main script”? The microprofiler does not show the WaitUntilCompleted, Present, or Perform as directly related to any script as far as I can see – it’s just part of the general workload. (Unless WaitUntilCompleted is a custom label)