Skip to content

Commit 8d5f15a

Browse files
committed
Improve compilation time by disabling inlining instead of enabling outlining. Generate a non-asmjs version with even shorter loading times.
Performance is now very good in both Firefox and Chrome with the asm.js version. With the non-asm version, firefox can take a few hundred ms to execute complex queries
1 parent 1d514c7 commit 8d5f15a

File tree

4 files changed

+141
-135
lines changed

4 files changed

+141
-135
lines changed

GUI/gui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ execBtn.addEventListener("click", execEditorContents, true);
6666

6767
// Performance measurement functions
6868
var tictime;
69-
if (!performance) {performance = {now:Date.now}}
69+
if (!window.performance || !performance.now) {window.performance = {now:Date.now}}
7070
function tic () {tictime = performance.now()}
7171
function toc(msg) {
7272
var dt = performance.now()-tictime;

GUI/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<title>
66
sql.js
77
</title>
8-
<script src="../js/sql.js"></script>
98
<style>
109
.CodeMirror {
1110
border: 1px solid #eee;
@@ -40,7 +39,11 @@
4039
<body>
4140
<h1>Online SQL interpreter</h1>
4241

43-
<br>
42+
<div id="loading">Loading sql.js...</div>
43+
<script src="../js/sql.js"></script>
44+
<script>document.getElementById('loading').style.display='none';</script>
45+
46+
<main>
4447
<label for='commands'>Enter some SQL</label>
4548
<br>
4649

@@ -75,6 +78,7 @@ <h1>Online SQL interpreter</h1>
7578
<div id="error" class="error"></div>
7679
Result:
7780
<pre id="output"></pre>
81+
</main>
7882

7983
<script src="codemirror/mode/sql/sql.js"></script>
8084
<script type="text/javascript" src="gui.js"></script>

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Need $(EMSCRIPTEN), for example run with emmake make
22

33
EMSCRIPTEN?=/usr/bin
4-
EMCC=$(EMSCRIPTEN)/emcc -s RESERVED_FUNCTION_POINTERS=2 -s OUTLINING_LIMIT=5500 --closure 1 -O3
5-
# -s INLINING_LIMIT=0
4+
EMCC=$(EMSCRIPTEN)/emcc -s RESERVED_FUNCTION_POINTERS=2 --closure 1 -O3 -s INLINING_LIMIT=10
65
CC=clang -O2
76
CFLAGS=-DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DISABLE_LFS -DLONGDOUBLE_TYPE=double -DSQLITE_INT64_TYPE="long long int" -DSQLITE_THREADSAFE=0
87
EXPORTED_FUNCTIONS="['_sqlite3_open', '_sqlite3_close', '_sqlite3_exec', '_sqlite3_free', '_sqlite3_column_count', ' _sqlite3_column_type', '_sqlite3_column_text', '_sqlite3_column_double', '_sqlite3_prepare_v2', '_sqlite3_step']"
@@ -11,7 +10,10 @@ EXPORTED_FUNCTIONS="['_sqlite3_open', '_sqlite3_close', '_sqlite3_exec', '_sqlit
1110
all: js/sql.js test/benchmark.js test/benchmark
1211

1312
js/sql.js: c/sqlite3.bc js/pre.js js/post.js
14-
$(EMCC) $(CFLAGS) c/sqlite3.c --pre-js js/pre.js --post-js js/post.js -o js/sql.js -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS)
13+
$(EMCC) -s ASM_JS=1 $(CFLAGS) c/sqlite3.c --pre-js js/pre.js --post-js js/post.js -o js/sql.js -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS)
14+
15+
js/sql-faststart.js: c/sqlite3.bc js/pre.js js/post.js
16+
$(EMCC) -s ASM_JS=2 $(CFLAGS) c/sqlite3.c --pre-js js/pre.js --post-js js/post.js -o js/sql-faststart.js -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS)
1517

1618
c/sqlite3.bc: c/sqlite3.c
1719
# Generate llvm bitcode

0 commit comments

Comments
 (0)