I have a Haskell program that inserts data into an SQLite file. This program runs fairly slowly, it processes ~3900 rows in ~3 seconds.
I have also written a Python counterpart, and it processes the same dataset in ~0.16 seconds, or about 18 times faster.
After a lot of experiments, I simplified the core part of the program to the following function, which isolates the other factors by only using necessary functions provided by the library:
add stmt time stock = do {-# SCC bind #-} bind stmt $ toFields time stock
{-# SCC step #-} stepNoCB stmt
{-# SCC reset #-} reset stmt
The profile shows that stepNoCB consumes most of the time:
I have a Haskell program that inserts data into an SQLite file. This program runs fairly slowly, it processes ~3900 rows in ~3 seconds.
I have also written a Python counterpart, and it processes the same dataset in ~0.16 seconds, or about 18 times faster.
After a lot of experiments, I simplified the core part of the program to the following function, which isolates the other factors by only using necessary functions provided by the library:
The profile shows that
stepNoCB
consumes most of the time:I checked the definition of
stepNoCB
and it is merely a thin wrapper around an FFI call:The system is macOS Mojave 10.14.6. Does anyone have any idea about why it is slow? Thanks.