Changeset: eff8e4bd9f16 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=eff8e4bd9f16 Modified Files: MonetDB/src/gdk/gdk_relop.mx MonetDB/src/gdk/gdk_setop.mx Branch: Oct2010 Log Message:
use MMAP_WILLNEED only if random access is not too scattered, i.e., only if number of lookups is more than 10% of inner BAT This exhaustively applies Niels changeset 4bc9c5336c6f (http://dev.monetdb.org/hg/MonetDB/rev/4bc9c5336c6f) to all (random-order) positional-, binary-search-, & hash- lookups in GDK that currently use BATaccess(MMAP_WILLNEED). diffs (truncated from 314 to 300 lines): diff -r 474431818a18 -r eff8e4bd9f16 MonetDB/src/gdk/gdk_relop.mx --- a/MonetDB/src/gdk/gdk_relop.mx Tue Oct 19 18:21:30 2010 +0200 +++ b/MonetDB/src/gdk/gdk_relop.mx Tue Oct 19 18:47:19 2010 +0200 @@ -288,7 +288,10 @@ return NULL; } BATaccessBegin(l, USE_HEAD | USE_TAIL, MMAP_SEQUENTIAL); - BATaccessBegin(r, USE_HEAD | USE_TAIL, r_scan > 0 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessBegin(r, USE_HEAD | USE_TAIL, r_scan > 0 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); if (bn == NULL) { @:joinbat(JOIN_EQ,mergejoin(l,r,NULL,nil_on_miss,BUN_NONE,NULL),estimate)@ } @@ -366,7 +369,10 @@ /* propagate properties */ bunins_done: BATaccessEnd(l, USE_HEAD | USE_TAIL, MMAP_SEQUENTIAL); - BATaccessEnd(r, USE_HEAD | USE_TAIL, r_scan > 0 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessEnd(r, USE_HEAD | USE_TAIL, r_scan > 0 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); bn->hsorted = BAThordered(l); if (r->hkey) { if (BATcount(bn) == BATcount(l)) { @@ -393,7 +399,10 @@ return bn; bunins_failed: BATaccessEnd(l, USE_HEAD | USE_TAIL, MMAP_SEQUENTIAL); - BATaccessEnd(r, USE_HEAD | USE_TAIL, r_scan > 0 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessEnd(r, USE_HEAD | USE_TAIL, r_scan > 0 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); BBPreclaim(bn); return NULL; } @@ -486,7 +495,10 @@ return NULL; } BATaccessEnd(r, USE_HEAD, MMAP_SEQUENTIAL); - BATaccessBegin(r, USE_HEAD | USE_TAIL | USE_HHASH, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessBegin(r, USE_HEAD | USE_TAIL | USE_HHASH, MMAP_WILLNEED); switch (any = ATOMstorage(l->ttype)) { #ifndef NOEXPAND_CHR case TYPE_chr: @@ -518,7 +530,10 @@ default: @:hashjoin(atom,any,tail,any)@ } - BATaccessEnd(r, USE_HEAD | USE_TAIL | USE_HHASH, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessEnd(r, USE_HEAD | USE_TAIL | USE_HHASH, MMAP_WILLNEED); /* propagate alignment info */ bn->hsorted = BAThordered(l); @@ -677,7 +692,10 @@ ALGODEBUG THRprintf(GDKout, "#BATfetchjoin: defaultfetchjoin(@1,@2);\n"); BATaccessBegin(l, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL); - BATaccessBegin(r, USE_TAIL, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessBegin(r, USE_TAIL, MMAP_WILLNEED); /*BATaccessBegin(bn, MMAP_SEQUENTIAL);*/ BATloop(l, l_cur, l_end) { yy = (BUN) (offset + *(oid *) BUNtail(li, l_cur)); @@ -692,7 +710,10 @@ goto bunins_failed; bunins_failed: BATaccessEnd(l, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL); - BATaccessEnd(r, USE_TAIL, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessEnd(r, USE_TAIL, MMAP_WILLNEED); /*BATaccessEnd(bn, MMAP_SEQUENTIAL);*/ BATsetcount(bn, dst); if (!ret) @@ -809,7 +830,9 @@ @= defaultvoidfetchjoin ALGODEBUG THRprintf(GDKout, "#BATfetchjoin: defaultvoidfetchjoin(@1);\n"); BATaccessBegin(l, USE_TAIL, MMAP_SEQUENTIAL); - if (BATcount(l) > (BATcount(r)/10)) + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) BATaccessBegin(r, USE_TAIL, MMAP_WILLNEED); BATloop(l, l_cur, l_end) { BUN _yy = (BUN) (offset + * (oid *) BUNtloc(li, l_cur)); @@ -825,7 +848,9 @@ dst++; } BATaccessEnd(l, USE_TAIL, MMAP_SEQUENTIAL); - if (BATcount(l) > (BATcount(r)/10)) + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) BATaccessEnd(r, USE_TAIL, MMAP_WILLNEED); if (nondense) { BATiter bni; @@ -1518,7 +1543,10 @@ BUN p, q; @4 - BATaccessBegin(r, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessBegin(r, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); BATloop(l, p, q) { BUN i = 0; @@ -1532,7 +1560,10 @@ @3(bn, s, BUNhead(li, p), nilt); } } - BATaccessEnd(r, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessEnd(r, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); } break; @ @@ -1596,7 +1627,10 @@ bit nonil = TRUE; BUN p, q, w, s = BUNfirst(bn); - BATaccessBegin(r, USE_TAIL, BATtordered(l) & 1 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessBegin(r, USE_TAIL, BATtordered(l) & 1 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); BATloop(l, p, q) { oid v = *(oid *) BUNtail(li, p); ptr t = nilt; @@ -1610,7 +1644,10 @@ bunfastins_nocheck(bn, s, BUNhead(li, p), t, Hsize(bn), Tsize(bn)); s++; } - BATaccessEnd(r, USE_TAIL, BATtordered(l) & 1 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessEnd(r, USE_TAIL, BATtordered(l) & 1 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); bn->tsorted = ((BATtordered(l) & BATtordered(r) & 1) && nonil) ? GDK_SORTED : 0; } else { /* hash based algorithm (default) */ @@ -2010,7 +2047,10 @@ if (cpy == l) { BATaccessBegin(l, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL); - BATaccessBegin(r, USE_HEAD, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessBegin(r, USE_HEAD, MMAP_WILLNEED); BATloop(l, lp, lq) { ptr v = b...@1(li, lp); @@ -2019,10 +2059,16 @@ } } BATaccessEnd(l, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL); - BATaccessEnd(r, USE_HEAD, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessEnd(r, USE_HEAD, MMAP_WILLNEED); } else { BATaccessBegin(l, USE_HEAD, MMAP_SEQUENTIAL); - BATaccessBegin(r, USE_HEAD|USE_TAIL, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessBegin(r, USE_HEAD|USE_TAIL, MMAP_WILLNEED); BATloop(l, lp, lq) { BUN rp, rq; ptr v = b...@1(li, lp); @@ -2034,7 +2080,10 @@ } } BATaccessEnd(l, USE_HEAD, MMAP_SEQUENTIAL); - BATaccessEnd(r, USE_HEAD|USE_TAIL, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessEnd(r, USE_HEAD|USE_TAIL, MMAP_WILLNEED); } } break; @@ -2139,7 +2188,10 @@ if (merge) { ALGODEBUG THRprintf(GDKout, "#BATrevsemijoin: merge\n"); BATaccessBegin(r, USE_HEAD, MMAP_SEQUENTIAL); - BATaccessBegin(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(r) > BATcount(l)/10) + BATaccessBegin(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); BATloop(r, rp, rq) { v = b...@3(ri, rp); @@ -2152,11 +2204,17 @@ } } BATaccessEnd(r, USE_HEAD, MMAP_SEQUENTIAL); - BATaccessEnd(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(r) > BATcount(l)/10) + BATaccessEnd(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); } else if (rdoubles) { ALGODEBUG THRprintf(GDKout, "#BATrevsemijoin: rdoubles\n"); BATaccessBegin(r, USE_HEAD, MMAP_SEQUENTIAL); - BATaccessBegin(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(r) > BATcount(l)/10) + BATaccessBegin(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); BATloop(r, rp, rq) { v = b...@3(ri, rp); @@ -2170,10 +2228,16 @@ } } BATaccessEnd(r, USE_HEAD, MMAP_SEQUENTIAL); - BATaccessEnd(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(r) > BATcount(l)/10) + BATaccessEnd(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); } else { BATaccessBegin(r, USE_HEAD, MMAP_SEQUENTIAL); - BATaccessBegin(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(r) > BATcount(l)/10) + BATaccessBegin(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); BATloop(r, rp, rq) { v = b...@3(ri, rp); if (!...@1_eq(v, nil, @4)) { @@ -2182,7 +2246,10 @@ } } BATaccessEnd(r, USE_HEAD, MMAP_SEQUENTIAL); - BATaccessEnd(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(r) > BATcount(l)/10) + BATaccessEnd(l, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); } } break; @@ -2305,7 +2372,10 @@ /* iterate l; positional fetch in r */ BATaccessBegin(l, USE_HEAD | USE_TAIL, MMAP_SEQUENTIAL); - BATaccessBegin(r, USE_HEAD | USE_TAIL, BAThordered(l) & 1 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessBegin(r, USE_HEAD | USE_TAIL, BAThordered(l) & 1 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); BATloop(l, l_cur, l_end) { yy = (BUN) (offset + *(oid *) BUNhloc(li, l_cur)); if (yy < base || yy >= end) { @@ -2319,7 +2389,10 @@ } } BATaccessEnd(l, USE_HEAD | USE_TAIL, MMAP_SEQUENTIAL); - BATaccessEnd(r, USE_HEAD | USE_TAIL, BAThordered(l) & 1 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessEnd(r, USE_HEAD | USE_TAIL, BAThordered(l) & 1 ? MMAP_SEQUENTIAL : MMAP_WILLNEED); /* property propagation */ bn->hsorted = (BAThordered(l) & BAThordered(r) & 1 ? GDK_SORTED : FALSE); diff -r 474431818a18 -r eff8e4bd9f16 MonetDB/src/gdk/gdk_setop.mx --- a/MonetDB/src/gdk/gdk_setop.mx Tue Oct 19 18:21:30 2010 +0200 +++ b/MonetDB/src/gdk/gdk_setop.mx Tue Oct 19 18:47:19 2010 +0200 @@ -486,7 +486,10 @@ goto bunins_failed; } BATaccessEnd(r, USE_HEAD, MMAP_SEQUENTIAL); - BATaccessBegin(r, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); + /* use MMAP_WILLNEED only if random access is not too scattered, * + * i.e., only if number of lookups is more than 10% of inner BAT */ + if (BATcount(l) > BATcount(r)/10) + BATaccessBegin(r, USE_HEAD|USE_TAIL|USE_HHASH, MMAP_WILLNEED); BATaccessBegin(l, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL); _______________________________________________ Checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
