Quantcast

[RFC] Use mutexes by default in db_open()

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[RFC] Use mutexes by default in db_open()

Samba - samba-technical mailing list
Hi!

Is there any reason not to use mutexes by default? Maybe for 4.7?

-slow

db-open-default-mutexes.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [RFC] Use mutexes by default in db_open()

Samba - samba-technical mailing list
On Mon, Apr 24, 2017 at 04:16:45PM +0200, Ralph Böhme via samba-technical wrote:
> Hi!
>
> Is there any reason not to use mutexes by default? Maybe for 4.7?

Wow ! +1 from me - that seems like a no-brainer to me !

Jeremy.

> From 9aff7e4bc481e7b7517cb97149a841de45e68d90 Mon Sep 17 00:00:00 2001
> From: Ralph Boehme <[hidden email]>
> Date: Mon, 24 Apr 2017 16:10:23 +0200
> Subject: [PATCH] s3/dbwrap: enable mutexes by default
>
> For small file copy workloads this makes a huge difference in the number
> of fcntl() syscalls.
>
> Eg copying 10,000 files, without mutexes:
>
> % time     seconds  usecs/call     calls    errors syscall
> ------ ----------- ----------- --------- --------- ----------------
> ...
>  32.16    3.149828           6    498574           fcntl
> ...
>
> Enabling mutexes by setting "dbwrap_tdb_mutexes:* = yes":
>
> % time     seconds  usecs/call     calls    errors syscall
> ------ ----------- ----------- --------- --------- ----------------
> ...
>   7.37    0.577316           7     81998           fcntl
> ...
>
> So 500k vs 80k.
>
> Signed-off-by: Ralph Boehme <[hidden email]>
> ---
>  source3/lib/dbwrap/dbwrap_open.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
> index feb9f5e..5e9a7b0 100644
> --- a/source3/lib/dbwrap/dbwrap_open.c
> +++ b/source3/lib/dbwrap/dbwrap_open.c
> @@ -97,7 +97,7 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
>  
>   if (tdb_flags & TDB_CLEAR_IF_FIRST) {
>   const char *base;
> - bool try_mutex = false;
> + bool try_mutex = true;
>   bool require_mutex = false;
>  
>   base = strrchr_m(name, '/');
> --
> 2.9.3
>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [RFC] Use mutexes by default in db_open()

Samba - samba-technical mailing list
On Mon, Apr 24, 2017 at 10:21:56AM -0700, Jeremy Allison wrote:
> On Mon, Apr 24, 2017 at 04:16:45PM +0200, Ralph Böhme via samba-technical wrote:
> > Hi!
> >
> > Is there any reason not to use mutexes by default? Maybe for 4.7?
>
> Wow ! +1 from me - that seems like a no-brainer to me !

fwiw, here are the full strace stats:

without mutexes:

$ sudo strace -c -p 6167
strace: Process 6167 attached
^Cstrace: Process 6167 detached
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 32.16    3.149828           6    498574           fcntl
 14.44    1.413707           7    216321     20408 stat
  5.92    0.579759           7     83076           readv
  5.27    0.515892           8     63591     32048 getxattr
  4.20    0.410900           8     51542           epoll_wait
  4.07    0.398473          10     41540           writev
  4.01    0.392753           6     61370     20204 lstat
  3.23    0.316353           6     51543           getrusage
  3.11    0.304510           6     50236           fstat
  3.10    0.303822          15     20207           open
  3.03    0.297227           6     51125           getcwd
  3.00    0.293724          10     30202           sendmsg
  2.81    0.274921           6     42566           read
  2.60    0.254488           6     40401           chdir
  2.18    0.213752          12     18352           futex
  2.17    0.212816          10     20408           getdents
  1.54    0.151269          15     10101           setxattr
  1.49    0.145945           7     20209           close
  0.85    0.083246           8     10000           utimensat
  0.66    0.064636           6     10000     10000 fgetxattr
  0.05    0.005006           9       533           pwrite64
  0.03    0.003076          30       101           mkdir
  0.03    0.002989          10       310           listxattr
  0.02    0.001473          25        58           munmap
  0.01    0.001010         112         9           setresgid
  0.01    0.000639          10        64           mmap
  0.00    0.000347          18        19           getegid
  0.00    0.000309          15        21           geteuid
  0.00    0.000242           8        29           ftruncate
  0.00    0.000174          19         9           setresuid
  0.00    0.000124          21         6           setgroups
  0.00    0.000052          26         2           clock_gettime
  0.00    0.000023           5         5           mprotect
  0.00    0.000022          11         2           socket
  0.00    0.000015          15         1           clone
  0.00    0.000010           5         2         1 connect
  0.00    0.000003           2         2           rt_sigprocmask
  0.00    0.000002           1         2           brk
  0.00    0.000000           0         2           getgroups
------ ----------- ----------- --------- --------- ----------------
100.00    9.793537               1392541     82661 total

With mutexes:

$ sudo strace -c -p 6046
strace: Process 6046 attached
^Cstrace: Process 6046 detached
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 19.71    1.543710           7    216186     20408 stat
  7.74    0.606135           7     82986           readv
  7.37    0.577316           7     81998           fcntl
  7.10    0.556157           9     63471     31988 getxattr
  5.70    0.446476          11     41498           writev
  5.63    0.440620           9     51499           epoll_wait
  5.44    0.425990           7     61348     20204 lstat
  4.82    0.377667          19     20207           open
  4.28    0.335272           7     51500           getrusage
  4.25    0.332931          11     30202           sendmsg
  4.15    0.324819           6     51110           getcwd
  4.14    0.323940           6     50236           fstat
  3.80    0.297313           7     42491           read
  3.59    0.281365           7     40401           chdir
  2.94    0.230625          11     20408           getdents
  2.80    0.219255          12     17690           futex
  2.30    0.179997          18     10101           setxattr
  1.97    0.154460           8     20209           close
  1.17    0.091397           9     10000           utimensat
  0.87    0.068211           7     10000     10000 fgetxattr
  0.10    0.007916          15       533           pwrite64
  0.05    0.004069          40       101           mkdir
  0.05    0.003717          13       295           listxattr
  0.02    0.001812          31        58           munmap
  0.01    0.000893          14        64           mmap
  0.00    0.000363          13        29           ftruncate
  0.00    0.000118           8        15           getegid
  0.00    0.000114           7        16           geteuid
  0.00    0.000076          11         7           setresgid
  0.00    0.000074          11         7           setresuid
  0.00    0.000040           8         5           setgroups
  0.00    0.000034          17         2           socket
  0.00    0.000024          24         1           clone
  0.00    0.000019           4         5           mprotect
  0.00    0.000015          15         1           clock_gettime
  0.00    0.000011           6         2         1 connect
  0.00    0.000003           2         2           rt_sigprocmask
  0.00    0.000002           1         2           getgroups
  0.00    0.000000           0         2           brk
------ ----------- ----------- --------- --------- ----------------
100.00    7.832956                974688     82601 total


-slow

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [RFC] Use mutexes by default in db_open()

Samba - samba-technical mailing list
On Mon, Apr 24, 2017 at 07:58:31PM +0200, Ralph Böhme wrote:

> On Mon, Apr 24, 2017 at 10:21:56AM -0700, Jeremy Allison wrote:
> > On Mon, Apr 24, 2017 at 04:16:45PM +0200, Ralph Böhme via samba-technical wrote:
> > > Hi!
> > >
> > > Is there any reason not to use mutexes by default? Maybe for 4.7?
> >
> > Wow ! +1 from me - that seems like a no-brainer to me !
>
> fwiw, here are the full strace stats:
>

>
> $ sudo strace -c -p 6167
> strace: Process 6167 attached
> ^Cstrace: Process 6167 detached
> % time     seconds  usecs/call     calls    errors syscall
> ------ ----------- ----------- --------- --------- ----------------
>  32.16    3.149828           6    498574           fcntl
>  14.44    1.413707           7    216321     20408 stat
>   5.92    0.579759           7     83076           readv
>   5.27    0.515892           8     63591     32048 getxattr
>   4.20    0.410900           8     51542           epoll_wait
>   4.07    0.398473          10     41540           writev
>   4.01    0.392753           6     61370     20204 lstat
>   3.23    0.316353           6     51543           getrusage
>   3.11    0.304510           6     50236           fstat
>   3.10    0.303822          15     20207           open
>   3.03    0.297227           6     51125           getcwd
>   3.00    0.293724          10     30202           sendmsg
>   2.81    0.274921           6     42566           read
>   2.60    0.254488           6     40401           chdir
>   2.18    0.213752          12     18352           futex
>   2.17    0.212816          10     20408           getdents
>   1.54    0.151269          15     10101           setxattr
>   1.49    0.145945           7     20209           close
>   0.85    0.083246           8     10000           utimensat
>   0.66    0.064636           6     10000     10000 fgetxattr
>   0.05    0.005006           9       533           pwrite64
>   0.03    0.003076          30       101           mkdir
>   0.03    0.002989          10       310           listxattr
>   0.02    0.001473          25        58           munmap
>   0.01    0.001010         112         9           setresgid
>   0.01    0.000639          10        64           mmap
>   0.00    0.000347          18        19           getegid
>   0.00    0.000309          15        21           geteuid
>   0.00    0.000242           8        29           ftruncate
>   0.00    0.000174          19         9           setresuid
>   0.00    0.000124          21         6           setgroups
>   0.00    0.000052          26         2           clock_gettime
>   0.00    0.000023           5         5           mprotect
>   0.00    0.000022          11         2           socket
>   0.00    0.000015          15         1           clone
>   0.00    0.000010           5         2         1 connect
>   0.00    0.000003           2         2           rt_sigprocmask
>   0.00    0.000002           1         2           brk
>   0.00    0.000000           0         2           getgroups
> ------ ----------- ----------- --------- --------- ----------------
> 100.00    9.793537               1392541     82661 total
>
> With mutexes:
>
> $ sudo strace -c -p 6046
> strace: Process 6046 attached
> ^Cstrace: Process 6046 detached
> % time     seconds  usecs/call     calls    errors syscall
> ------ ----------- ----------- --------- --------- ----------------
>  19.71    1.543710           7    216186     20408 stat
>   7.74    0.606135           7     82986           readv
>   7.37    0.577316           7     81998           fcntl
>   7.10    0.556157           9     63471     31988 getxattr
>   5.70    0.446476          11     41498           writev
>   5.63    0.440620           9     51499           epoll_wait
>   5.44    0.425990           7     61348     20204 lstat
>   4.82    0.377667          19     20207           open
>   4.28    0.335272           7     51500           getrusage
>   4.25    0.332931          11     30202           sendmsg
>   4.15    0.324819           6     51110           getcwd
>   4.14    0.323940           6     50236           fstat
>   3.80    0.297313           7     42491           read
>   3.59    0.281365           7     40401           chdir
>   2.94    0.230625          11     20408           getdents
>   2.80    0.219255          12     17690           futex
>   2.30    0.179997          18     10101           setxattr
>   1.97    0.154460           8     20209           close
>   1.17    0.091397           9     10000           utimensat
>   0.87    0.068211           7     10000     10000 fgetxattr
>   0.10    0.007916          15       533           pwrite64
>   0.05    0.004069          40       101           mkdir
>   0.05    0.003717          13       295           listxattr
>   0.02    0.001812          31        58           munmap
>   0.01    0.000893          14        64           mmap
>   0.00    0.000363          13        29           ftruncate
>   0.00    0.000118           8        15           getegid
>   0.00    0.000114           7        16           geteuid
>   0.00    0.000076          11         7           setresgid
>   0.00    0.000074          11         7           setresuid
>   0.00    0.000040           8         5           setgroups
>   0.00    0.000034          17         2           socket
>   0.00    0.000024          24         1           clone
>   0.00    0.000019           4         5           mprotect
>   0.00    0.000015          15         1           clock_gettime
>   0.00    0.000011           6         2         1 connect
>   0.00    0.000003           2         2           rt_sigprocmask
>   0.00    0.000002           1         2           getgroups
>   0.00    0.000000           0         2           brk
> ------ ----------- ----------- --------- --------- ----------------
> 100.00    7.832956                974688     82601 total

That does seem to confirm this is a good change to make !

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [RFC] Use mutexes by default in db_open()

Samba - samba-technical mailing list
In reply to this post by Samba - samba-technical mailing list
On Mon, Apr 24, 2017 at 04:16:45PM +0200, Ralph Böhme via samba-technical wrote:
> Hi!
>
> Is there any reason not to use mutexes by default? Maybe for 4.7?

Ping. Can you propose this as an official patch ?

> From 9aff7e4bc481e7b7517cb97149a841de45e68d90 Mon Sep 17 00:00:00 2001
> From: Ralph Boehme <[hidden email]>
> Date: Mon, 24 Apr 2017 16:10:23 +0200
> Subject: [PATCH] s3/dbwrap: enable mutexes by default
>
> For small file copy workloads this makes a huge difference in the number
> of fcntl() syscalls.
>
> Eg copying 10,000 files, without mutexes:
>
> % time     seconds  usecs/call     calls    errors syscall
> ------ ----------- ----------- --------- --------- ----------------
> ...
>  32.16    3.149828           6    498574           fcntl
> ...
>
> Enabling mutexes by setting "dbwrap_tdb_mutexes:* = yes":
>
> % time     seconds  usecs/call     calls    errors syscall
> ------ ----------- ----------- --------- --------- ----------------
> ...
>   7.37    0.577316           7     81998           fcntl
> ...
>
> So 500k vs 80k.
>
> Signed-off-by: Ralph Boehme <[hidden email]>
> ---
>  source3/lib/dbwrap/dbwrap_open.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
> index feb9f5e..5e9a7b0 100644
> --- a/source3/lib/dbwrap/dbwrap_open.c
> +++ b/source3/lib/dbwrap/dbwrap_open.c
> @@ -97,7 +97,7 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
>  
>   if (tdb_flags & TDB_CLEAR_IF_FIRST) {
>   const char *base;
> - bool try_mutex = false;
> + bool try_mutex = true;
>   bool require_mutex = false;
>  
>   base = strrchr_m(name, '/');
> --
> 2.9.3
>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [RFC] Use mutexes by default in db_open()

Samba - samba-technical mailing list
On Sat, May 06, 2017 at 02:15:27PM -0700, Jeremy Allison wrote:
> On Mon, Apr 24, 2017 at 04:16:45PM +0200, Ralph Böhme via samba-technical wrote:
> > Hi!
> >
> > Is there any reason not to use mutexes by default? Maybe for 4.7?
>
> Ping. Can you propose this as an official patch ?

sure, but I'd like Volker, metze or Michael to ack this first.

So... anyone?

-slow

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [RFC] Use mutexes by default in db_open()

Samba - samba-technical mailing list
On Sun, May 07, 2017 at 08:23:40AM +0200, Ralph Böhme wrote:

> On Sat, May 06, 2017 at 02:15:27PM -0700, Jeremy Allison wrote:
> > On Mon, Apr 24, 2017 at 04:16:45PM +0200, Ralph Böhme via samba-technical wrote:
> > > Hi!
> > >
> > > Is there any reason not to use mutexes by default? Maybe for 4.7?
> >
> > Ping. Can you propose this as an official patch ?
>
> sure, but I'd like Volker, metze or Michael to ack this first.
>
> So... anyone?

I don't see why we should not do this.

Volker

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [RFC] Use mutexes by default in db_open()

Samba - samba-technical mailing list
On Sun, May 07, 2017 at 11:52:59AM +0200, Volker Lendecke wrote:

> On Sun, May 07, 2017 at 08:23:40AM +0200, Ralph Böhme wrote:
> > On Sat, May 06, 2017 at 02:15:27PM -0700, Jeremy Allison wrote:
> > > On Mon, Apr 24, 2017 at 04:16:45PM +0200, Ralph Böhme via samba-technical wrote:
> > > > Hi!
> > > >
> > > > Is there any reason not to use mutexes by default? Maybe for 4.7?
> > >
> > > Ping. Can you propose this as an official patch ?
> >
> > sure, but I'd like Volker, metze or Michael to ack this first.
> >
> > So... anyone?
>
> I don't see why we should not do this.

ok, thanks for confirming!

I'll add a whatsnew section and will resubmit the patchset once done.

-slow

Loading...