Changeset: 6e51cc73a156 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6e51cc73a156
Modified Files:
monetdb5/modules/mal/mosaic.c
monetdb5/modules/mal/mosaic.h
sql/backends/monet5/sql.mal
sql/backends/monet5/sql_mosaic.c
sql/scripts/76_compression.sql
Branch: mosaic
Log Message:
Collect ms timing during analysis
diffs (170 lines):
diff --git a/monetdb5/modules/mal/mosaic.c b/monetdb5/modules/mal/mosaic.c
--- a/monetdb5/modules/mal/mosaic.c
+++ b/monetdb5/modules/mal/mosaic.c
@@ -1522,7 +1522,7 @@ MOSanalyseInternal(Client cntxt, int thr
#define CANDIDATES 256 /* all three combinations */
void
-MOSanalyseReport(Client cntxt, BAT *b, BAT *btech, BAT *boutput, BAT *bratio,
str compressions)
+MOSanalyseReport(Client cntxt, BAT *b, BAT *btech, BAT *boutput, BAT *bratio,
BAT *brun, str compressions)
{
int i,j,k,cases, bit=1, ret, bid= b->batCacheid;
BUN cnt= BATcount(b);
@@ -1531,6 +1531,7 @@ MOSanalyseReport(Client cntxt, BAT *b, B
int pattern[CANDIDATES];
char technique[CANDIDATES]={0}, *t = technique;
dbl xf[CANDIDATES], ratio;
+ lng clk;
cases = makepatterns(pattern,CANDIDATES, compressions);
task = (MOStask) GDKzalloc(sizeof(*task));
@@ -1550,7 +1551,9 @@ MOSanalyseReport(Client cntxt, BAT *b, B
task->factor[j]= 0.0;
bit *=2;
}
+ clk = GDKms();
MOScompressInternal(cntxt, &ret, &bid, task, 0, 0);
+ clk = GDKms() - clk;
// analyse result to detect a new combination
for(k=0, j=0, bit=1; j < MOSAIC_METHODS-1; j++){
@@ -1579,6 +1582,7 @@ MOSanalyseReport(Client cntxt, BAT *b, B
if( task->xsize)
ratio = (input + 0.0)/task->xsize;
BUNappend(bratio,&ratio,FALSE);
+ BUNappend(brun,&clk,FALSE);
// get rid of temporary compressed BAT
if( ret != bid)
diff --git a/monetdb5/modules/mal/mosaic.h b/monetdb5/modules/mal/mosaic.h
--- a/monetdb5/modules/mal/mosaic.h
+++ b/monetdb5/modules/mal/mosaic.h
@@ -227,7 +227,7 @@ mosaic_export str MOSdump(Client cntxt,
mosaic_export str MOSlayout(Client cntxt, BAT *b, BAT *btech, BAT *bcount, BAT
*binput, BAT *boutput, BAT *bproperties, str compressionscheme);
mosaic_export str MOSsliceInternal(Client cntxt, bat *slices, BUN size, BAT
*b);
mosaic_export int MOSanalyseInternal(Client cntxt, int threshold, MOStask
task, bat bid);
-mosaic_export void MOSanalyseReport(Client cntxt, BAT *b, BAT *btech, BAT
*output, BAT *factor, str compressions);
+mosaic_export void MOSanalyseReport(Client cntxt, BAT *b, BAT *btech, BAT
*output, BAT *factor, BAT *run, str compressions);
mosaic_export str MOSoptimize(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
mosaic_export str MOSslice(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
mosaic_export void MOSblk(MosaicBlk blk);
diff --git a/sql/backends/monet5/sql.mal b/sql/backends/monet5/sql.mal
--- a/sql/backends/monet5/sql.mal
+++ b/sql/backends/monet5/sql.mal
@@ -467,12 +467,6 @@ pattern analyze(minmax:int, sample:lng,
address sql_analyze
comment "Update the database statistics table";
-#pattern mosaic(sch:str, tbl:str):void
-#address sql_mosaic;
-#pattern mosaic(sch:str, tbl:str, col:str):void
-#address sql_mosaic
-#comment "Analyse the data for possible compression effectiveness";
-
pattern storage()(
schema:bat[:oid,:str],
table:bat[:oid,:str],
@@ -511,12 +505,14 @@ comment "Return a table with detailed co
pattern mosaicAnalysis(sch:str,tbl:str,col:str,compression:str)(
technique:bat[:oid,:str],
outputsize:bat[:oid,:lng],
- factor:bat[:oid,:dbl])
+ factor:bat[:oid,:dbl],
+ run:bat[:oid,:lng])
address sql_mosaicAnalysis;
pattern mosaicAnalysis(sch:str,tbl:str,col:str)(
technique:bat[:oid,:str],
outputsize:bat[:oid,:lng],
- factor:bat[:oid,:dbl])
+ factor:bat[:oid,:dbl],
+ run:bat[:oid,:lng])
address sql_mosaicAnalysis
comment "Return a table with compression opportunities for the column";
diff --git a/sql/backends/monet5/sql_mosaic.c b/sql/backends/monet5/sql_mosaic.c
--- a/sql/backends/monet5/sql_mosaic.c
+++ b/sql/backends/monet5/sql_mosaic.c
@@ -139,8 +139,8 @@ sql_mosaicAnalysis(Client cntxt, MalBlkP
sql_trans *tr = m->session->tr;
node *nsch, *ntab, *ncol;
str sch = 0, tbl = 0, col = 0;
- int *tech,*output, *factor;
- BAT *bn, *btech, *boutput, *bfactor;
+ int *tech,*output, *factor, *run;
+ BAT *bn, *btech, *boutput, *bfactor, *brun;
str compressions = NULL;
if (msg != MAL_SUCCEED || (msg = checkSQLContext(cntxt)) != NULL)
@@ -172,12 +172,23 @@ sql_mosaicAnalysis(Client cntxt, MalBlkP
factor = getArgReference_bat(stk, pci, 2);
*factor = bfactor->batCacheid;
- sch = *getArgReference_str(stk, pci, 3);
- tbl = *getArgReference_str(stk, pci, 4);
- col = *getArgReference_str(stk, pci, 5);
- if ( pci->argc == 7){
+ brun = BATnew(TYPE_void, TYPE_lng,0, TRANSIENT);
+ if( brun == NULL){
+ BBPunfix(btech->batCacheid);
+ BBPunfix(boutput->batCacheid);
+ BBPunfix(bfactor->batCacheid);
+ throw(SQL,"mosaicAnalysis", MAL_MALLOC_FAIL);
+ }
+ BATseqbase(brun,0);
+ run = getArgReference_bat(stk, pci, 3);
+ *run = brun->batCacheid;
+
+ sch = *getArgReference_str(stk, pci, 4);
+ tbl = *getArgReference_str(stk, pci, 5);
+ col = *getArgReference_str(stk, pci, 6);
+ if ( pci->argc == 8){
// use a predefined collection of compression schemes.
- compressions = *getArgReference_str(stk,pci,6);
+ compressions = *getArgReference_str(stk,pci,7);
}
#ifdef DEBUG_SQL_MOSAIC
@@ -186,6 +197,7 @@ sql_mosaicAnalysis(Client cntxt, MalBlkP
for (nsch = tr->schemas.set->h; nsch; nsch = nsch->next) {
sql_base *b = nsch->data;
sql_schema *s = (sql_schema *) nsch->data;
+
if (!isalpha((int) b->name[0]))
continue;
if (sch && strcmp(sch, b->name))
@@ -205,7 +217,7 @@ sql_mosaicAnalysis(Client cntxt, MalBlkP
continue;
// perform the analysis
bn =
store_funcs.bind_col(m->session->tr, c, 0);
- MOSanalyseReport(cntxt, bn,
btech, boutput, bfactor, compressions);
+ MOSanalyseReport(cntxt, bn,
btech, boutput, bfactor, brun, compressions);
BBPunfix(bn->batCacheid);
(void) c;
}
@@ -214,5 +226,6 @@ sql_mosaicAnalysis(Client cntxt, MalBlkP
BBPkeepref(*tech);
BBPkeepref(*output);
BBPkeepref(*factor);
+ BBPkeepref(*run);
return MAL_SUCCEED;
}
diff --git a/sql/scripts/76_compression.sql b/sql/scripts/76_compression.sql
--- a/sql/scripts/76_compression.sql
+++ b/sql/scripts/76_compression.sql
@@ -45,12 +45,14 @@ create function mosaic.analysis(sch stri
returns table(
technique string, -- compression techniques being used
outputsize bigint, -- after compression
- factor double -- compression factor
+ factor double, -- compression factor
+ run bigint -- time spent in msec
) external name sql."mosaicAnalysis";
create function mosaic.analysis(sch string, tbl string, col string,
compressions string)
returns table(
technique string, -- compression techniques being used
outputsize bigint, -- after compression
- factor double -- compression factor
+ factor double, -- compression factor
+ run bigint -- time spent in msec
) external name sql."mosaicAnalysis";
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list