Package: eatmydata
Version: 105-1
Severity: normal
Tags: patch

Hello,

libeatmydata is linked against libpthread. This thus pulls libpthread
in all processes run under eatmydata. It happens that having
libpthread in a process makes pthread_mutex_lock() and all such basic
performance-sensitive operations much heavier (since they then have to
deal with potential multithreading). The attached patch avoids that by
using a weak reference to pthread_testcancel, so that pthread_testcancel
is called only if the program itself pulls libpthread.

Samuel

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 'oldoldstable'), 
(500, 'buildd-unstable'), (500, 'unstable'), (500, 'stable'), (500, 
'oldstable'), (1, 'experimental-debug'), (1, 'buildd-experimental'), (1, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.4.0 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages eatmydata depends on:
ii  libeatmydata1  105-1

eatmydata recommends no packages.

eatmydata suggests no packages.

-- no debconf information

-- 
Samuel
* y se leve dans 2h10
--- libeatmydata/libeatmydata.c.original        2016-02-28 01:15:05.000000000 
+0000
+++ libeatmydata/libeatmydata.c 2016-02-28 01:16:34.000000000 +0000
@@ -67,6 +67,7 @@
         libc_##name = (libc_##name##_##t)(intptr_t)dlsym(RTLD_NEXT, #name);    
                \
                                                   dlerror();
 
+#pragma weak pthread_testcancel
 
 int LIBEATMYDATA_API msync(void *addr, size_t length, int flags);
 static int initing = 0;
@@ -113,7 +114,8 @@
 int LIBEATMYDATA_API fsync(int fd)
 {
        if (eatmydata_is_hungry()) {
-               pthread_testcancel();
+               if (pthread_testcancel)
+                       pthread_testcancel();
                errno= 0;
                return 0;
        }
@@ -188,7 +190,8 @@
 int LIBEATMYDATA_API fdatasync(int fd)
 {
        if (eatmydata_is_hungry()) {
-               pthread_testcancel();
+               if (pthread_testcancel)
+                       pthread_testcancel();
                errno= 0;
                return 0;
        }
@@ -199,7 +202,8 @@
 int LIBEATMYDATA_API msync(void *addr, size_t length, int flags)
 {
        if (eatmydata_is_hungry()) {
-               pthread_testcancel();
+               if (pthread_testcancel)
+                       pthread_testcancel();
                errno= 0;
                return 0;
        }
@@ -211,7 +215,8 @@
 int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
 {
        if (eatmydata_is_hungry()) {
-               pthread_testcancel();
+               if (pthread_testcancel)
+                       pthread_testcancel();
                errno= 0;
                return 0;
        }
--- Makefile.am.original        2016-02-28 01:21:09.000000000 +0000
+++ Makefile.am 2016-02-28 01:17:07.000000000 +0000
@@ -80,7 +80,7 @@
   $(NO_WERROR) \
        -DBUILDING_LIBEATMYDATA
 
-libeatmydata_la_LIBADD = $(LIBDL_LIBS) -lpthread
+libeatmydata_la_LIBADD = $(LIBDL_LIBS)
 libeatmydata_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBEATMYDATA_VERSION)
 
 #install-exec-hook:

Reply via email to