Yielding is also affected by a governance limit. T...
# suitescript
r
Yielding is also affected by a governance limit. This limit is 10,000 usage units for each map and reduce job. This limit works in the same way as the Yield After Minutes limit. But map has 1000 and reduce has 5000 how come 10000?
b
the script processor will process multiple values for each map or reduce
it will yield after it uses 10000 points
each individual value for a map can use 1000 points
r
so in total all jobs of map can use 10000?
and it will yield after that
they have given each map or reduce job but then was is 1000 and 5000 ? and what is 10000?
b
a map stage processes key/values generated by the getInutData stage
the suitecloud processor that runs the map stage will use a maximum of 1000 points processsing on each key/value before throwing an error
that suitecloud processor will process multiple key/values until it uses 10000 points
at which point it will yield and goto the next task in the queue
a task that is yielded will go back into the queue, so its possible that the suitecloud processor will go right back to the same task if the queue is empty or full of lower priority tasks
r
so when I am able to process 80000 records each having to load the record that uses 10 units it has gone into yielding multiple times?
because clearly it has surpassed the 10000 unit mark after some 1000 records
for combined map and reduce it has 10000 or for 10000 for map and 10000 for reduce seperately?
by task you mean the key/value pair right or the deployment as whole?
b
your question for combined points regarding map/reduce makes no sense
the stages are separate
r
okay
let me rephrase
b
your question about 80000 records is probably more ambiguous than you meant, a single map or reduce invocation can process multiple records
r
See, what is difference between 1000 unit that map has and 10000 unit soft limit that is provided to map stage?
b
but the answer is the same, it will yield multiple times
r
I am just not getting the 10000 unit thing
b
SuiteScript 2.x Map/Reduce Governance describes the difference between the soft and hard limits
r
I know
I have read this 1000 times
b
its requires you to know the difference between yielding and throwing an error
r
atleast
yielding is restarting and throwing an error is when hard limit is exceeeded
b
and what do you think restarting means?
the usual definition of starting from the beginning is not what happens
r
but what I don't understand is suppose 50 total key/value pair in get input stage and map use 500 units for each each value so at 20th key value total unit that is 10000 is reached so after 20 key/value pair for 21st the yeilding will happen right? and it will be restarted in map stage and not the from the start that is the get input stage
right it starts only for map
not from start?
b
same question
and what do you think restarting means?
r
it means starting the script from where is stopped previously, at whatever stage or point it stopped it will start from there. Meaning it will not restart from the get input stage and execute the script from the start like we did when we did 'save & execute'
b
that is what will happen
r
thank god that was right
b
yielding in the map stage will start the script again at whatever the next key would be
r
but my 21st key value pair logic is correct right?
for 10000 unit
b
the yield would happen between the 20th and 21st
r
gotcha!
now it clicked
b
although you really dont want to write any logic that depends on that fact
r
right it will reschedule for itself
b
in practice, you just ignore the soft limit
r
right , I just needed to understand how it is working exactly
b
and make sure your map doesnt use over 1000 points
there are questionable things you can use if you pay extra attention to when the yield occurs
for example, global variables are preserved between map invocation until a yield occurs
r
right
b
its not something you would want to use if you wanted a robust script
r
it preserves everything
it might get lost in between