Geeting degrade while using multhi threading

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Geeting degrade while using multhi threading

Senthil Kumar Chellappan
Hi All,

  I am using the SQLite version 3.20 .

I have created the inmemory database with shared cachemode as shown below

"FullUri=file::memory:?cache=shared;PRAGMA locking_mode = NORMAL;Read
Only=True;Pooling=True;Max Pool Size=120"

I am using only select operation ,but it gets degreaded(response time) when
i calls the API thur multi threading

If i call same API for single thread sequentialy ,it works fine,

Please help me to solve the degraded response time when i use the multi
threading.


Thanks & Regards,
Senthil Kumaar C
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Geeting degrade while using multhi threading

Jens Alfke-2


> On Sep 4, 2017, at 7:22 AM, Senthil Kumar Chellappan <[hidden email]> wrote:
>
> I am using only select operation ,but it gets degreaded(response time) when
> i calls the API thur multi threading

Internally SQLite uses locks to serialize calls by multiple threads. If multiple threads are trying to access it at once, that will increase overhead since the locks have to control the access. Usually this isn't noticeable since the overhead for acquiring a single lock is very low, but it depends on how many calls are being made.

You'll need to give more details of what calls you're making, on how many threads, and how many times they're called.

—Jens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Geeting degrade while using multhi threading

Karthi M
HI

    Thanks for the Reply..
    "Internally SQLite uses locks to serialize calls by multiple threads."
if this is case then how can we achieve concurrency?
    we are using 50 threads and 1500 time it is called for 30min. At
initial stage it works fine at some point of time the performance degrades.
   Is there any way  to achieve maximum concurrency? Please suggest...

Thanks
Karthi M



On Wed, Sep 6, 2017 at 8:53 PM, Jens Alfke <[hidden email]> wrote:

>
>
> > On Sep 4, 2017, at 7:22 AM, Senthil Kumar Chellappan
> <[hidden email]> wrote:
> >
> > I am using only select operation ,but it gets degreaded(response time)
> when
> > i calls the API thur multi threading
>
> Internally SQLite uses locks to serialize calls by multiple threads. If
> multiple threads are trying to access it at once, that will increase
> overhead since the locks have to control the access. Usually this isn't
> noticeable since the overhead for acquiring a single lock is very low, but
> it depends on how many calls are being made.
>
> You'll need to give more details of what calls you're making, on how many
> threads, and how many times they're called.
>
> —Jens
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Geeting degrade while using multhi threading

Simon Slavin-3


On 8 Sep 2017, at 10:23am, Karthi M <[hidden email]> wrote:

>    Thanks for the Reply..
>    "Internally SQLite uses locks to serialize calls by multiple threads."
> if this is case then how can we achieve concurrency?
>    we are using 50 threads and 1500 time it is called for 30min.

When making a change (COMMIT) SQLite locks the entire database.  But not for very long.  Perhaps a few milliseconds.  If all 50 threads are trying to write at the same time you may have problems.  If just a few of them write each minute then you should be okay.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Geeting degrade while using multhi threading

Clemens Ladisch
In reply to this post by Karthi M
Karthi M wrote:
>     "Internally SQLite uses locks to serialize calls by multiple threads."
> if this is case then how can we achieve concurrency?

In general, SQLite serializes accesses to the same connection object.

To get higher concurrency (for reading), use multiple connections.


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users