Changeset 1257


Ignore:
Timestamp:
Dec 10, 2008, 7:57:25 AM (16 years ago)
Author:
mmc
Message:

Added a new Rappture::sysinfo command for querying system load
information. Updated the p2p software to use that command to
gauge the load of workers and execute a "perftest" executable
from time to time to measure worker output.

Location:
trunk
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/lang/tcl/src/Makefile.in

    r1082 r1257  
    5555                RpRusage.o \
    5656                RpSignal.o  \
     57                RpSysinfo.o  \
    5758                RpUnitsTclInterface.o \
    5859                RpUtilsTclInterface.o
  • trunk/lang/tcl/src/Rappture_Init.c

    r1018 r1257  
    2525extern Tcl_AppInitProc RpRusage_Init;
    2626extern Tcl_AppInitProc RpSignal_Init;
     27extern Tcl_AppInitProc RpSysinfo_Init;
    2728extern Tcl_AppInitProc RpDaemon_Init;
    2829
     
    7273        return TCL_ERROR;
    7374    }
     75    if (RpSysinfo_Init(interp) != TCL_OK) {
     76        return TCL_ERROR;
     77    }
    7478    if (RpDaemon_Init(interp) != TCL_OK) {
    7579        return TCL_ERROR;
  • trunk/p2p/Makefile

    r1251 r1257  
     1CC = gcc
     2CFLAGS = -O3
     3
    14all:
     5        $(CC) $(CFLAGS) perftest.c -o perftest
    26        ./mkindex handler.tcl server.tcl client.tcl log.tcl random.tcl
  • trunk/p2p/authority.tcl

    r1251 r1257  
    99# ======================================================================
    1010#  Copyright (c) 2008  Purdue Research Foundation
     11#
     12#  See the file "license.terms" for information on usage and
     13#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1114# ======================================================================
    1215
  • trunk/p2p/client.tcl

    r1251 r1257  
    66# ======================================================================
    77#  Copyright (c) 2008  Purdue Research Foundation
     8#
     9#  See the file "license.terms" for information on usage and
     10#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    811# ======================================================================
    912package require Itcl
  • trunk/p2p/handler.tcl

    r1251 r1257  
    88# ======================================================================
    99#  Copyright (c) 2008  Purdue Research Foundation
     10#
     11#  See the file "license.terms" for information on usage and
     12#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1013# ======================================================================
    1114package require Itcl
  • trunk/p2p/log.tcl

    r1251 r1257  
    55# ======================================================================
    66#  Copyright (c) 2008  Purdue Research Foundation
     7#
     8#  See the file "license.terms" for information on usage and
     9#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    710# ======================================================================
    811# ----------------------------------------------------------------------
  • trunk/p2p/random.tcl

    r1251 r1257  
    55# ======================================================================
    66#  Copyright (c) 2008  Purdue Research Foundation
     7#
     8#  See the file "license.terms" for information on usage and
     9#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    710# ======================================================================
    811
  • trunk/p2p/server.tcl

    r1251 r1257  
    55# ======================================================================
    66#  Copyright (c) 2008  Purdue Research Foundation
     7#
     8#  See the file "license.terms" for information on usage and
     9#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    710# ======================================================================
    811package require Itcl
  • trunk/p2p/tclIndex

    r1251 r1257  
    1010set auto_index(::Handler::protocol) [list source [file join $dir handler.tcl]]
    1111set auto_index(::Handler::define) [list source [file join $dir handler.tcl]]
     12set auto_index(::Handler::connectionName) [list source [file join $dir handler.tcl]]
    1213set auto_index(::Handler::connectionSpeaks) [list source [file join $dir handler.tcl]]
    1314set auto_index(::Handler::handle) [list source [file join $dir handler.tcl]]
    1415set auto_index(::Handler::finalize) [list source [file join $dir handler.tcl]]
     16set auto_index(::Handler::handlerType) [list source [file join $dir handler.tcl]]
    1517set auto_index(Server) [list source [file join $dir server.tcl]]
    1618set auto_index(::Server::port) [list source [file join $dir server.tcl]]
    1719set auto_index(::Server::accept) [list source [file join $dir server.tcl]]
    1820set auto_index(::Server::connectionSpeaks) [list source [file join $dir server.tcl]]
     21set auto_index(::Server::handlerType) [list source [file join $dir server.tcl]]
    1922set auto_index(Client) [list source [file join $dir client.tcl]]
    2023set auto_index(::Client::send) [list source [file join $dir client.tcl]]
    2124set auto_index(::Client::address) [list source [file join $dir client.tcl]]
     25set auto_index(::Client::handlerType) [list source [file join $dir client.tcl]]
    2226set auto_index(log) [list source [file join $dir log.tcl]]
    2327set auto_index(randomize) [list source [file join $dir random.tcl]]
  • trunk/p2p/test.tcl

    r1251 r1257  
    99# ======================================================================
    1010#  Copyright (c) 2008  Purdue Research Foundation
     11#
     12#  See the file "license.terms" for information on usage and
     13#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1114# ======================================================================
    1215package require Itcl
  • trunk/p2p/worker.tcl

    r1251 r1257  
    1010# ======================================================================
    1111#  Copyright (c) 2008  Purdue Research Foundation
    12 # ======================================================================
     12#
     13#  See the file "license.terms" for information on usage and
     14#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     15# ======================================================================
     16package require Rappture
    1317
    1418# recognize other library files in this same directory
     
    4145set options(max_peer_connections) 4
    4246
     47# number of seconds between each check of system load
     48set options(time_between_load_checks) 60000
     49
    4350# ======================================================================
    4451#  PEERS
     
    4956# list of peers that we're testing connections with
    5057set peers(testing) ""
     58
     59# ======================================================================
     60#  SYSTEM LOAD
     61# ======================================================================
     62# Check system load every so often.  When the load changes
     63# significantly, execute a "perftest" run to compute the current
     64# number of wonks available to this worker.
     65
     66set sysload(lastLoad) -1
     67set sysload(wonks) -1
     68set sysload(measured) -1
     69
     70after idle worker_load_check
    5171
    5272# ======================================================================
     
    194214    # gets restarted in between.
    195215    after $options(time_between_registers) worker_register
     216}
     217
     218# ----------------------------------------------------------------------
     219#  COMMAND:  worker_load_check
     220#
     221#  Invoked when this worker first starts up and periodically thereafter
     222#  to compute the system load available to the worker.  If the system
     223#  load has changed significantly, then the "perftest" program is
     224#  executed to get a measure of performance available.  This program
     225#  returns a number of "wonks" which we report to peers as our available
     226#  performance.
     227# ----------------------------------------------------------------------
     228proc worker_load_check {} {
     229    global options sysload dir
     230
     231    # see if the load has changed significantly
     232    set changed 0
     233    if {$sysload(lastLoad) < 0} {
     234        set changed 1
     235    } else {
     236        set load [Rappture::sysinfo load5]
     237        if {$load < 0.9*$sysload(lastLoad) || $load > 1.1*$sysload(lastLoad)} {
     238            set changed 1
     239        }
     240    }
     241
     242    if {$changed} {
     243        set sysload(lastLoad) [Rappture::sysinfo load5]
     244puts "LOAD CHANGED: $sysload(lastLoad) [Rappture::sysinfo freeram freeswap]"
     245        set sysload(measured) [clock seconds]
     246
     247        # Run the program, but don't use exec, since it blocks.
     248        # Instead, run it in the background and harvest its output later.
     249        set sysload(test) [open "| [file join $dir perftest]" r]
     250        fileevent $sysload(test) readable worker_load_results
     251    }
     252
     253    # monitor the system load at regular intervals
     254    after $options(time_between_load_checks) worker_load_check
     255}
     256
     257# ----------------------------------------------------------------------
     258#  COMMAND:  worker_load_results
     259#
     260#  Invoked automatically when the "perftest" run finishes.  Reads the
     261#  number of wonks reported on standard output and reports them to
     262#  other peers.
     263# ----------------------------------------------------------------------
     264proc worker_load_results {} {
     265    global sysload
     266
     267    if {[catch {read $sysload(test)} msg] == 0} {
     268        if {[regexp {[0-9]+} $msg match]} {
     269puts "WONKS: $match"
     270            set sysload(wonks) $match
     271        } else {
     272            log system "ERROR: performance test failed: $msg"
     273        }
     274    }
     275    catch {close $sysload(test)}
     276    set sysload(test) ""
    196277}
    197278
Note: See TracChangeset for help on using the changeset viewer.