… | |
… | |
8 | our $SWAP_TIMEOUT = $cf::CFG{swap_timeout} || 300; # number of seconds after which inactive maps get swapped out |
8 | our $SWAP_TIMEOUT = $cf::CFG{swap_timeout} || 300; # number of seconds after which inactive maps get swapped out |
9 | our $SCHEDULE_INTERVAL = $cf::CFG{schedule_interval} || .8; # time the map scheduler sleeps between runs |
9 | our $SCHEDULE_INTERVAL = $cf::CFG{schedule_interval} || .8; # time the map scheduler sleeps between runs |
10 | our $SAVE_TIMEOUT = $cf::CFG{save_timeout} || 30; # save maps every n seconds |
10 | our $SAVE_TIMEOUT = $cf::CFG{save_timeout} || 30; # save maps every n seconds |
11 | our $SWAP_LOAD1 = $cf::CFG{swap_load1} || .1; # start aggressively swapping at this load |
11 | our $SWAP_LOAD1 = $cf::CFG{swap_load1} || .1; # start aggressively swapping at this load |
12 | our $SWAP_LOAD2 = $cf::CFG{swap_load2} || .4; # swap as fast as possible at this load |
12 | our $SWAP_LOAD2 = $cf::CFG{swap_load2} || .4; # swap as fast as possible at this load |
|
|
13 | |
|
|
14 | warn "load1 ", $SWAP_LOAD1;#d# |
|
|
15 | warn "load2 ", $SWAP_LOAD2;#d# |
13 | |
16 | |
14 | cf::async_ext { |
17 | cf::async_ext { |
15 | $Coro::current->prio (Coro::PRIO_MIN); |
18 | $Coro::current->prio (Coro::PRIO_MIN); |
16 | |
19 | |
17 | # load the header of swapped-out maps. |
20 | # load the header of swapped-out maps. |
… | |
… | |
82 | |
85 | |
83 | if ($map->last_access + $max_idle <= $cf::RUNTIME && !$map->players) { |
86 | if ($map->last_access + $max_idle <= $cf::RUNTIME && !$map->players) { |
84 | $map->swap_out; |
87 | $map->swap_out; |
85 | } elsif ($map->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
88 | } elsif ($map->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
86 | $map->save; |
89 | $map->save; |
|
|
90 | $map->{last_save} -= rand; # randomise map save times a bit |
87 | } |
91 | } |
88 | } |
92 | } |
89 | }; |
93 | }; |
90 | warn $@ if $@; |
94 | warn $@ if $@; |
91 | cf::cede_to_tick; |
95 | cf::cede_to_tick; |