Accessing empty table causes 100% lag spike?!

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:


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.

1 Like

Clicking any of these doesn’t do anything?

It’s settingshub but more than that I cant see.

Seems like it’s trying to translate, i’ll upload the whole file in a sec.

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.

1 Like

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:


You can then sort them by Date modified.

Here’s the file:

@FieryEvent 10 printed lines is not a valid reason for lag.

Yep. This is caused by SettingsHub aka the developer console.

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.

Doing that hundreds of times is – apparently – really bad for performance.

1 Like

It’s 4am here and I gotta get my update done today…

Now you’re telling me I gotta write my own dev. console because roblox can’t even do that?!

Appriciate your help tho, I’ll see if removing all prints will solve this.

These logs I mentioned include prints called from the developer.

This can be somewhat useful.

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.

1 Like

To watch the changes to the file in real time, I found that could be done in powershell:

  1. On the current folder, press shift and right click, then select “Open PowerShell window here”
  2. Paste the command:
Get-Content .\log_XXXXX_X.txt –Wait
1 Like

Cool! But I’ll write my own console system instead as I’ve done with basically everything by now.

One last question, when I experienced a nearby explosion I got this result:

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?

Here’s full dump:

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. :woman_shrugging:

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)

1 Like

Alright, I guess the lag was graphics related then and that the WaitUntilCompleted had to do with waiting for next frame.

My main script is a cluster of modules that’s all run under a customlabel “Main”. These WaitUntilCompleted are under that label.