On 3/25/2015 10:03 AM, Renaud wrote:
I'm new to Racket, and i would like to know why sqlite queries are so slow in
my test program.
This program imports some data from a text file into a simple sqlite DB. It
takes 35s with the INSERT queries and 5-6s without them.
I've done the same thing with other languages, all do far better. For example
with perl the same code runs in 8s with the queries, and 2-3s with them.
I know that startup and regex are (reasonably ?) slower in racket, but queries
seems to be very slow.
Am i doing somethin wrong?
Thanks for your help.
Hi Renaud,
I see that you have wrapped the inserts in an outer transaction - that
already addresses a well known performance issue with batch
inserts/updates. If your version of sqlite has the write ahead log, you
might try enabling that (if it isn't already).
Much of the problem is that sqlite is a "foreign" C library. Racket's
internal data formats [mostly] are not C compatible and so at every
function call, arguments must be translated to C and return data
translated to Racket. This is the "Foreign Function Interface" (FFI).
Perl's internal data formats are C already, and the DBD::SQLite lib has
the sqlite engine embedded into it. Because it is C top to bottom, Perl
has a significant speed advantage when calling sqlite functions.
File access in Racket is slightly slower than in Perl - you saw that
already - but that again is due to FFI (the C system calls). In my
experience Racket's regex is as fast as Perl's.
I think FFI overhead will explain 95+% of the time difference - and
there's not much you can do about it. You could try #lang typed/racket,
but I don't know how easily the db module can be used with it - I have
never tried and some things require a lot of effort to make work in the
typed language ... it's an ongoing project to make everything work smoothly.
You can slightly reduce startup time by compiling the Racket to a
bytecode *.zo file (using raco make). *.zo files will live in a
subdirectory called "compiled/" under the source file directory. Then
start your program with "racket -r <source_file>". Note that you can't
try to run the *.zo file directly - Racket checks the timestamps on the
source and bytecode file and recompiles (in memory, it won't save the
result) if necessary. You can reduce more by linking the program's *.zo
file(s) into an executable (using raco exe) that can be run directly.
This can help significantly with a large program, but it probably won't
make any difference with your tiny one.
George
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.