profiling stats for samba

Herb Lewis herb at chomps.engr.sgi.com
Wed Oct 4 15:42:31 GMT 2000


I would like to propose the following structure for profile.h as the
list of stats that will be collected when profiling is enabled. I would
like suggestions on what other stats should be collected. Jeremy 
indicated he would like the execution time for processing SMB
transactions. Do we want the time for every SMB? Do we want the time
split into system and user?

Currently this is implemented as a shared memory segment so the 
display agent can obtain the info later. All smbd's write into this 
with no locking to reduce overhead. Since this is not critical data
it doesn't really matter if we ocassionally step on each other while
bumping a counter. Do we want to collect indivual stats for every smbd
that is running or maybe be able to specify a particular smbd that 
should be the only process updating the counters? Currently the size
is 584 bytes for the structure. If we want individual stats for all
smbd's what do people recommend for storing these - tdb, mmap file,
etc.?

Finally, once all this is completed, should this be left as a compile
time option or should we add a runtime test for a pointer being 
non-null to every function where stats are gathered? I may actually
try this later and run NetBench to see what the performance degrad
will be.

I have also implemented a Performance Co-Pilot collection agent to
display these stats that I'll probably check into the samba tree
when it is complete.

I would appreciate feedback and suggestions from all.
-- 
======================================================================
Herb Lewis                               Silicon Graphics 
Networking Engineer                      1600 Amphitheatre Pkwy MS-510
Strategic Software Organization          Mountain View, CA  94043-1351
herb at sgi.com                             Tel: 650-933-2177
http://www.sgi.com                       Fax: 650-932-2177          
======================================================================
-------------- next part --------------
/* 
   Unix SMB/Netbios implementation.
   Version 1.9.
   store smbd profiling information in shared memory
   Copyright (C) Andrew Tridgell 1999
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

/*
 * Reasons for cache flush.
 */

#define NUM_FLUSH_REASONS 8 /* Keep this in sync with the enum below. */
enum flush_reason_enum { SEEK_FLUSH, READ_FLUSH, WRITE_FLUSH, READRAW_FLUSH,
			OPLOCK_RELEASE_FLUSH, CLOSE_FLUSH, SYNC_FLUSH, SIZECHANGE_FLUSH };
 
/* this file defines the profile structure in the profile shared
   memory area */

#define PROF_SHMEM_KEY ((key_t)0x07021999)
#define PROF_SHM_MAGIC 0x6349985
#define PROF_SHM_VERSION 2

struct profile_struct {
	int prof_shm_magic;
	int prof_shm_version;
/* general counters */
	unsigned smb_count; /* how many SMB packets we have processed */
	unsigned uid_changes; /* how many times we change our effective uid */
/* system call counters */
	unsigned syscall_opendir_count;
	unsigned syscall_readdir_count;
	unsigned syscall_mkdir_count;
	unsigned syscall_rmdir_count;
	unsigned syscall_closedir_count;
	unsigned syscall_open_count;
	unsigned syscall_close_count;
	unsigned syscall_read_count;
	unsigned syscall_read_bytes;	/* bytes read with read syscall */
	unsigned syscall_write_count;
	unsigned syscall_write_bytes;	/* bytes written with write syscall */
	unsigned syscall_lseek_count;
	unsigned syscall_rename_count;
	unsigned syscall_fsync_count;
	unsigned syscall_stat_count;
	unsigned syscall_fstat_count;
	unsigned syscall_lstat_count;
	unsigned syscall_unlink_count;
	unsigned syscall_chmod_count;
	unsigned syscall_chown_count;
	unsigned syscall_chdir_count;
	unsigned syscall_getwd_count;
	unsigned syscall_utime_count;
	unsigned syscall_ftruncate_count;
	unsigned syscall_fcntl_lock_count;
/* stat cache counters */
	unsigned statcache_lookups;
	unsigned statcache_misses;
	unsigned statcache_hits;
/* write cache counters */
	unsigned writecache_read_hits;
	unsigned writecache_abutted_writes;
	unsigned writecache_total_writes;
	unsigned writecache_non_oplock_writes;
	unsigned writecache_direct_writes;
	unsigned writecache_init_writes;
	unsigned writecache_flushed_writes[NUM_FLUSH_REASONS];
	unsigned writecache_num_perfect_writes;
	unsigned writecache_num_write_caches;
	unsigned writecache_allocated_write_caches;
/* counters for individual SMB types */
	unsigned SMBmkdir_count;	/* create directory */
	unsigned SMBrmdir_count;	/* delete directory */
	unsigned SMBopen_count;		/* open file */
	unsigned SMBcreate_count;	/* create file */
	unsigned SMBclose_count;	/* close file */
	unsigned SMBflush_count;	/* flush file */
	unsigned SMBunlink_count;	/* delete file */
	unsigned SMBmv_count;		/* rename file */
	unsigned SMBgetatr_count;	/* get file attributes */
	unsigned SMBsetatr_count;	/* set file attributes */
	unsigned SMBread_count;		/* read from file */
	unsigned SMBwrite_count;	/* write to file */
	unsigned SMBlock_count;		/* lock byte range */
	unsigned SMBunlock_count;	/* unlock byte range */
	unsigned SMBctemp_count;	/* create temporary file */
	unsigned SMBmknew_count;	/* make new file */
	unsigned SMBchkpth_count;	/* check directory path */
	unsigned SMBexit_count;		/* process exit */
	unsigned SMBlseek_count;	/* seek */
	unsigned SMBlockread_count;	/* Lock a range and read */
	unsigned SMBwriteunlock_count;	/* Unlock a range then write */
	unsigned SMBreadbraw_count;	/* read a block of data with no smb header */
	unsigned SMBreadBmpx_count;	/* read block multiplexed */
	unsigned SMBreadBs_count;	/* read block (secondary response) */
	unsigned SMBwritebraw_count;	/* write a block of data with no smb header */
	unsigned SMBwriteBmpx_count;	/* write block multiplexed */
	unsigned SMBwriteBs_count;	/* write block (secondary request) */
	unsigned SMBwritec_count;	/* secondary write request */
	unsigned SMBsetattrE_count;	/* set file attributes expanded */
	unsigned SMBgetattrE_count;	/* get file attributes expanded */
	unsigned SMBlockingX_count;	/* lock/unlock byte ranges and X */
	unsigned SMBtrans_count;	/* transaction - name, bytes in/out */
	unsigned SMBtranss_count;	/* transaction (secondary request/response) */
	unsigned SMBioctl_count;	/* IOCTL */
	unsigned SMBioctls_count;	/* IOCTL  (secondary request/response) */
	unsigned SMBcopy_count;		/* copy */
	unsigned SMBmove_count;		/* move */
	unsigned SMBecho_count;		/* echo */
	unsigned SMBwriteclose_count;	/* write a file then close it */
	unsigned SMBopenX_count;	/* open and X */
	unsigned SMBreadX_count;	/* read and X */
	unsigned SMBwriteX_count;	/* write and X */
	unsigned SMBtrans2_count;	/* TRANS2 protocol set */
	unsigned SMBtranss2_count;	/* TRANS2 protocol set, secondary command */
	unsigned SMBfindclose_count;	/* Terminate a TRANSACT2_FINDFIRST */
	unsigned SMBfindnclose_count;	/* Terminate a TRANSACT2_FINDNOTIFYFIRST */
	unsigned SMBtcon_count;		/* tree connect */
	unsigned SMBtdis_count;		/* tree disconnect */
	unsigned SMBnegprot_count;	/* negotiate protocol */
	unsigned SMBsesssetupX_count;	/* Session Set Up & X (including User Logon) */
	unsigned SMBulogoffX_count;	/* user logoff */
	unsigned SMBtconX_count;	/* tree connect and X*/
	unsigned SMBdskattr_count;	/* get disk attributes */
	unsigned SMBsearch_count;	/* search directory */
	unsigned SMBffirst_count;	/* find first */
	unsigned SMBfunique_count;	/* find unique */
	unsigned SMBfclose_count;	/* find close */
	unsigned SMBnttrans_count;	/* NT transact */
	unsigned SMBnttranss_count;	/* NT transact secondary */
	unsigned SMBntcreateX_count;	/* NT create and X */
	unsigned SMBntcancel_count;	/* NT cancel */
	unsigned SMBsplopen_count;	/* open print spool file */
	unsigned SMBsplwr_count;	/* write to print spool file */
	unsigned SMBsplclose_count;	/* close print spool file */
	unsigned SMBsplretq_count;	/* return print queue */
	unsigned SMBsends_count;	/* send single block message */
	unsigned SMBsendb_count;	/* send broadcast message */
	unsigned SMBfwdname_count;	/* forward user name */
	unsigned SMBcancelf_count;	/* cancel forward */
	unsigned SMBgetmac_count;	/* get machine name */
	unsigned SMBsendstrt_count;	/* send start of multi-block message */
	unsigned SMBsendend_count;	/* send end of multi-block message */
	unsigned SMBsendtxt_count;	/* send text of multi-block message */
	unsigned SMBinvalid_count;	/* invalid command */
/* These are the TRANS2 sub commands */
	unsigned Trans2_open_count;
	unsigned Trans2_findfirst_count;
	unsigned Trans2_findnext_count;
	unsigned Trans2_qfsinfo_count;
	unsigned Trans2_setfsinfo_count;
	unsigned Trans2_qpathinfo_count;
	unsigned Trans2_setpathinfo_count;
	unsigned Trans2_qfileinfo_count;
	unsigned Trans2_setfileinfo_count;
	unsigned Trans2_fsctl_count;
	unsigned Trans2_ioctl_count;
	unsigned Trans2_findnotifyfirst_count;
	unsigned Trans2_findnotifynext_count;
	unsigned Trans2_mkdir_count;
	unsigned Trans2_session_setup_count;
	unsigned Trans2_get_dfs_referral_count;
	unsigned Trans2_report_dfs_inconsistancy_count;
/* These are the NT transact sub commands. */
	unsigned NT_transact_create_count;
	unsigned NT_transact_ioctl_count;
	unsigned NT_transact_set_security_desc_count;
	unsigned NT_transact_notify_change_count;
	unsigned NT_transact_rename_count;
	unsigned NT_transact_query_security_desc_count;
};


extern struct profile_struct *profile_p;


More information about the samba-technical mailing list