Re: [Rpm-maint] [rpm-software-management/rpm] luaext/Pexec: optimize setting CLOEXEC (#444)

2018-05-17 Thread Kirill Kolyshkin
For the reference, here's my quick-n-dirty benchmarking code: ```c #include #include #include #include #include #include static void set_cloexec(int fd) { int flags = fcntl(fd, F_GETFD); if (flags == -1 || (flags & FD_CLOEXEC)) return; fcntl(fd,

Re: [Rpm-maint] [rpm-software-management/rpm] luaext/Pexec: optimize setting CLOEXEC (#444)

2018-05-17 Thread Kirill Kolyshkin
``` kir@kd:~/git/rpm$ time ./a 64 100 p real0m3.413s user0m0.416s sys 0m2.994s kir@kd:~/git/rpm$ time ./a 64 100 i real0m3.661s user0m1.421s sys 0m2.233s ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or

Re: [Rpm-maint] [rpm-software-management/rpm] luaext/Pexec: optimize setting CLOEXEC (#444)

2018-05-17 Thread Kirill Kolyshkin
I did some more benchmarks comparing the new /proc way with the old one. It seems that the old one is faster when `open_max < 60` which should almost never be the case. Based on that and the suggestion from @Saur2000 I'm dropping the conditional switch to old method completely. -- You are

Re: [Rpm-maint] [rpm-software-management/rpm] luaext/Pexec: optimize setting CLOEXEC (#444)

2018-05-17 Thread Kirill Kolyshkin
kolyshkin commented on this pull request. > + fcntl(fd, F_SETFD, FD_CLOEXEC); +} + +static void set_cloexec_all(void) +{ + const int min_fd = 3; // don't touch stdin/out/err + const int default_open_max = 1024; + int fd, open_max; + + open_max =

Re: [Rpm-maint] [rpm-software-management/rpm] luaext/Pexec: optimize setting CLOEXEC (#444)

2018-05-17 Thread Kirill Kolyshkin
kolyshkin commented on this pull request. > @@ -330,26 +330,64 @@ static int Pmkfifo(lua_State *L)/** > mkfifo(path) */ } +static void set_cloexec(int fd) +{ + int flag = fcntl(fd, F_GETFD); + + if (flag == -1 || (flag & FD_CLOEXEC)) + return; + +

Re: [Rpm-maint] [rpm-software-management/rpm] luaext/Pexec: optimize setting CLOEXEC (#444)

2018-05-17 Thread Kirill Kolyshkin
kolyshkin commented on this pull request. > + struct dirent *entry; + while ((entry = readdir(dir)) != NULL) { + fd = atoi(entry->d_name); + if (fd >= min_fd) + set_cloexec(fd); + } + closedir(dir); + + return; +

Re: [Rpm-maint] [rpm-software-management/rpm] luaext/Pexec: optimize setting CLOEXEC (#444)

2018-05-17 Thread Kirill Kolyshkin
The CI failure on rawhide is unrelated, it's a dnf error complaining about repo metadata: > raise ValueError("The supplied metadata version isn't supported") -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub:

Re: [Rpm-maint] [rpm-software-management/rpm] luaext/Pexec: optimize setting CLOEXEC (#444)

2018-05-17 Thread Peter Kjellerstedt
Saur2000 requested changes on this pull request. > + struct dirent *entry; + while ((entry = readdir(dir)) != NULL) { + fd = atoi(entry->d_name); + if (fd >= min_fd) + set_cloexec(fd); + } + closedir(dir); + + return;

Re: [Rpm-maint] [rpm-software-management/rpm] luaext/Pexec: optimize setting CLOEXEC (#444)

2018-05-17 Thread Colin Walters
At a quick glance anyways, your code looks fine to me. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: