ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.369 by root, Thu Sep 13 08:35:25 2007 UTC vs.
Revision 1.370 by root, Thu Sep 13 10:59:41 2007 UTC

3464 my $signal = new Coro::Signal; 3464 my $signal = new Coro::Signal;
3465 push @WAIT_FOR_TICK_BEGIN, $signal; 3465 push @WAIT_FOR_TICK_BEGIN, $signal;
3466 $signal->wait; 3466 $signal->wait;
3467} 3467}
3468 3468
3469our $stat_fh;
3470sysopen $stat_fh, "/tmp/cfstats", Fcntl::O_APPEND | Fcntl::O_CREAT | Fcntl::O_WRONLY, 0600;#d#
3471
3472$TICK_WATCHER = Event->timer ( 3469$TICK_WATCHER = Event->timer (
3473 reentrant => 0, 3470 reentrant => 0,
3474 parked => 1, 3471 parked => 1,
3475 prio => 0, 3472 prio => 0,
3476 at => $NEXT_TICK || $TICK, 3473 at => $NEXT_TICK || $TICK,
3480 Carp::cluck "major BUG: server tick called outside of main coro, skipping it" 3477 Carp::cluck "major BUG: server tick called outside of main coro, skipping it"
3481 unless ++$bug_warning > 10; 3478 unless ++$bug_warning > 10;
3482 return; 3479 return;
3483 } 3480 }
3484 3481
3485 my @pl = cf::player::list; my $stats = sprintf "%.2f %d %d %d", $RUNTIME, (scalar @pl), cf::object::actives_size, cf::object::objects_size; #d#
3486
3487 $NOW = $tick_start = Event::time; 3482 $NOW = $tick_start = Event::time;
3488 3483
3489 cf::server_tick; # one server iteration 3484 cf::server_tick; # one server iteration
3490 3485
3491 $RUNTIME += $TICK; 3486 $RUNTIME += $TICK;
3497 write_runtime 3492 write_runtime
3498 or warn "ERROR: unable to write runtime file: $!"; 3493 or warn "ERROR: unable to write runtime file: $!";
3499 }; 3494 };
3500 } 3495 }
3501 3496
3502# my $AFTER = Event::time;
3503# warn $AFTER - $NOW;#d#
3504
3505 if (my $sig = shift @WAIT_FOR_TICK_BEGIN) { 3497 if (my $sig = shift @WAIT_FOR_TICK_BEGIN) {
3506 $sig->send; 3498 $sig->send;
3507 } 3499 }
3508 while (my $sig = shift @WAIT_FOR_TICK) { 3500 while (my $sig = shift @WAIT_FOR_TICK) {
3509 $sig->send; 3501 $sig->send;
3519 3511
3520 $LOAD = ($NOW - $tick_start) / $TICK; 3512 $LOAD = ($NOW - $tick_start) / $TICK;
3521 $LOADAVG = $LOADAVG * 0.75 + $LOAD * 0.25; 3513 $LOADAVG = $LOADAVG * 0.75 + $LOAD * 0.25;
3522 3514
3523 _post_tick; 3515 _post_tick;
3524
3525 # gather some statistics#d#
3526 $stats .= sprintf " %d\n", 10000 * ($NOW - $tick_start);#d#
3527 IO::AIO::aio_write $stat_fh, undef, undef, $stats, 0;#d#
3528 }, 3516 },
3529); 3517);
3530 3518
3531{ 3519{
3532 BDB::min_parallel 8; 3520 BDB::min_parallel 8;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines