switch sqlite3 to single-threaded mode

Looking at 'perf top' of osmo-msc under load shows that there's a
significant amount of time spent in terms of locking (mutex,...)
which is useless as osmo-msc is a single-threaded application.

Unfortunately libdbi doesn't provide a mechanism to perform
sqlite3_config(), so we have to do it directly here, introducing an
explicit build-time dependency (and linkage) to libsqlite3.

Related: OS#5559
Change-Id: I5bbea90d28b6d73b64b9e5124ff59304b90a8a75
changes/08/28108/4
Harald Welte 5 months ago
parent 2db1966e25
commit 467fc5728d
  1. 1
      configure.ac
  2. 1
      contrib/osmo-msc.spec.in
  3. 1
      debian/control
  4. 3
      src/libmsc/db.c
  5. 2
      src/osmo-msc/Makefile.am
  6. 2
      tests/db_sms/Makefile.am
  7. 2
      tests/msc_vlr/Makefile.am
  8. 2
      tests/sms_queue/Makefile.am

@ -36,6 +36,7 @@ if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
fi
PKG_PROG_PKG_CONFIG([0.20])
PKG_CHECK_MODULES(LIBSQLITE3, sqlite3)
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.6.0)
PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.6.0)
PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.6.0)

@ -34,6 +34,7 @@ BuildRequires: systemd-rpm-macros
%endif
BuildRequires: pkgconfig >= 0.20
BuildRequires: pkgconfig(dbi)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(libcrypto) >= 0.9.5
BuildRequires: pkgconfig(libosmo-gsup-client) >= 1.4.0
BuildRequires: pkgconfig(libosmo-mgcp-client) >= 1.9.0

1
debian/control vendored

@ -11,6 +11,7 @@ Build-Depends: debhelper (>=9),
pkg-config,
libdbi-dev,
libdbd-sqlite3,
libsqlite3-dev,
libsctp-dev,
libtalloc-dev,
libsmpp34-dev (>= 1.14.0),

@ -28,6 +28,7 @@
#include <string.h>
#include <errno.h>
#include <time.h>
#include <sqlite3.h>
#include <dbi/dbi.h>
#include <osmocom/msc/gsm_data.h>
@ -637,6 +638,8 @@ static int db_configure(void)
int db_init(const char *name)
{
sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
dbi_initialize_r(NULL, &inst);
LOGP(DDB, LOGL_NOTICE, "Init database connection to '%s' using %s\n",

@ -19,6 +19,7 @@ AM_CFLAGS = \
$(LIBOSMOSIGTRAN_CFLAGS) \
$(LIBOSMOMGCPCLIENT_CFLAGS) \
$(LIBOSMOGSUPCLIENT_CFLAGS) \
$(LIBSQLITE3_CFLAGS) \
$(NULL)
AM_LDFLAGS = \
@ -48,6 +49,7 @@ osmo_msc_LDADD = \
$(LIBOSMOSIGTRAN_LIBS) \
$(LIBOSMOMGCPCLIENT_LIBS) \
$(LIBOSMOGSUPCLIENT_LIBS) \
$(LIBSQLITE3_LIBS) \
-ldbi \
-lsctp \
$(NULL)

@ -17,6 +17,7 @@ AM_CFLAGS = \
$(LIBSMPP34_CFLAGS) \
$(LIBOSMOMGCPCLIENT_CFLAGS) \
$(LIBOSMOGSUPCLIENT_CFLAGS) \
$(LIBSQLITE3_CFLAGS) \
$(NULL)
EXTRA_DIST = \
@ -46,6 +47,7 @@ db_sms_test_LDADD = \
$(LIBASN1C_LIBS) \
$(LIBOSMOMGCPCLIENT_LIBS) \
$(LIBOSMOGSUPCLIENT_LIBS) \
$(LIBSQLITE3_LIBS) \
$(LIBRARY_GSM) \
-ldbi \
$(NULL)

@ -17,6 +17,7 @@ AM_CFLAGS = \
$(LIBASN1C_CFLAGS) \
$(LIBOSMOMGCPCLIENT_CFLAGS) \
$(LIBOSMOGSUPCLIENT_CFLAGS) \
$(LIBSQLITE3_CFLAGS) \
$(NULL)
AM_LDFLAGS = \
@ -41,6 +42,7 @@ LDADD = \
$(LIBASN1C_LIBS) \
$(LIBOSMOMGCPCLIENT_LIBS) \
$(LIBOSMOGSUPCLIENT_LIBS) \
$(LIBSQLITE3_LIBS) \
$(LIBRARY_GSM) \
-ldbi \
$(NULL)

@ -15,6 +15,7 @@ AM_CFLAGS = \
$(LIBASN1C_CFLAGS) \
$(LIBOSMOMGCPCLIENT_CFLAGS) \
$(LIBOSMOGSUPCLIENT_CFLAGS) \
$(LIBSQLITE3_CFLAGS) \
$(NULL)
EXTRA_DIST = \
@ -43,6 +44,7 @@ sms_queue_test_LDADD = \
$(LIBASN1C_LIBS) \
$(LIBOSMOMGCPCLIENT_LIBS) \
$(LIBOSMOGSUPCLIENT_LIBS) \
$(LIBSQLITE3_LIBS) \
$(LIBRARY_GSM) \
-ldbi \
$(NULL)

Loading…
Cancel
Save