Modules do not appear under Script Activity/Script Performance. Only their parent scripts appear, and, their parent scripts do not include the modules’ activity.
The bug happens in Studio under Script Performance and in live games under the Dev Console’s Script Activity tab.
As far as I know this bug has been happening since at least around 2017 or 2018 or so. I decided to report it now because its existed for some considerable time and I wasn’t able to find any information about it anywhere else.
Steps to reproduce:
Insert a module script which is connected to Heartbeat, and, require it from an outside script. No activity will be shown for it, and, its activity won’t be included in the script that requires it (it shouldn’t anyway since modules can be required from multiple scripts but will only run once).
ModuleScripts should get a Script Activity entry when they are initially required.
I think the script activity is bound to the root script than the module script, considering that modules acts as if they were insertion of code to the root script. It would otherwise be a feature to be added, if script activity should be able to be monitored between the root and its modules.
Module script activity doesn’t show up in the root requiring script. If you require a module and call a function it returns the activity shows up in the caller script, but, if the module connects to an event or starts a thread in its own body this activity won’t ever be tracked, and, this is making it difficult for me to locate which scripts are causing the most lag. It’s really beneficial to me to know which scripts might be causing lag at any given time, because, it helps me narrow down sources I can improve server performance.
Even if module activity did show under the root script’s activity, it absolutely shouldn’t partly because that’d make debugging a nightmare and partly because that’d result in completely arbitrary activities. If I have two scripts that are spawned in an arbitrary order and they both access the module, whichever script which contain its activity would also be arbitrary, and, that’s bad.
Currently none of the code in my game shows up in Script Activity, every script including the start script shows up as having a rate of 0.0/s and 0.000% activity. Quite a few of the modules I require execute their own code, and, this activity seems to just end up completely untracked. Every piece of my game’s code is spawned from that one start script, and, that makes it really frustrating to locate performance issues I accidentally introduce for some reason or another.
Being able to see the activity of ModuleScripts would have helped me massively in identifying performance issues in some of my game systems. I had created a projectile system where a ModuleScript would handle logic connected to a Heartbeat event and for months I thought it was perfectly performant as I saw 0 - 0.5% activity in the root script. I eventually realised it was running at near 10% script activity.
It would be great if we could see the script activity of individual ModuleScripts or have the script requiring those modules accurately show activity overall.
It would be totally beneficial if you could monitor the script activity per module script. Is it even possible to do some sort of hierarchical structure, where the root script and its modules are displaying the percentages? The root may or may not be the summary of all activity in each module script. It would be fantastic if that was implemented.
I agree. Personally I was expecting modules to show up individually like any other script, which, would be better than nothing, but, if you wanted to drift more into feature request territory the ability to view script activities as a hierarchy would be amazing.
Even better would be displaying the traceback of events/threads and those thread’s activities as well, but, I’m not sure if that’s something that luau would have the capability for.
I think it would make sense if modules have their own individual activity listings, but, the scripts that require them will keep track of them. That way if a module is running but the original script that required it dies, the module can show up in the list. If two scripts required the same module, that module could show up under both scripts as a dropdown. It still shouldn’t add to the script’s activity, since, the module script is still its own thing, but, having a way to identify what scripts are starting what modules and how those are contributing to performance would be great as well.
And, in the case where a module has only been required by one script it might make sense to allow that module to contribute to the script’s total activity but I think that could be a little confusing. At the very least, modules that are required by exactly one running script could show up only under that script without their own separate activity entry.
Overall, I think it’d be really good to have some extra script activity functionality rather than just fixing this ancient bug, but, I’m not really sure. Probably deserves its own feature request thread.
It would help with optimizations and reduce the pain that comes with solving performance bottlenecks. I would love to see module scripts’ activity as well.