Repository navigation
Conversation
|
No dialect label was applied because the title does not name a SQL dialect. If this change targets one or more dialects, edit the title to |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2729 +/- ##
==========================================
+ Coverage 82.30% 82.38% +0.08%
==========================================
Files 42 42
Lines 35294 35405 +111
Branches 35294 35405 +111
==========================================
+ Hits 29047 29167 +120
+ Misses 2690 2681 -9
Partials 3557 3557 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Dialects: none |
Add a mixed_sql workload with 22 TPC-H files and eight short statements. Measure tokenize_identifiers at lengths 1, 2, 4, 8, 16, 32, 64 and 128. Keep the existing query shape, dialect, spans and output-drop behavior.
Keep the existing character-reading helper with the cursor it operates on and update its callers. Leave its scanning behavior unchanged.
Some token scans collect text in a temporary string, copy it into the string they are building, then discard the temporary. Append directly instead, using the same scanning loop.
a23326b to
dafd04e
Compare
|
Consider that we are targetting a full refactoring of the tokenizer in the next few months, at this time we are primarely focusing on fuzzing-driven bug squashing so that we will be able to tell which errors come from the refactoring and which are just preexisting stuff. I expect that a good refactoring, expecially aiming to go towards copy-less-ness, will be able to achieve much better performance. |
|
If you have time, we would really appreciate any help in the fuzzing/debugging department & reviews in particular. Also, of course, once the time comes, very welcome to help in any tokenizer refactoring. I do agree as it stands it is in an unfortunate shape, mostly it is due to an accomulation of patches. |
|
@LucaCappelletti94 Okay, good to know! I don't think we need this that urgently, and if we do we can use our fork until the refactor comes through. As far as fuzzing etc. are you thinking of validation of the refactor in particular, or the project in general? I am not on Discord any more but I'll try to figure out how to help. |
|
Ah basically there are I believe now 4 different libfuzzer harnesses in the repo. Just pick one that is relevant to the dialect you work on, and start running it. You'll get bugs in no time at all, and gradually we'll get them fixed. Some of the bugs are clearly stuff relative to the tokenization patches, and that is something that as aforementioned will get fixed with a heavy refactoring. Another thing that would be very helpful is reviews. Just pick any PR you believe you are likely familiar or interested in, and provide a review. That'll move things along. |
Some callers of the tokenizer's
peeking_take_whilehelper simply copied the newly-allocatedStringinto an existingString. Refactor it to call a newpeeking_read_whilehelper, and convert 4takecallers toread. This avoids an allocation and extraneous string copy at each callsite.This was motivated by finding one of the converted callers (
tokenize_word) pretty high up when profiling some real workloads. Converting that caller gets most of the improvement in tokenizing time in the added benchmarks, but converting the rest seemed harmless.Add two benchmarks (results from a few runs on a Ryzen 5 3600):
mixed_sql: 22 TPC-H files plus eight short statements. ~9-11% improvement to tokenizing time and ~5% improvement to overall parse time.tokenize_identifiersbenchmark targetingtokenize_word, testing power-of-two identifier lengths from 1 to 128. Pretty contrived, mainly to check this doesn't regress small identifiers. 1-character identifiers showed ~4% reduction in tokenizing time, up to ~14% reduction for 128-character identifiers.