[Monetdb-developers] [Monetdb-checkins] MonetDB5/src/mal mal_profiler.mx, , 1.108, 1.109

Stefan Manegold Stefan.Manegold at cwi.nl
Tue Aug 5 08:09:29 CEST 2008


On Mon, Aug 04, 2008 at 11:46:50PM +0000, Martin Kersten wrote:
> Update of /cvsroot/monetdb/MonetDB5/src/mal
> In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18736
> 
> Modified Files:
> 	mal_profiler.mx 
> Log Message:
> Use a larger type for the diskspace

Martin,

thank for taking care of this one, and my apologies for not having suggested
a mu simple solution in my bug report.

In detail:
I'm in fact afraid that your fix / new solution will not even compile on
Windows. The reason is, that the C function getDiskSpace() internally
(still) collects / calculates the occupied disk space in a variable of type
"lng" --- this is (and was) good & correct, as even on 32-bit systems,
MonetDB's (total) database size can grow beyond 2 GB --- however,
C function getDiskSpace() now returns a "size_t" (while it used to correctly
return the internal "lng"). Not only is "size_t" only 32 bit on 32-bit
systems, while "lng" is 64-bit also on 32-bit systems, but it is also
unsigned while lng is signed. Hence, the Windows compilers will (at least)
complain about the possible loos of data when implicitly truncating the
64-bit (signed) "lng" to a 32-bit (unsigned) "size_t" in the return
statement of C function getDiskSpace() on 32-bit systems.

Moreover, it is a bit "odd" to use unsigned type "size_t" in the undelying C
function, but signed type "wrd" in the MAL command --- why not also use type
"wrd" in C -- we have it defined (for exacly this reason) as any other
"three-letter-type" we use in GDK ...

In fact, the IMHO correct (and simpler/simplest) solution would have been
to leave the C function getDiskSpace() return a "lng" as it (correctly) used
to do, and simply change to MAL command signature and wrapper to directly
pass this "lng" through as "lng" instead of truncating it (on both 32- &
64-bit systems) to an "int".

Again, my apologies for not explicitly pointing out this simple solution in
my bug report.

Stefan

ps: If you wish, I could take care of fixing this ...

> U mal_profiler.mx
> Index: mal_profiler.mx
> ===================================================================
> RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_profiler.mx,v
> retrieving revision 1.108
> retrieving revision 1.109
> diff -u -d -r1.108 -r1.109
> --- mal_profiler.mx	4 Aug 2008 06:56:27 -0000	1.108
> +++ mal_profiler.mx	4 Aug 2008 23:46:48 -0000	1.109
> @@ -213,7 +213,7 @@
>  mal_export void clearTrace(void);
>  mal_export BAT *getTrace(str ev);
>  
> -mal_export lng getDiskSpace(void);
> +mal_export size_t getDiskSpace(void);
>  #define DEBUG_MAL_PROFILER
>  
>  #endif
> @@ -550,7 +550,7 @@
>  		log("%d,\t", mb->profiler[pc].obytes);
>  	}
>  	if (profileCounter[PROFdisk].status) {
> -		log("%d,\t", getDiskSpace());
> +		log(SZFMT",\t", getDiskSpace());
>  	}
>  	if (profileCounter[PROFaggr].status) 
>  		log2("%d,\t%d,\t", mb->profiler[pc].counter, mb->profiler[pc].clk);
> @@ -950,7 +950,7 @@
>  	TRACE_id_stmt = TRACEcreate("id", "statement", TYPE_int, TYPE_str);
>  	TRACE_id_ibytes = TRACEcreate("id", "ibytes", TYPE_int, TYPE_wrd);
>  	TRACE_id_obytes = TRACEcreate("id", "obytes", TYPE_int, TYPE_wrd);
> -	TRACE_id_diskspace = TRACEcreate("id", "diskspace", TYPE_int, TYPE_lng);
> +	TRACE_id_diskspace = TRACEcreate("id", "diskspace", TYPE_int, TYPE_wrd);
>  	TRACE_init = 1;
>  	mal_unset_lock(mal_contextLock, "trace");
>  }
> @@ -1132,7 +1132,7 @@
>  		BUNins(TRACE_id_obytes, &evnt, &mb->profiler[pc].obytes, FALSE);
>  	}
>  	if (profileCounter[PROFdisk].status) {
> -		lng disk= getDiskSpace();
> +		size_t disk= getDiskSpace();
>  		BUNins(TRACE_id_diskspace, &evnt, &disk, FALSE);
>  	}
>  	eventcounter++;
> @@ -1147,7 +1147,7 @@
>  	if( mb->profiler) return;
>  	mb->profiler = (ProfPtr) GDKzalloc(mb->ssize*sizeof(ProfRecord));
>  }
> -lng
> +size_t
>  getDiskSpace()
>  {
>  	BAT *b;
> 
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Monetdb-checkins mailing list
> Monetdb-checkins at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/monetdb-checkins
> 
> 

-- 
| Dr. Stefan Manegold | mailto:Stefan.Manegold at cwi.nl |
| CWI,  P.O.Box 94079 | http://www.cwi.nl/~manegold/  |
| 1090 GB Amsterdam   | Tel.: +31 (20) 592-4212       |
| The Netherlands     | Fax : +31 (20) 592-4312       |




More information about the developers-list mailing list