Commit 163ed855 authored by Yiannis Tsiouris's avatar Yiannis Tsiouris

Make Stats type more module-specific

parent 0a8089a2
......@@ -7,15 +7,17 @@ import Control.Distributed.Process (Process, ProcessId, NodeId,
match, receiveWait)
import Credit (credit, is_one)
import qualified Sequential as Sq (Generator, orbit)
import Table (Stats, Vertex, freq_from_stat,
import Table (Vertex, freq_from_stat,
freq_to_stat, sum_freqs)
import Worker (credit_retd_from_stat,
import Worker (WorkerStats,
credit_retd_from_stat,
init_idle_from_stat,
max_idle_from_stat,
min_atomic_credit_from_stat,
tail_idle_from_stat,
verts_recvd_from_stat)
type MasterStats = [(String, String)]
data MaybeHosts = Seq Int
| Par HostInfo
data HostInfo = JustOne (Int, -- Number of processes
......@@ -91,22 +93,14 @@ type ParConf = ([Sq.Generator], ProcessId, [ProcessId], Int, Int, Bool)
-- The function returns a pair consisting of the computed orbit and
-- a list of statistics, the first element of which reports overall statistics,
-- and all remaining elements report statistics of some worker.
orbit :: [Vertex -> Vertex] -> [Vertex] -> MaybeHosts -> ([Vertex], [Stats])
orbit :: [Vertex -> Vertex] -> [Vertex] -> MaybeHosts -> ([Vertex], [MasterStats])
orbit gs xs (Seq tablesize) = Sq.orbit gs xs tablesize
orbit gs xs (Par hostInfo) = par_orbit gs xs hostInfo
-- FIXME Write the proper par_orbit
par_orbit :: [Vertex -> Vertex] -> [Vertex] -> HostInfo -> ([Vertex], [Stats])
par_orbit :: [Vertex -> Vertex] -> [Vertex] -> HostInfo -> ([Vertex], [MasterStats])
par_orbit gs xs hosts = ([42], [[("xxx", "xxx")]])
-- collect_credit collects leftover credit from idle workers until
-- the credit adds up to 1.
collect_credit :: [Int] -> Process ()
......@@ -119,12 +113,12 @@ collect_credit crdt =
]
-- collect_orbit collects partial orbits and stats from N workers.
collect_orbit :: Int -> Int -> Process ([Vertex], [Stats])
collect_orbit :: Int -> Int -> Process ([Vertex], [MasterStats])
collect_orbit elapsedTime n = do
(orbit, stats) <- do_collect_orbit n [] []
return (concat orbit, master_stats elapsedTime stats : stats)
do_collect_orbit :: Int -> [[Vertex]] -> [Stats] -> Process ([[Vertex]], [Stats])
do_collect_orbit :: Int -> [[Vertex]] -> [WorkerStats] -> Process ([[Vertex]], [WorkerStats])
do_collect_orbit 0 partOrbits workerStats = return (partOrbits, workerStats)
do_collect_orbit n partOrbits workerStats = do
receiveWait [
......@@ -165,15 +159,16 @@ clear_spawn_img_comp :: ParConf -> ParConf
clear_spawn_img_comp (gs, mst, wks, gts, tmt, spawmImgComp) = (gs, mst, wks, gts, tmt, False)
-- produce readable statistics
master_stats :: Int -> [Stats] -> Stats
master_stats elapsedTime workerStats = ("wall_time", show elapsedTime)
: ("vertices_recvd", show vertsRecvd)
: ("credit_retd", show creditRetd)
: ("min_atomic_credit", show minAtomicCredit)
: ("max_init_idle_time", show maxInitIdle)
: ("max_idle_time", show maxIdle)
: ("max_tail_idle_time", show maxTailIdle)
: freq_to_stat freq
master_stats :: Int -> [WorkerStats] -> MasterStats
master_stats elapsedTime workerStats =
("wall_time", show elapsedTime)
: ("vertices_recvd", show vertsRecvd)
: ("credit_retd", show creditRetd)
: ("min_atomic_credit", show minAtomicCredit)
: ("max_init_idle_time", show maxInitIdle)
: ("max_idle_time", show maxIdle)
: ("max_tail_idle_time", show maxTailIdle)
: freq_to_stat freq
where freq = sum_freqs $ map freq_from_stat workerStats
vertsRecvd = sum $ map verts_recvd_from_stat workerStats
creditRetd = sum $ map credit_retd_from_stat workerStats
......
......@@ -10,13 +10,13 @@ module Sequential( -- Types
import Data.Dequeue (BankersDequeue, fromList, popFront, pushBack)
import Data.Hashable (hash)
import Table (Freq, Stats, Vertex, VTable,
freq_to_stat, get_freq, insert, is_member, new,
to_list)
import Table (Freq, Vertex, VTable, freq_to_stat, get_freq,
insert, is_member, new, to_list)
import Utils (now)
type Generator = Vertex -> Vertex
type SeqConf = ([Generator], Int)
type SeqStats = [(String, String)]
-- DATA
-- Static Machine Configuration:
......@@ -32,7 +32,7 @@ type SeqConf = ([Generator], Int)
-- where the hash table is of size TableSize.
-- The function returns a pair consisting of the computed orbit and a singleton
-- list of statistics (mainly runtime and fill degree of the table).
orbit :: [Generator] -> [Vertex] -> Int -> ([Vertex], [Stats])
orbit :: [Generator] -> [Vertex] -> Int -> ([Vertex], [SeqStats])
orbit gs xs tableSize = (orbit, [stat])
where -- assemble static configuration
staticMachConf = mk_static_mach_conf gs tableSize
......@@ -99,7 +99,9 @@ get_table_size :: SeqConf -> Int
get_table_size staticMachConf = snd staticMachConf
-- produce readable statistics
seq_stats :: Int -> Freq -> Int -> Stats
seq_stats :: Int -> Freq -> Int -> SeqStats
seq_stats elapsedTime frequency vertsRecvd =
("wall_time", show elapsedTime) : ("vertices_recvd", show vertsRecvd) : freq_to_stat frequency
("wall_time", show elapsedTime)
: ("vertices_recvd", show vertsRecvd)
: freq_to_stat frequency
......@@ -3,7 +3,6 @@
--
module Table( -- Types
Freq
, Stats
, VTable
, Vertex
-- Functions
......@@ -30,7 +29,7 @@ import Data.Array (Array, elems, listArray, (!), (//))
type Freq = [Int]
type Vertex = Int
type VTable = Array Int [Vertex]
type Stats = [(String, String)]
type TableStats = [(String, String)]
-- Note: Hash tables have a fixed number of slots but each slot can store
-- a list of vertices. The functions is_member/3 and insert/3
......@@ -106,26 +105,24 @@ sum_freqs fs = foldl (flip sum_freqs2) [] fs
-- freq_to_stat produces a readable statistics from a table fill frequency;
-- the input frequency F is itself part of the statistics
freq_to_stat :: Freq -> Stats
freq_to_stat frequency = [ ("freq", show frequency)
, ("size", show $ freq_to_vertices frequency)
, ("slots", show $ freq_to_slots frequency)
, ("nonempty_slots",
show $ freq_to_nonempty_slots frequency)
, ("fill_deg", show $ fill_deg frequency)
, ("max_freq", show $ max_freq frequency)
, ("avg_freq", show $ avg_freq frequency)
, ("nonempty_avg_freq",
show $ avg_nonempty_freq frequency)
]
freq_to_stat :: Freq -> TableStats
freq_to_stat frequency =
[ ("freq", show frequency)
, ("size", show $ freq_to_vertices frequency)
, ("slots", show $ freq_to_slots frequency)
, ("nonempty_slots", show $ freq_to_nonempty_slots frequency)
, ("fill_deg", show $ fill_deg frequency)
, ("max_freq", show $ max_freq frequency)
, ("avg_freq", show $ avg_freq frequency)
, ("nonempty_avg_freq", show $ avg_nonempty_freq frequency) ]
-- freq_from_stat extracts a table fill frequency from a statistics Stat
-- (assuming Stat was produced by freq_to_stat/1, otherwise returns []);
freq_from_stat :: Stats -> Freq
freq_from_stat :: TableStats -> Freq
freq_from_stat stat =
case "freq" `lookup` stat of
Just val -> read val :: [Int]
Nothing -> []
case "freq" `lookup` stat of
Just val -> read val :: [Int]
Nothing -> []
--------------------------------------------------------------------------------
-- auxiliary functions
......
......@@ -2,31 +2,36 @@
-- orbit-int worker (computing vertices and holding part of hash table)
--
module Worker( --init
--, distribute_vertices
--, send_image
--, distribute_vertices
--, send_image
verts_recvd_from_stat
, credit_retd_from_stat
, min_atomic_credit_from_stat
, init_idle_from_stat
, tail_idle_from_stat
, max_idle_from_stat
, WorkerStats
) where
import Control.Distributed.Process (NodeId)
import Table (Freq, Stats, freq_to_stat)
import Table (Freq, freq_to_stat)
import Utils (now)
type WorkerStats = [(String, String)]
-- counters/timers record
data Ct = Ct {
verts_recvd :: Int -- #vertices received by this server so far
, credit_retd :: Int -- #times server has returned credit to master
, min_atomic_credit :: Int -- minimal atomic credit received so far
, last_event :: Int -- time stamp [ms] of most recent event
, init_idle :: Int -- idle time [ms] between init recv first vertex
, tail_idle :: Int -- idle time [ms] between send last vertex and dump
, max_idle :: Int -- max idle [ms] time between vertices
}
data Ct = Ct { verts_recvd :: Int -- #vertices received by this server so far
, credit_retd :: Int -- #times server has returned credit to
-- master
, min_atomic_credit :: Int -- minimal atomic credit received so far
, last_event :: Int -- time stamp [ms] of most recent event
, init_idle :: Int -- idle time [ms] between init recv first
-- vertex
, tail_idle :: Int -- idle time [ms] between send last vertex
-- and dump
, max_idle :: Int -- max idle [ms] time between vertices
}
defaultCt :: Ct
defaultCt = Ct { verts_recvd = 0
......@@ -39,49 +44,49 @@ defaultCt = Ct { verts_recvd = 0
}
-- produce readable statistics
worker_stats :: NodeId -> Freq -> Ct -> Stats
worker_stats node frequency statData = ("node", show node)
: ("vertices_recvd", show $ verts_recvd statData)
: ("credit_retd", show $ credit_retd statData)
: ("min_atomic_credit", show $ min_atomic_credit statData)
: ("init_idle_time", show $ init_idle statData)
: ("max_idle_time", show $ max_idle statData)
: ("tail_idle_time", show $ tail_idle statData)
: freq_to_stat frequency
worker_stats :: NodeId -> Freq -> Ct -> WorkerStats
worker_stats node frequency statData =
("node", show node)
: ("vertices_recvd", show $ verts_recvd statData)
: ("credit_retd", show $ credit_retd statData)
: ("min_atomic_credit", show $ min_atomic_credit statData)
: ("init_idle_time", show $ init_idle statData)
: ("max_idle_time", show $ max_idle statData)
: ("tail_idle_time", show $ tail_idle statData)
: freq_to_stat frequency
verts_recvd_from_stat :: Stats -> Int
verts_recvd_from_stat :: WorkerStats -> Int
verts_recvd_from_stat stat =
case "vertices_recvd" `lookup` stat of
Just val -> read val :: Int
Nothing -> 0 -- instead of false
case "vertices_recvd" `lookup` stat of
Just val -> read val :: Int
Nothing -> 0 -- instead of false
credit_retd_from_stat :: Stats -> Int
credit_retd_from_stat :: WorkerStats -> Int
credit_retd_from_stat stat =
case "credit_retd" `lookup` stat of
Just val -> read val :: Int
Nothing -> 0 -- instead of false
case "credit_retd" `lookup` stat of
Just val -> read val :: Int
Nothing -> 0 -- instead of false
min_atomic_credit_from_stat :: Stats -> Int
min_atomic_credit_from_stat :: WorkerStats -> Int
min_atomic_credit_from_stat stat =
case "min_atomic_credit" `lookup` stat of
Just val -> read val :: Int
Nothing -> 0 -- instead of false
case "min_atomic_credit" `lookup` stat of
Just val -> read val :: Int
Nothing -> 0 -- instead of false
init_idle_from_stat :: Stats -> Int
init_idle_from_stat :: WorkerStats -> Int
init_idle_from_stat stat =
case "init_idle_time" `lookup` stat of
Just val -> read val :: Int
Nothing -> 0 -- instead of false
case "init_idle_time" `lookup` stat of
Just val -> read val :: Int
Nothing -> 0 -- instead of false
tail_idle_from_stat :: Stats -> Int
tail_idle_from_stat :: WorkerStats -> Int
tail_idle_from_stat stat =
case "tail_idle_time" `lookup` stat of
Just val -> read val :: Int
Nothing -> 0 -- instead of false
Just val -> read val :: Int
Nothing -> 0 -- instead of false
max_idle_from_stat :: Stats -> Int
max_idle_from_stat :: WorkerStats -> Int
max_idle_from_stat stat =
case "max_idle_time" `lookup` stat of
Just val -> read val :: Int
Nothing -> 0 -- instead of false
case "max_idle_time" `lookup` stat of
Just val -> read val :: Int
Nothing -> 0 -- instead of false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment