37 karma · joined June 26, 2019
That is, the duckdb-wasm web shell with loaded PSQL extension
Go to https://shell.duckdb.org, and type
FROM 'https://hacker-news.firebaseio.com/v0/item/37663308.json';
Querying hacker news, from a browser tab (passing through a bunch of database and Web technology that make it possible for DuckDB to be executed within a browser tab)
I think I have just found out yet another great DuckDB-weekend project!
- Dominator tree (https://en.wikipedia.org/wiki/Dominator_(graph_theory))
- Single-Connected-Components-Graph
- Deterministic data structures (eg. a set that acts deterministic to the fact that addresses might be somehow randomly assigned, very useful for ensuring reproducibility)
Already cited, but it's clearly among the most elegant:
- union-find (!!!!)
and as a bonus one that is easily overlooked:
-std::deque, that when restricted to push_back() or push_front() guarantees not to ever move objects around.
Here by playing HumanCompiler it should be possible to prove that the if condition never evaluates to true, so removing the if is safe.
This is an example of optimization that PartialExecuter is able to do. Note that some combinations of other optimizations might also be potentially able to get to this result (say adding a tag "is always power of 2", but doing this in a general way it's what PartialExecuter does well).
Somehow similarly, clang might be instructed to enable a check to avoid including printf_float and somehow detect it and exclude it (this is what happens here), but this is hardly generalizable.
Same!
On the second part, I have to do some thinking and coming back, thanks!
Target-wise, all information is kept encoded in the IR, so that part is easier (the only strange thing that might happens is bumping some alignment to 8, but I expect every target to be able to handle the prescribed IR alignemtn)
I also believe it would be cool to upstream this, we will have to sit down and do some planning.
Compilation time could improve (I was actually working on this today), but it's already in line with other optimizations, taking < 10% of the time spent doing optimizations on a big codebase we use as benchmark.
Currently it's applied to all functions, since runtime it's anyhow somehow linear in the number of Instructions a Function has, but possibly in more costly versions of this (that we have on paper but yet to implement) some logic to filter functions in advance could be used.
There are some general gains to be had with this optimization, and probably the same ideas were already around for a while, but putting together in this way was helped by thinking about WebAssembly specific constraints.
In general the whole concept behind Cheerp (C++ to WebAssembly + JavaScript compiler) is doing as much as possible at the LLVM IR level, JavaScript concept included, since it's easier and more powerful to do code transformation there.
function add() {
var i = 0, d0 = 0.0, d1 = 0.0, d2=0.0, d3=0.0;
for (i = 0|0; i < N; i = ((i|0)+(4|0))|0) {
d0 = a[i^0] + b[i^0];
d1 = a[i^1] + b[i^1];
d2 = a[i^2] + b[i^2];
d3 = a[i^3] + b[i^3];
c[i^0] = d0;
c[i^1] = d1;
c[i^2] = d2;
c[i^3] = d3;
}
}
Could you try it & possibly adding this (possibly instead of the slower unrolling options?)I did got to the page you linked, but also there is no actual "proof".