ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/map-scheduler.ext
(Generate patch)

Comparing deliantra/server/ext/map-scheduler.ext (file contents):
Revision 1.24 by root, Mon Jan 22 03:44:41 2007 UTC vs.
Revision 1.25 by root, Tue Jan 23 01:05:17 2007 UTC

6 6
7#our $DEACTIVATE_TIMEOUT = 20; # number of seconds after which maps get deactivated to save cpu 7#our $DEACTIVATE_TIMEOUT = 20; # number of seconds after which maps get deactivated to save cpu
8our $SWAP_TIMEOUT = 35; # number of seconds after which maps inactive get swapped out 8our $SWAP_TIMEOUT = 35; # number of seconds after which maps inactive get swapped out
9our $SCHEDULE_INTERVAL = 2; # time the map scheduler sleeps between runs 9our $SCHEDULE_INTERVAL = 2; # time the map scheduler sleeps between runs
10our $SAVE_TIMEOUT = 20; # save maps every n seconds 10our $SAVE_TIMEOUT = 20; # save maps every n seconds
11our $MAX_ACTIVES = $cf::CFG{max_actives} || 200000; # swap aggressively when > this many objects are active
11 12
12cf::async_ext { 13cf::async_ext {
13 $Coro::current->prio (Coro::PRIO_MIN); 14 $Coro::current->prio (Coro::PRIO_MIN);
14 # load the header of swapped-out maps. 15 # load the header of swapped-out maps.
15 # this is not a correctness issue, it simply saves diskspace 16 # this is not a correctness issue, it simply saves diskspace
53# delete $map->{active}; 54# delete $map->{active};
54# } 55# }
55 if ($map->should_reset) { 56 if ($map->should_reset) {
56 $map->reset; 57 $map->reset;
57 } elsif ($map->in_memory == cf::MAP_IN_MEMORY) { 58 } elsif ($map->in_memory == cf::MAP_IN_MEMORY) {
58 if ($map->last_access + $SWAP_TIMEOUT <= $cf::RUNTIME && !$map->players) { 59 if ((cf::object::actives_size > $MAX_ACTIVES || $map->last_access + $SWAP_TIMEOUT <= $cf::RUNTIME)
60 && !$map->players) {
61 $map->swap_out;
59 $cf::WAIT_FOR_TICK_ONE->wait; 62 $cf::WAIT_FOR_TICK_ONE->wait;
60 $map->swap_out;
61 } elsif ($map->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { 63 } elsif ($map->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) {
64 $map->save;
62 $cf::WAIT_FOR_TICK_ONE->wait; 65 $cf::WAIT_FOR_TICK_ONE->wait;
63 $map->save;
64 } 66 }
65 } 67 }
66 }; 68 };
67 warn $@ if $@; 69 warn $@ if $@;
68 Coro::cede; 70 Coro::cede;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines