--- deliantra/server/ext/map-scheduler.ext 2007/01/03 12:33:33 1.9 +++ deliantra/server/ext/map-scheduler.ext 2007/01/04 17:22:06 1.12 @@ -4,10 +4,30 @@ # the reset/swap policy of the server. our $DEACTIVATE_TIMEOUT = 20; # number of seconds after which maps get deactivated to save cpu -our $SWAP_TIMEOUT = 50; # number of seconds after which maps inactive get swapped out +our $SWAP_TIMEOUT = 35; # number of seconds after which maps inactive get swapped out our $SCHEDULE_INTERVAL = 2; # time the map scheduler sleeps between runs -our $SAVE_TIMEOUT = 30; # save maps every n seconds -our $SAVE_INTERVAL = 0.3; # save at max. one map every $SAVE_INTERVAL +our $SAVE_TIMEOUT = 20; # save maps every n seconds +our $SAVE_INTERVAL = 0.1; # save at max. one map every $SAVE_INTERVAL + +cf::coro { + $Coro::current->prio (Coro::PRIO_MIN); + # load the header of swapped-out. + # this is not a correctness issue, it simply saves diskspace + # because old files will get cleaned up on reset time + Coro::Timer::sleep 5; + + my $files = Coro::AIO::aio_readdir cf::localdir . "/" . cf::tmpdir; + + for my $map (@$files) { + utf8::decode $map; + next if $map =~ /\.(?:pst|meta)$/; + $map =~ s/∕/\//g; + cf::map::find $map; + Coro::Timer::sleep 0.5; + } + + #TODO: should also preload random maps... +}; our $SCHEDULER = cf::coro { while () { @@ -50,3 +70,12 @@ $SCHEDULER->prio (-2); +# map load prefetch +cf::map->attach ( + on_enter => sub { + my ($map, $pl) = @_; + + # floodfill surrounging maps, asynchronously + }, +); +