Odi's astoundingly incomplete notes

New entries


back | next

package.keywords becomes package.accept_keywords

As of sys-apps/portage-2.3.89 Gentoo installations must rename /etc/portage/package.keywords to /etc/portage/package.accept_keywords.

posted on 2020-03-03 15:56 UTC in Code | 1 comments | permalink

Relaying SIGINT signal to child processes

Here is a bash function (plus test program) that correctly relays important signals to child processes. So that pressing Ctrl-C reliably terminates both all child processes and the parent process.

posted on 2020-01-09 10:32 UTC in Code | 0 comments | permalink

linux-5.5 mm looks very good

My tests with the upcoming Linux kernel are looking very promising. For me memory management issue has been improved a lot. In recent 5.x kernels the mm would trigger a lot of reclaim scans even with low memory pressure. For example  on a 2GB laptop the Normal zone is quite small. Most memory is in the DMA32 zone. And those kernels would trigger reclaim and even swap when opening a browser or using gitk on the kernel repo. Even though there is still plenty of usable RAM.
With 5.5 this is resolved. Reclaim scans are rare again and swap is not used in these situations.

posted on 2020-01-01 14:29 UTC in Code | 0 comments | permalink

Gentoo updating gcc, mpfr, mpc

When Gentoo updates gcc together with mpfr and mpc the normal emerge procedure will cause building of gcc twice. Because mpfr and mpc cause automatic rebuild of the (existing) gcc. But if you are going to update gcc anyway then this is utterly pointless waste of energy.

Instead you can emerge --ignore-built-slot-operator-deps=y -1uav mpfr mpc first without doing the rebuild. This leaves you with a broken gcc maybe (but actually probably not because portage preserves the old library versions), but next you simply emerge -1uav gcc anyway.

After gcc update don't forget to switch to the new compiler with gcc-config and rebuild libtool.

posted on 2019-11-28 09:09 UTC in Code | 0 comments | permalink

Gentoo replacing ntp, vixie-cron, man

Gentoo is cleaning out its closet. It has removed unmaintained upstream packages which were still popular: ntp, vixie-cron and man. Of course it's a logical step and using the modern replacements is rational.

For net-misc/ntp, use net-misc/ntpsec: This has way more robust configuration while eliminating ancient obscure features like traps.

For vixie-cron, use sys-process/cronie. It also itegrates anacron, so you get two in one.

For man, use man-db which is faster as it uses a BDB backend instead of text files.

posted on 2019-10-14 07:06 UTC in Code | 0 comments | permalink

Java and its use of filesystem syscalls

File f = new File("build.xml");
// openat(AT_FDCWD, "build.xml", O_RDONLY) = 96
// fstat(96
InputStream io = new FileInputStream(f);
// read(96
// read(96
// close(96)

Path p = f.toPath();
// openat(AT_FDCWD, "build.xml", O_RDONLY) = 96
io = Files.newInputStream(p);
// read(96
// read(96
// close(96)
The NIO way of creating an input stream from a file actually saves an fstat syscall.
posted on 2019-10-01 13:36 UTC in Code | 0 comments | permalink

ipset's hashsize and maxelem parameters

When defining a Linux hash ipset the parameters hashsize and maxelem must be chosen.

maxelem is easy: this limits how many entries the ipset can have.

hashsize however is a tuning parameter. It defines how many hash buckets are allocated for the hashtable. This is the amount of memory that you are willing to sacrifice. It has a very coarse granularity and accepts only values that are equal to 2^n where n is 1..32.

Hashtables are most efficient (buckets mostly contain only a single key, eliminating the search within a bucket) when only 3/4 of their buckets are actually used (1/4 is free). But for large ipsets this is not practical as it would waste a lot of memory. For example for an ipset with 100'000 entries the hashsize should be at least 133'333. The next larger legal value of hashsize is 262'144 which is very wasteful (but fast).

So for such large hashtables we can't really afford to avoid the bucket search. Instead we try to find a balance between the size of a bucket and the number of buckets. If we put 8 entries inside a bucket on average then we get 12'500 buckets. The next legal value for hashsize is 16'384, which gets us 6 entries in average in reality. This should yield acceptable performance vs. small enough space.

posted on 2019-09-30 14:44 UTC in Code | 0 comments | permalink

Java and its use of mmap

These are the syscalls caused by Java's mapped byte buffers:
FileChannel fc = FileChannel.open(f.toPath(), StandardOpenOption.READ, StandardOpenOption.WRITE);
// mmap(NULL, 2147483647, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0)
MappedByteBuffer buf = fc.map(MapMode.READ_WRITE, 0, Integer.MAX_VALUE);
// madvise(0x7f4294000000, 2147483647, MADV_WILLNEED) = 0
When the buffer is garbage collected the munmap call happens.
posted on 2019-09-11 11:30 UTC in Code | 0 comments | permalink

How to migrate SonarQube to Postgresql

Perform the migration on an existing SonarQube installation. You can not do it at the same time as upgrading to a newer SonarQube version!

1. Create an emtpy Postgresql DB (no password is used here, depending on settings in pg_hba.conf):
psql -U postgres
create user sonar;
create database sonarqube owner sonar;
2. Change the DB connection of the existing SonarQube installation in sonar.properties:
3. Start up the SonarQube instance so that it creates the DB schema in Postgresql.

4. Shut down the SonarQube instance again for migration.

5. Delete the sonar/data/es6/nodes folder.

4. Run the mysql-migrator utility.

5. Startup the SonarQube instance again.

6. If you want to update to a newer SonarQube version then do that now.

posted on 2019-08-15 09:47 UTC in Code | 0 comments | permalink

Java and its use of epoll

In case you wonder how Java NIO uses epoll under Linux:
posted on 2019-06-19 09:36 UTC in Code | 0 comments | permalink
back | next