[sqlite] Serialized access faster than multithreaded?

2012-05-03 Thread Marco Era
Hi there,

I've been using sqlite for a few years now and it worked fine in my experience.

Now that I have some time, I'm stress testing it to see how much I can get from 
it; what I want to check is its performance in a multithreading environment.

To my surprise, it seems that serialized access to the database (which is the 
default in the source code for Windows) is ~20% faster than multithreading (no 
matter how the shared cache option is set). 



My test program creates 4 threads that do some work on a single table of a 
~200MB WAL-based database. 

First two threads do only SELECTs; third thread does UPDATEs; fourth thread 
does INSERTs; the SQL commands are not wrapped into explicit transactions.


Serialized test (SQLITE_THREADSAFE=1):

The main thread opens the database, sets the cache and busy timeout to huge 
values and passes the db descriptor to the threads.


Multithreaded test (SQLITE_THREADSAFE=2):
The main thread creates the other threads and wait; each thread opens its own 
database connection and sets the cache and timeout (using a shared cache 
required some changes to handle the LOCKED return codes, but didn't give better 
results).



Is this the expected behavior or am I missing something?
Thanks in advance.

Marco
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Database corrupted

2010-12-02 Thread Marco Era
Hello,
I'm doing some tests to get the best out of the threading models for sqlite. 
All tests are done on a multicore processor, windows XP; sqlite is working in 
WAL mode.

I've got a database image corrupted when using SQLITE_THREADSAFE=2 and two 
threads, each opening a private connection to the same database. sqlite3* 
pointers are not shared, each thread has his own. 

Compiling with SQLITE_THREADSAFE=1 seems to work well, but I will test it more.

Am is missing something?
Do I have to synchronize the threads?
Thanks in advance.


  
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users