[peerdist] Gather and report peer statistics during download

Record and report the number of peers (calculated as the maximum
number of peers discovered for a block's segment at the time that the
block download is complete), and the percentage of blocks retrieved
from peers rather than from the origin server.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2017-09-05 22:55:05 +01:00
parent 4674df25ef
commit 7e673a6b67
5 changed files with 114 additions and 0 deletions

View File

@@ -76,6 +76,36 @@ static struct peerdisc_segment * peerdisc_find ( const char *id );
static int peerdisc_discovered ( struct peerdisc_segment *segment,
const char *location );
/******************************************************************************
*
* Statistics reporting
*
******************************************************************************
*/
/**
* Report peer discovery statistics
*
* @v intf Interface
* @v peer Selected peer (or NULL)
* @v peers List of available peers
*/
void peerdisc_stat ( struct interface *intf, struct peerdisc_peer *peer,
struct list_head *peers ) {
struct interface *dest;
peerdisc_stat_TYPE ( void * ) *op =
intf_get_dest_op ( intf, peerdisc_stat, &dest );
void *object = intf_object ( dest );
if ( op ) {
op ( object, peer, peers );
} else {
/* Default is to do nothing */
}
intf_put ( dest );
}
/******************************************************************************
*
* Discovery sockets