rvirding / luerl

Lua in Erlang
Apache License 2.0
1.02k stars 140 forks source link

What the 'Reductions' meaning in sandbox? #134

Closed wwhai closed 3 years ago

wwhai commented 3 years ago

Hi, I am confused at bellow code:

    %% script runner with reduction counting and process flags
    MaxReductions = 100,
    ProcessFlags = [{priority, low}],
    Timeout = 1000,
    {error, {reductions, R0}} = luerl_sandbox:run("a={}; for i=1,1000000 do a[i] = 5 end", St0, MaxReductions),
    io:format("killed process with reductions ~p > 100~n",[R0]),
    {error, {reductions, R1}} = luerl_sandbox:run("x = 'a'; while true do x = x .. x end", luerl:init(), MaxReductions, ProcessFlags, Timeout),
    io:format("killed process with reductions ~p > 100~n",[R1]),

Can you explain what the ‘Reductions’ means?Thanks!

wwhai commented 3 years ago

Oh, I found an article about erlang process reductions:=>https://hamidreza-s.github.io/erlang/scheduling/real-time/preemptive/migration/2016/02/09/erlang-scheduler-details.html

rvirding commented 3 years ago

Do you have suggestions for using spawn_opt?

Robert

On Wed, 18 Nov 2020 at 01:58, bignullnull notifications@github.com wrote:

And I also have a suggestion, should use spawn_opts to enhance sandbox:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rvirding/luerl/issues/134#issuecomment-729307031, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACZS6Q5G4375RIZMOXDDTSQML2HANCNFSM4TYXPA2Q .