On Thu, Dec 6, 2012 at 12:14 AM, Keith Chew <keith.c...@gmail.com> wrote:
> On Thu, Dec 6, 2012 at 3:52 PM, Keith Chew <keith.c...@gmail.com> wrote: > > I am guess it may have something to do with the locking of the files. > > sqlite could be getting blocked by the filesystem when trying to > > obtain the lock before writing to the file... > > This is a stab in the dark... I had a look at the sqlite code, and > noticed that the file lock is acquired using fcntl(F_SETLK). So, when > kjournald wants to flush the data to disk, and sqlite wants to write > to the file at the same time, I guess there will be contention, and > sqlite can only get the lock when the file is free. This explains the > latencies that I am seeing being consistent with the ext3 journal's > parameters. Eg increase commit time removes the contention (thus 0ms > between commits), removing write-cache, disabling barriers all affect > the latency accordingly. > > So, if this is the case, how do I get around it? > Specify "unix-none" at the VFS in the 4th parameter to sqlite3_open_v2(). (Or you can use URI pathnames and add the vfs=unix-none query parameter.) This will load a version of the backend that never does any file locking. Does that make your problem go away? If that does cure your latencies, it also adds another problem, in that it does nothing to prevent two or more processes, or even two threads within the same process, from trying to use the database at the same time and tripping over one another. So this solution will only work if you can absolutely guarantee that nobody will ever fire up an "sqlite3" shell on your database file at the same time you application is using it. > > Regards > Keith > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users