Exemplo n.º 1
0
void print_resource_track(const char *desc, struct resource_track *track,
			  io_channel channel)
{
#ifdef HAVE_GETRUSAGE
	struct rusage r;
#endif
#ifdef HAVE_MALLINFO
	struct mallinfo	malloc_info;
#endif
	struct timeval time_end;

	gettimeofday(&time_end, 0);

	if (desc)
		printf("%s: ", desc);

#ifdef HAVE_MALLINFO
#define kbytes(x)	(((x) + 1023) / 1024)

	malloc_info = mallinfo();
	printf(_("Memory used: %dk/%dk (%dk/%dk), "),
	       kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
	       kbytes(malloc_info.uordblks), kbytes(malloc_info.fordblks));
#else
	printf(_("Memory used: %d, "),
	       (int) (((char *) sbrk(0)) - ((char *) track->brk_start)));
#endif
#ifdef HAVE_GETRUSAGE
	getrusage(RUSAGE_SELF, &r);

	printf(_("time: %5.2f/%5.2f/%5.2f\n"),
	       timeval_subtract(&time_end, &track->time_start),
	       timeval_subtract(&r.ru_utime, &track->user_start),
	       timeval_subtract(&r.ru_stime, &track->system_start));
#else
	printf(_("elapsed time: %6.3f\n"),
	       timeval_subtract(&time_end, &track->time_start));
#endif
#define mbytes(x)	(((x) + 1048575) / 1048576)
	if (channel && channel->manager && channel->manager->get_stats) {
		io_stats delta = 0;
		unsigned long long bytes_read = 0;
		unsigned long long bytes_written = 0;

		if (desc)
			printf("%s: ", desc);

		channel->manager->get_stats(channel, &delta);
		if (delta) {
			bytes_read = delta->bytes_read - track->bytes_read;
			bytes_written = delta->bytes_written -
				track->bytes_written;
		}
		printf("I/O read: %lluMB, write: %lluMB, rate: %.2fMB/s\n",
		       mbytes(bytes_read), mbytes(bytes_written),
		       (double)mbytes(bytes_read + bytes_written) /
		       timeval_subtract(&time_end, &track->time_start));
	}
}
Exemplo n.º 2
0
Arquivo: mem.c Projeto: junkoda/fs
void* mem_use_from_zero(Mem* const mem, size_t size)
{
  size= size_align(size); 

  if(size > mem->size_alloc)
    msg_abort("Error: Unable to use %lu MB in Mem %s (only %lu MB allocated)\n",
	      mbytes(size), mem->name, mbytes(mem->size_alloc));

  mem->size_using= size;
  return mem->buf;
}
Exemplo n.º 3
0
void o2fsck_print_resource_track(char *pass, o2fsck_state *ost,
                                 struct o2fsck_resource_track *rt,
                                 io_channel *channel)
{
    struct ocfs2_io_stats *rtio = &rt->rt_io_stats;
    uint64_t total_io, cache_read;
    float rtime_s, utime_s, stime_s, walltime;
    uint32_t rtime_m, utime_m, stime_m;

    if (!ost->ost_show_stats)
        return ;

    if (pass && !ost->ost_show_extended_stats)
        return;

#define split_time(_t, _m, _s)			\
	do {					\
		(_s) = timeval_in_secs(&_t);	\
		(_m) = (_s) / 60;		\
		(_s) -= ((_m) * 60);		\
	} while (0);

    split_time(rt->rt_real_time, rtime_m, rtime_s);
    split_time(rt->rt_user_time, utime_m, utime_s);
    split_time(rt->rt_sys_time, stime_m, stime_s);

    walltime = timeval_in_secs(&rt->rt_real_time) -
               timeval_in_secs(&rt->rt_user_time);

    /* TODO: Investigate why user time is sometimes > wall time*/
    if (walltime < 0)
        walltime = 0;

    cache_read = (uint64_t)rtio->is_cache_hits * io_get_blksize(channel);
    total_io = rtio->is_bytes_read + rtio->is_bytes_written;

    if (!pass)
        printf("  Cache size: %luMB\n",
               mbytes(io_get_cache_size(channel)));

    printf("  I/O read disk/cache: %"PRIu64"MB / %"PRIu64"MB, "
           "write: %"PRIu64"MB, rate: %.2fMB/s\n",
           mbytes(rtio->is_bytes_read),
           mbytes(cache_read), mbytes(rtio->is_bytes_written),
           (double)(mbytes(total_io) / walltime));

    printf("  Times real: %dm%.3fs, user: %dm%.3fs, sys: %dm%.3fs\n",
           rtime_m, rtime_s, utime_m, utime_s, stime_m, stime_s);
}
Exemplo n.º 4
0
Arquivo: mem.c Projeto: junkoda/fs
void* mem_use_remaining(Mem* const mem, size_t size)
{
  size= size_align(size);

  //printf("debug %lu %lu\n", mem->size_using, mem->size_alloc);
  
  if(size + mem->size_using > mem->size_alloc)
    msg_abort("Error: Unable to use %lu MB in Mem %s; %lu MB allocated, "
	      "%lu remaining.\n",
	      mbytes(size), mem->name, mbytes(mem->size_alloc),
	      mbytes(mem->size_alloc - mem->size_using));
  
  assert(mem->size_using % sizeof(float) == 0);
  float* p= mem->buf;
  size_t n= mem->size_using / sizeof(float); //printf("n= %lu\n", n);

  mem->size_using += size;
  msg_printf(msg_verbose, "Using %lu of %lu in memory %s\n",
	     mem->size_using, mem->size_alloc, mem->name);


  return p+n;
}
Exemplo n.º 5
0
void print_resource_track(e2fsck_t ctx, const char *desc,
			  struct resource_track *track, io_channel channel)
{
#ifdef HAVE_GETRUSAGE
	struct rusage r;
#endif
#ifdef HAVE_MALLINFO
	struct mallinfo	malloc_info;
#endif
	struct timeval time_end;

	if ((desc && !(ctx->options & E2F_OPT_TIME2)) ||
	    (!desc && !(ctx->options & E2F_OPT_TIME)))
		return;

	e2fsck_clear_progbar(ctx);
	gettimeofday(&time_end, 0);

	if (desc)
		log_out(ctx, "%s: ", desc);

#ifdef HAVE_MALLINFO
#define kbytes(x)	(((unsigned long)(x) + 1023) / 1024)

	malloc_info = mallinfo();
	log_out(ctx, _("Memory used: %luk/%luk (%luk/%luk), "),
		kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
		kbytes(malloc_info.uordblks), kbytes(malloc_info.fordblks));
#else
	log_out(ctx, _("Memory used: %lu, "),
		(unsigned long) (((char *) sbrk(0)) -
				 ((char *) track->brk_start)));
#endif
#ifdef HAVE_GETRUSAGE
	getrusage(RUSAGE_SELF, &r);

	log_out(ctx, _("time: %5.2f/%5.2f/%5.2f\n"),
		timeval_subtract(&time_end, &track->time_start),
		timeval_subtract(&r.ru_utime, &track->user_start),
		timeval_subtract(&r.ru_stime, &track->system_start));
#else
	log_out(ctx, _("elapsed time: %6.3f\n"),
		timeval_subtract(&time_end, &track->time_start));
#endif
#define mbytes(x)	(((x) + 1048575) / 1048576)
	if (channel && channel->manager && channel->manager->get_stats) {
		io_stats delta = 0;
		unsigned long long bytes_read = 0;
		unsigned long long bytes_written = 0;

		if (desc)
			log_out(ctx, "%s: ", desc);

		channel->manager->get_stats(channel, &delta);
		if (delta) {
			bytes_read = delta->bytes_read - track->bytes_read;
			bytes_written = delta->bytes_written -
				track->bytes_written;
		}
		log_out(ctx, "I/O read: %lluMB, write: %lluMB, "
			"rate: %.2fMB/s\n",
			mbytes(bytes_read), mbytes(bytes_written),
			(double)mbytes(bytes_read + bytes_written) /
			timeval_subtract(&time_end, &track->time_start));
	}
}