Map/Reduce start: 15/12/2022 11:55.12 am Map/Redu...
# suitescript
c
Map/Reduce start: 15/12/2022 11:55.12 am Map/Reduce end: 15/12/2022 12:04.40 pm Error:
Copy code
{
   type: "error.SuiteScriptError",
   name: "SSS_TIME_LIMIT_EXCEEDED",
   message: "Script Execution Time Exceeded."
}
b
e
My guess is that you are seeing this in the getInputData stage. Try limiting your search results first.
c
It's a grouped search that only had one transaction
and the tran had 229 lines that are being iterated through
e
Is it an inline search or are you loading a saved search?
c
Loading the search
I will try/catch the search to see if that's where the exception is coming from.
This is probably the issue
300 seconds is not enough for what this script is doing.
I'm not sure how to make this quicker
I need to transform an SO to an IF then remove lines from the IF that do not meet a certain criteria. This means I have to inspect every line on the IF before it's saved
It's then updating each line on the SO where the same line was not removed from the transformed IF.
It just takes too long.
s
Are you actually utilizing the stages of Map/Reduce? You could move to a scheduled script if not.
c
The dev put everything in the map phase
b
change it to do some variation of one map or reduce stage per item fulfillment line
s
Inspecting lines on a data object that is already retrieved should not be "slow" at all. If you are editing/saving the same Sales Order over and over, then you should rework the script the update the SO once after creating all the corresponding fulfillments (by utilizing the stages as battk suggested)
c
The SO needs to be loaded and saved twice
so it's not really slow in that regard.
e
I have similar code that is based on the use case for splitting up the SO lines over several IFs based on pallet size criteria and most of the pre-work (retrieving the dataset and sorting it in preparation for updating it based on certain criteria) is done in getInputData and then all the heavy lifting is done in the reduce stage to generate the multiple IFs for one SO.
c
Sounds just as complex as this script
I think the original dev dumped everything map() because they probably saw map/reduce as a ScheduledScript replacement.
n
Most dev consider MR as scheduled script replacement which is totally wrong. I think you can implement this scenario in scheduled script without the error. Can you try that?
c
Not sure
Need to investigate governance limits
The script would have to initiate another instance of itself if the search results are too big
s
what exactly is taking all the time? are you doing some sort of loading/searchign for each line individually? The script you have described should not take long at all
c
What’s the best way to inspect execution time per function?
s
the simplest way is to log a time and put more logs throughout and see how long between each step... loading a sales order takes no time, creating an if takes no time, looping lines takes no time
so if you are trying to load/search for each line individually while looping, then change the script the go get all the data it needs for the lines at the same time instead of retrieving data one by one
c
There’s two loads and one search in the whole script
It’s not clear to me why it takes a lot time once you hit a few hundred lines
Does the performance monitoring tool allow me to drill down into function Exec times?
e
I would not convert this process to a scheduled script.
c
I hoped the move to graal vm would’ve given us more developer tools other than console logs and chrome debuggers
r
@battk How do you get the shareable help center links from system.netsuite.com?