mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
s3:smbd: improve writecache profiling
In order to have useful profiling counters should never be decremented. We need a separate counter for deallocation events. The current value can be calculated by allocations - deallocations. We also use better names and avoid having an array for the flush reasons. This will simplify further profiling improvements a lot. The value writecache_num_write_caches (this was similar to writecache_allocations) is replaced by writecache_cached_writes, which counts the amount of writes which were completely handled by the cache. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
297d187761
commit
86a951b4ff
@ -819,7 +819,6 @@ enum flush_reason_enum {
|
||||
SAMBA_CLOSE_FLUSH,
|
||||
SAMBA_SYNC_FLUSH,
|
||||
SAMBA_SIZECHANGE_FLUSH,
|
||||
/* NUM_FLUSH_REASONS must remain the last value in the enumeration. */
|
||||
SAMBA_NUM_FLUSH_REASONS};
|
||||
};
|
||||
|
||||
#endif /* _SMB_H */
|
||||
|
@ -789,16 +789,24 @@ struct profile_stats {
|
||||
unsigned statcache_hits;
|
||||
|
||||
/* write cache counters */
|
||||
unsigned writecache_read_hits;
|
||||
unsigned writecache_abutted_writes;
|
||||
unsigned writecache_allocations;
|
||||
unsigned writecache_deallocations;
|
||||
unsigned writecache_cached_reads;
|
||||
unsigned writecache_total_writes;
|
||||
unsigned writecache_init_writes;
|
||||
unsigned writecache_abutted_writes;
|
||||
unsigned writecache_non_oplock_writes;
|
||||
unsigned writecache_direct_writes;
|
||||
unsigned writecache_init_writes;
|
||||
unsigned writecache_flushed_writes[SAMBA_NUM_FLUSH_REASONS];
|
||||
unsigned writecache_num_perfect_writes;
|
||||
unsigned writecache_num_write_caches;
|
||||
unsigned writecache_allocated_write_caches;
|
||||
unsigned writecache_cached_writes;
|
||||
unsigned writecache_perfect_writes;
|
||||
unsigned writecache_flush_reason_seek;
|
||||
unsigned writecache_flush_reason_read;
|
||||
unsigned writecache_flush_reason_readraw;
|
||||
unsigned writecache_flush_reason_write;
|
||||
unsigned writecache_flush_reason_oplock;
|
||||
unsigned writecache_flush_reason_close;
|
||||
unsigned writecache_flush_reason_sync;
|
||||
unsigned writecache_flush_reason_sizechange;
|
||||
};
|
||||
|
||||
extern struct profile_stats *profile_p;
|
||||
|
@ -53,7 +53,7 @@ static bool read_from_write_cache(files_struct *fsp,char *data,off_t pos,size_t
|
||||
|
||||
memcpy(data, wcp->data + (pos - wcp->offset), n);
|
||||
|
||||
DO_PROFILE_INC(writecache_read_hits);
|
||||
DO_PROFILE_INC(writecache_cached_reads);
|
||||
|
||||
return True;
|
||||
}
|
||||
@ -799,6 +799,7 @@ n = %u, wcp->offset=%.0f, wcp->data_size=%u\n",
|
||||
*/
|
||||
|
||||
if (n) {
|
||||
DO_PROFILE_INC(writecache_cached_writes);
|
||||
if (wcp->data_size) {
|
||||
DO_PROFILE_INC(writecache_abutted_writes);
|
||||
} else {
|
||||
@ -827,7 +828,6 @@ n = %u, wcp->offset=%.0f, wcp->data_size=%u\n",
|
||||
memcpy(wcp->data+wcp->data_size, data, n);
|
||||
if (wcp->data_size == 0) {
|
||||
wcp->offset = pos;
|
||||
DO_PROFILE_INC(writecache_num_write_caches);
|
||||
}
|
||||
wcp->data_size += n;
|
||||
|
||||
@ -866,7 +866,7 @@ void delete_write_cache(files_struct *fsp)
|
||||
return;
|
||||
}
|
||||
|
||||
DO_PROFILE_DEC(writecache_allocated_write_caches);
|
||||
DO_PROFILE_INC(writecache_deallocations);
|
||||
allocated_write_caches--;
|
||||
|
||||
SMB_ASSERT(wcp->data_size == 0);
|
||||
@ -914,7 +914,7 @@ static bool setup_write_cache(files_struct *fsp, off_t file_size)
|
||||
memset(wcp->data, '\0', wcp->alloc_size );
|
||||
|
||||
fsp->wcp = wcp;
|
||||
DO_PROFILE_INC(writecache_allocated_write_caches);
|
||||
DO_PROFILE_INC(writecache_allocations);
|
||||
allocated_write_caches++;
|
||||
|
||||
DEBUG(10,("setup_write_cache: File %s allocated write cache size %lu\n",
|
||||
@ -963,13 +963,40 @@ ssize_t flush_write_cache(files_struct *fsp, enum flush_reason_enum reason)
|
||||
data_size = wcp->data_size;
|
||||
wcp->data_size = 0;
|
||||
|
||||
DO_PROFILE_DEC_INC(writecache_num_write_caches,writecache_flushed_writes[reason]);
|
||||
switch (reason) {
|
||||
case SAMBA_SEEK_FLUSH:
|
||||
DO_PROFILE_INC(writecache_flush_reason_seek);
|
||||
break;
|
||||
case SAMBA_READ_FLUSH:
|
||||
DO_PROFILE_INC(writecache_flush_reason_read);
|
||||
break;
|
||||
case SAMBA_WRITE_FLUSH:
|
||||
DO_PROFILE_INC(writecache_flush_reason_write);;
|
||||
break;
|
||||
case SAMBA_READRAW_FLUSH:
|
||||
DO_PROFILE_INC(writecache_flush_reason_readraw);
|
||||
break;
|
||||
case SAMBA_OPLOCK_RELEASE_FLUSH:
|
||||
DO_PROFILE_INC(writecache_flush_reason_oplock);
|
||||
break;
|
||||
case SAMBA_CLOSE_FLUSH:
|
||||
DO_PROFILE_INC(writecache_flush_reason_close);
|
||||
break;
|
||||
case SAMBA_SYNC_FLUSH:
|
||||
DO_PROFILE_INC(writecache_flush_reason_sync);
|
||||
break;
|
||||
case SAMBA_SIZECHANGE_FLUSH:
|
||||
DO_PROFILE_INC(writecache_flush_reason_sizechange);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG(9,("flushing write cache: fd = %d, off=%.0f, size=%u\n",
|
||||
fsp->fh->fd, (double)wcp->offset, (unsigned int)data_size));
|
||||
|
||||
if(data_size == wcp->alloc_size) {
|
||||
DO_PROFILE_INC(writecache_num_perfect_writes);
|
||||
DO_PROFILE_INC(writecache_perfect_writes);
|
||||
}
|
||||
|
||||
ret = real_write_file(NULL, fsp, wcp->data, wcp->offset, data_size);
|
||||
|
@ -199,40 +199,42 @@ bool status_profile_dump(bool verbose)
|
||||
profile_p->statcache_hits);
|
||||
|
||||
profile_separator("Write Cache");
|
||||
d_printf("read_hits: %u\n",
|
||||
profile_p->writecache_read_hits);
|
||||
d_printf("abutted_writes: %u\n",
|
||||
profile_p->writecache_abutted_writes);
|
||||
d_printf("allocations: %u\n",
|
||||
profile_p->writecache_allocations);
|
||||
d_printf("deallocations: %u\n",
|
||||
profile_p->writecache_deallocations);
|
||||
d_printf("cached_reads: %u\n",
|
||||
profile_p->writecache_cached_reads);
|
||||
d_printf("total_writes: %u\n",
|
||||
profile_p->writecache_total_writes);
|
||||
d_printf("init_writes: %u\n",
|
||||
profile_p->writecache_init_writes);
|
||||
d_printf("abutted_writes: %u\n",
|
||||
profile_p->writecache_abutted_writes);
|
||||
d_printf("non_oplock_writes: %u\n",
|
||||
profile_p->writecache_non_oplock_writes);
|
||||
d_printf("direct_writes: %u\n",
|
||||
profile_p->writecache_direct_writes);
|
||||
d_printf("init_writes: %u\n",
|
||||
profile_p->writecache_init_writes);
|
||||
d_printf("flushed_writes[SEEK]: %u\n",
|
||||
profile_p->writecache_flushed_writes[SAMBA_SEEK_FLUSH]);
|
||||
d_printf("flushed_writes[READ]: %u\n",
|
||||
profile_p->writecache_flushed_writes[SAMBA_READ_FLUSH]);
|
||||
d_printf("flushed_writes[WRITE]: %u\n",
|
||||
profile_p->writecache_flushed_writes[SAMBA_WRITE_FLUSH]);
|
||||
d_printf("flushed_writes[READRAW]: %u\n",
|
||||
profile_p->writecache_flushed_writes[SAMBA_READRAW_FLUSH]);
|
||||
d_printf("flushed_writes[OPLOCK_RELEASE]: %u\n",
|
||||
profile_p->writecache_flushed_writes[SAMBA_OPLOCK_RELEASE_FLUSH]);
|
||||
d_printf("flushed_writes[CLOSE]: %u\n",
|
||||
profile_p->writecache_flushed_writes[SAMBA_CLOSE_FLUSH]);
|
||||
d_printf("flushed_writes[SYNC]: %u\n",
|
||||
profile_p->writecache_flushed_writes[SAMBA_SYNC_FLUSH]);
|
||||
d_printf("flushed_writes[SIZECHANGE]: %u\n",
|
||||
profile_p->writecache_flushed_writes[SAMBA_SIZECHANGE_FLUSH]);
|
||||
d_printf("num_perfect_writes: %u\n",
|
||||
profile_p->writecache_num_perfect_writes);
|
||||
d_printf("num_write_caches: %u\n",
|
||||
profile_p->writecache_num_write_caches);
|
||||
d_printf("allocated_write_caches: %u\n",
|
||||
profile_p->writecache_allocated_write_caches);
|
||||
d_printf("cached_writes: %u\n",
|
||||
profile_p->writecache_cached_writes);
|
||||
d_printf("perfect_writes: %u\n",
|
||||
profile_p->writecache_perfect_writes);
|
||||
d_printf("flush_reason_seek: %u\n",
|
||||
profile_p->writecache_flush_reason_seek);
|
||||
d_printf("flush_reason_read: %u\n",
|
||||
profile_p->writecache_flush_reason_read);
|
||||
d_printf("flush_reason_readraw: %u\n",
|
||||
profile_p->writecache_flush_reason_readraw);
|
||||
d_printf("flush_reason_write: %u\n",
|
||||
profile_p->writecache_flush_reason_write);
|
||||
d_printf("flush_reason_oplock: %u\n",
|
||||
profile_p->writecache_flush_reason_oplock);
|
||||
d_printf("flush_reason_close: %u\n",
|
||||
profile_p->writecache_flush_reason_close);
|
||||
d_printf("flush_reason_sync: %u\n",
|
||||
profile_p->writecache_flush_reason_sync);
|
||||
d_printf("flush_reason_sizechange: %u\n",
|
||||
profile_p->writecache_flush_reason_sizechange);
|
||||
|
||||
profile_separator("SMB Calls");
|
||||
d_printf("mkdir_count: %u\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user