-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Significant performance difference between SQLDelight and C++ on iOS #39
Comments
I'd be curious to know how your benchmarks change with the latest sqliter (present in the 1.5 SQLDelight release), since now it's using K/N cinterop to interop with sqlite3 directly, instead of going through a c++ layer |
i'd also be curious to see this with direct sqliter vs "sqldelight". The last round of changes changed both sqligher's communication (cinterop vs direct C++), and includes significant performance improvements to the sqldelight driver. |
Tried bumping sqldelight and getting this to run, but haven't been able to get it to build, so will have to get to it later. Currently having a weird linker issue. |
Numbers running sqldelight 1.5.0.
So, C++ doing direct sqlite calls compared to Kotlin Native, which has GC, etc, and using SQLDelight, which is sitting some layers above direct sqlite, isn't going to be a great comparison. I think this really either needs to be direct sqliter calls compared to C++ sqlite, or CoreData (or similar) compared to SQLDelight. Also, you probably want to do a few loops and average. |
I added direct kotlin calls for the inserts, just to get a sense: https://github.com/kpgalligan/SQLDelightPerformanceTest Results:
Sqliter vs C++ is 0.26966798305511475 vs 0.19979500770568848, so like 0.270 vs 0.200. That's like 35% slower for Kotlin. That also includes potential time differences in other things. For example, each project name gets created dynamically, and I would imagine Kotlin string interpolation performs worse than C++. I'll probably check those numbers again in the morning, as I expected the sqliter to C++ comparison to be a bit worse. |
Worth mentioning that constant folding for indentation stripping of the string literals is turned on only since Kotlin 1.5+. So if this is benched on Kotlin 1.4, stripping identiation from SQL strings will contribute some visible differences, especially with repeated DML statements. |
Working 1.5 updates this week. SQLDelight should also be going out pretty soon. Will revisit when those release to see if there's any measurable difference, although we probably should have a more comprehensive benchmark. |
@kpgalligan how did you solve iOS build issue? Have failing build after bumping SQLDelight to 1.5.0 |
@kpgalligan Have successfully run your fork on Release config on iPhone SE, getting about 2x speed improvement for |
SQLDelight 1.5.0 has significant native driver improvements. The next version should have a few more (largely coming from @andersio, thanks!), although I would guess not full multiples (but we'll see). As for iOS build issues, I had to hack around for a while to get it to run. I removed Android entirely (not needed), then reran cocoapods, Xcode build, etc. There was no clear "change this" to get it running. |
I replicate here issue from SQLDelight repo as per advise of @AlecStrong, he assumes the issue may have something to do with SQLiter
My test repo
The text was updated successfully, but these errors were encountered: