Opportunities for performance optimization #77
krishvishal
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
You cannot easily compare Another way to avoid (some) allocations would be #33: almost no |
Beta Was this translation helpful? Give feedback.
1 reply
-
https://github.com/apache/datafusion-sqlparser-rs/blob/main/Cargo.toml doesn't seem to use any specific allocator. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I've been going through SQLite source code and docs, and have compared it with
lemon-rs
implementation. I want to get your thoughts on my ideas.SQLite uses
lookaside buffers
to allocate many small objects such as parse tree nodes in them, avoiding many calls tomalloc
andfree
. There are many calls to the functionsqlite3DbMallocRaw
in many objects' initialization.Currently the
enum YYMINORTYPE
has many complex variants inside it and also a few heap allocated objects as well. Due to this all variants in the enum smaller variants will also occupy size of the largest variant. One optimization could be split theenum
intoSmallYYMINORTYPE
andBigYYMINORTYPE
and group the variants appropriately. This article goes into a deeper discussion on this issue.I propose that we use an arena allocator like
bumpalo
to ameliorate the cost of heap allocs. This will also increase cache locality because all the objects are allocated in a contiguous region and also reduces the calls to malloc.I was thinking of an API like the following
We will use the bump allocator to allocate short lived but large objects and this will also allocate sufficiently large memory in the beginning of the parsing and free all at once at the end.
Beta Was this translation helpful? Give feedback.
All reactions