[sql] SQL "works" but it's too dang slow
This commit is contained in:
parent
c23dbe3e8f
commit
2d10e91f9e
4 changed files with 1218 additions and 452 deletions
|
|
@ -129,14 +129,17 @@ function render_state(state, input_editor) {
|
|||
* otherwise just queue it for submission.
|
||||
*/
|
||||
function post_document(worker, kind, state, document) {
|
||||
console.log("Received document", kind)
|
||||
if (window.localStorage) {
|
||||
window.localStorage.setItem(kind, document);
|
||||
}
|
||||
|
||||
let new_state = {...state};
|
||||
if (new_state.pending) {
|
||||
console.log("Document parked", kind)
|
||||
new_state.next = document;
|
||||
} else {
|
||||
console.log("Document submitted", kind)
|
||||
new_state.pending = document;
|
||||
new_state.next = null;
|
||||
worker.postMessage({kind, data: document});
|
||||
|
|
@ -151,6 +154,7 @@ function post_document(worker, kind, state, document) {
|
|||
function rotate_document(worker, kind, state) {
|
||||
let new_state = {...state, last: state.pending, pending: null};
|
||||
if (new_state.next) {
|
||||
console.log("Rotating document", kind)
|
||||
new_state.pending = new_state.next;
|
||||
new_state.next = null;
|
||||
worker.postMessage({kind, data: new_state.pending});
|
||||
|
|
|
|||
|
|
@ -176,19 +176,21 @@ const pyodide_promise = setup_python();
|
|||
async function load_grammar_module(code) {
|
||||
const pyodide = self.pyodide;
|
||||
|
||||
// console.log("Running...");
|
||||
console.log("eval_grammar: Running");
|
||||
const my_fn = pyodide.globals.get("eval_grammar");
|
||||
my_fn(code);
|
||||
my_fn.destroy();
|
||||
console.log("eval_grammar: Done");
|
||||
}
|
||||
|
||||
async function parse_document(code) {
|
||||
const pyodide = self.pyodide;
|
||||
|
||||
// console.log("Running...");
|
||||
console.log("eval_document: Running");
|
||||
const my_fn = pyodide.globals.get("eval_document");
|
||||
my_fn(code);
|
||||
my_fn.destroy();
|
||||
console.log("eval_document: Done");
|
||||
}
|
||||
|
||||
self.onmessage = async function(event) {
|
||||
|
|
@ -197,8 +199,10 @@ self.onmessage = async function(event) {
|
|||
try {
|
||||
const { kind, data } = event.data;
|
||||
if (kind === "grammar") {
|
||||
console.log("Worker received grammar")
|
||||
await load_grammar_module(data);
|
||||
} else if (kind === "input") {
|
||||
console.log("Worker received input")
|
||||
await parse_document(data);
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue