Changeset: a7f1b23864a4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a7f1b23864a4 Modified Files: monetdb5/optimizer/opt_garbageCollector.c Branch: Jul2017_1-GC Log Message:
Backing-out changesets aebb813568b4, c68f57e45fe2, d350ab890b8e, 7e644e67e308, which effectively disabled ("early") MAL variable clean-up (garbage collection) between Dec2016 & Jul2017; here: reverting the effects of changeset aebb813568b4 on monetdb5/optimizer/opt_garbageCollector.c (only), i.e., keeping the test(s) that were added by it. diffs (142 lines): diff --git a/monetdb5/optimizer/opt_garbageCollector.c b/monetdb5/optimizer/opt_garbageCollector.c --- a/monetdb5/optimizer/opt_garbageCollector.c +++ b/monetdb5/optimizer/opt_garbageCollector.c @@ -10,46 +10,33 @@ #include "opt_garbageCollector.h" #include "mal_interpreter.h" /* for showErrors() */ #include "mal_builder.h" -#include "mal_function.h" #include "opt_prelude.h" -/* The garbage collector is focused on removing temporary BATs only. - * Leaving some garbage on the stack is an issue. - * - * The end-of-life of a BAT may lay within block bracket. This calls - * for care, as the block may trigger a loop and then the BATs should - * still be there. - * - * The life time of such BATs is forcefully terminated after the block exit. +/* + * Keeping variables around beyond their end-of-life-span + * can be marked with the proper 'keep'. + * Set the program counter to ease profiling */ str OPTgarbageCollectorImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { - int i, j, k, limit, slimit; - InstrPtr p, q, *old; + int i, j, k, n = 0, limit, vlimit, depth=0, slimit; + InstrPtr p, q, *old; int actions = 0; char buf[256]; lng usec = GDKusec(); - int *varlnk, *stmtlnk; (void) pci; (void) cntxt; (void) stk; if ( mb->inlineProp) return 0; - varlnk = (int*) GDKzalloc(mb->vtop * sizeof(int)); - if( varlnk == NULL) - return 0; - stmtlnk = (int*) GDKzalloc(mb->stop * sizeof(int)); - if( stmtlnk == NULL){ - GDKfree(varlnk); - return 0; - } - + + old= mb->stmt; limit = mb->stop; slimit = mb->ssize; - //vlimit = mb->vtop; + vlimit = mb->vtop; // move SQL query definition to the front for event profiling tools p = NULL; @@ -63,15 +50,7 @@ OPTgarbageCollectorImplementation(Client for( ; i > 1; i--) mb->stmt[i] = mb->stmt[i-1]; mb->stmt[1] = p; - actions =1; - } - - // Actual garbage collection stuff - // Construct the linked list of variables based on end-of-scope - setVariableScope(mb); - for( i = 0; i < mb->vtop; i++){ - varlnk[i] = stmtlnk[getEndScope(mb,i)]; - stmtlnk[getEndScope(mb,i)] = i; + setVariableScope(mb); } if ( newMalBlkStmt(mb,mb->ssize) < 0) @@ -81,32 +60,41 @@ OPTgarbageCollectorImplementation(Client for (i = 0; i < limit; i++) { p = old[i]; p->gc &= ~GARBAGECONTROL; - /* Set the program counter to ease profiling */ p->pc = i; if ( p->barrier == RETURNsymbol){ pushInstruction(mb, p); continue; } + if (blockStart(p) ) + depth++; if ( p->token == ENDsymbol) break; pushInstruction(mb, p); - - /* A block exit is never within a parallel block, - * otherwise we could not inject the assignment */ + n = mb->stop-1; + for (j = 0; j < p->argc; j++) { + if (getEndScope(mb,getArg(p,j)) == i && isaBatType(getArgType(mb, p, j)) ){ + setVarEolife(mb,getArg(p,j), n); + p->gc |= GARBAGECONTROL; + } + } if (blockExit(p) ){ - /* force garbage collection of all declared within output block and ending here */ - for( k = stmtlnk[i]; k; k = varlnk[k]) - if( isaBatType(getVarType(mb,k)) ){ - q = newAssignment(mb); - getArg(q,0)= k; - q= pushNil(mb,q, getVarType(mb,k)); - setVarUDFtype(mb,k); - setVarFixed(mb,k); - q->gc |= GARBAGECONTROL; - setVarEolife(mb,k,mb->stop-1); - actions++; + /* force garbage collection of all within upper block */ + depth--; + for (k = 0; k < vlimit; k++) { + if (getBeginScope(mb,k) > 0 && + getEndScope(mb,k) == i && + isaBatType(getVarType(mb,k)) ){ + q= newAssignment(mb); + getArg(q,0) = k; + setVarUDFtype(mb,k); + setVarFixed(mb,k); + q= pushNil(mb,q, getVarType(mb,k)); + q->gc |= GARBAGECONTROL; + setVarEolife(mb,k,mb->stop-1); + actions++; + } } } } @@ -119,8 +107,6 @@ OPTgarbageCollectorImplementation(Client if (old[i]) freeInstruction(old[i]); getInstrPtr(mb,0)->gc |= GARBAGECONTROL; - GDKfree(varlnk); - GDKfree(stmtlnk); GDKfree(old); #ifdef DEBUG_OPT_GARBAGE { int k; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list