libmap.conf vs packages and whatnot

From: Mateusz Guzik <mjguzik_at_gmail.com>
Date: Fri, 17 Oct 2014 16:14:44 +0200
Hello,

turns out that we got some additional cost when executing binaries.

I'm not declaring I'm going to do any work on this, but I'd like to
state why I don't like current approach. It's just my $0,03.

So we got libmap.conf + /usr/local/etc/libmap.d directory.

This results in:
lstat("/etc",{ mode=drwxr-xr-x ,inode=22,size=117,blksize=7680 }) = 0 (0x0)
lstat("/etc/libmap.conf",{ mode=-rw-r--r-- ,inode=384351,size=47,blksize=4096 }) = 0 (0x0)
open("/etc/libmap.conf",O_CLOEXEC,0146)		 = 3 (0x3)
fstat(3,{ mode=-rw-r--r-- ,inode=384351,size=47,blksize=4096 }) = 0 (0x0)
mmap(0x0,47,PROT_READ,MAP_PRIVATE,3,0x0)	 = 34366185472 (0x800626000)
close(3)					 = 0 (0x0)
lstat("/usr",{ mode=drwxr-xr-x ,inode=9,size=17,blksize=4096 }) = 0 (0x0)
lstat("/usr/local",{ mode=drwxr-xr-x ,inode=563,size=17,blksize=4096 }) = 0 (0x0)
lstat("/usr/local/etc",{ mode=drwxr-xr-x ,inode=16407,size=44,blksize=4096 }) = 0 (0x0)
lstat("/usr/local/etc/libmap.d",{ mode=drwxr-xr-x ,inode=12994,size=2,blksize=4096 }) = 0 (0x0)
open("/usr/local/etc/libmap.d",O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,0165) = 3 (0x3)
fstatfs(0x3,0x7fffffffcaa0,0x0,0x400,0x1000,0x8080808080808080) = 0 (0x0)
getdirentries(0x3,0x800624000,0x1000,0x800623028,0x1000,0x8080808080808080) = 24 (0x18)
getdirentries(0x3,0x800624000,0x1000,0x800623028,0x1000,0x8080808080808080) = 0 (0x0)
close(3)					 = 0 (0x0)

For each exec, even though in vast majority of cases there is no need
for this. Also note the directory is empty, otherwise this is another
round of lstats + open for each file.

I'm told this will be needed for ports so that they can shuffle libraries
for interested programs. I don't know problem area very well, so please
correct me if this stuff cannot work.

First off, if there is no way around needing to parse data, I would
suggest generating a binary blob which can be mmapped and quickly
traversed.

1st case: we want new lib for each program

just replace a symlink (or better yet, a hardlink) to the old one.

2nd case: only selected programs should get new lib

For each prog in need, one can create /usr/local/etc/libmap.d/${prog}.
And there you go, one open and if it failed there is nothing to do.

Path in question can be a symlink to a bigger file with a set of
remmapped libraries, or possibly can 'include ${some_set}'.

It is unclear to me whether ports tree guarantees unique names of
binaries. If not, maybe there will be an easy way to guarantee lookups
or unique stuff anyway (putting some crap in during compilation/linkage?).

This way the cost for uninterested progs is greatly reduced. Interested
progs also get this faster, as long as there are more than 3 files (as
with current approach one would have to parse them all).

-- 
Mateusz Guzik <mjguzik gmail.com>
Received on Fri Oct 17 2014 - 12:14:49 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:53 UTC