I'm wondering if one could write this bytecode directly (or with a higher level imperative language) instead of SQL. Often, the programmer knows exactly which index lookups need to happen in a loop, while it seems like a burden to express that in SQL. This might also be an opportunity to create a different type safe dsl for database access.
Why SQLite Uses Bytecode
81–90 of 231 posts
Re: Why SQLite Uses Bytecode
#82Re: Why SQLite Uses Bytecode
#83I recently implemented my own expression evaluator in java for in-memory data frames, and once you think about doing that deeply, you very quickly understand the need for bytecode. If you directly evaluate the expression using a tree representation, you basically have to do a whole lot of branching (either via switch statements or polymorphism) for every single line of useful operation. Yes, the branch predictor kick…
Bytecode will only impact packing, so more efficient ram, cache and cpu wise. But I don't understand how it would help with branching? You still have to make the same decisions? As in the bytecode executor still needs to do differnt things based on the op code, its not in hardware.
A tree based evaluator has to do something like -
for (int i = 0; i
whereas a bytecode based evaluator is able to run something equivalent to - for (int i = 0; i Re: Why SQLite Uses Bytecode
#84Running bytecode is much lower latency than compiling into native code. If you're not bottlenecked by running the bytecode (as opposed to memory or disk speed), you don't really have to JIT it any further into native code.
Re: Why SQLite Uses Bytecode
#85Re: Why SQLite Uses Bytecode
#86Earlier quoted context omitted.
There are three approaches: 1. interpreted code 2. compiled then interpreted bytecode 3. compiled machine code The further up, the simpler. The further down, the faster.
4. lots of small building blocks of static machine code precompiled/shipped with DB software binary, later iterated & looped through based on the query plan the optimizer came up with. Oracle does this with their columnar/vector/SIMD processing In-Memory Database option (it's not like LLVM as it doesn't compile/link/rearrange the existing binary building blocks, just jumps & loops through the existing ones in the req…
Re: Why SQLite Uses Bytecode
#87Re: Why SQLite Uses Bytecode
#88Earlier quoted context omitted.
I am amazed that the author (D Richard Hipp) made an effort to find and respond to a tweet that was (1) not directed/"@tted" at him or (2) written in his native language of English (original tweet is in Japanese[1]). [1] https://twitter.com/gorilla0513/status/1784623660193677762
Side note, but I'm amazed that anyone that is not a journalist or a politician still actively uses X/twitter. Everyone I used to follow has stopped.
Re: Why SQLite Uses Bytecode
#89Earlier quoted context omitted.
Do clients typically communicate with the server in some AST representation instead of, well, SQL? I'd be surprised if that much parsing/planning happens on the client.
Since prepared statements are created by the driver, I was assuming this was the case - but I might be completely wrong here.
Re: Why SQLite Uses Bytecode
#90Looks like SQLite could benefit from copy-and-patch JIT compiler.
I think that would make it cross a border where ‘Lite’ no longer applies. It also would be quite a challenge given their long-term-support statement ( https://www.sqlite.org/lts.html ): “Cross-platform Code → SQLite runs on any platform with an 8-bit byte, two's complement 32-bit and 64-bit integers, and a C compiler. It is actively tested on all currently popular CPUs and operating systems. The extreme portability o…