Feature #11971

Consider migrating some of /lib/live/config/* to systemd unit files

Added by intrigeri 2016-11-20 12:46:01 . Updated 2017-05-23 09:08:11 .

Status:
Resolved
Priority:
Elevated
Assignee:
Category:
Target version:
Start date:
2016-11-20
Due date:
% Done:

100%

Feature Branch:
bugfix/11971-fontconfig-cache-in-iso
Type of work:
Code
Blueprint:

Starter:
Affected tool:
Deliverable for:
289

Description

While working on reproducible builds we’re adding quite some stuff in there, and some of it might be slow. If this affects boot time significantly (especially on slower hardware), we should migrate some of those bits to systemd unit files, so that they can be run in parallel.


Subtasks


Related issues

Related to Tails - Feature #12318: Have our test suite track detailed boot-up performance Confirmed 2017-03-11
Related to Tails - Feature #11983: Check if the test suite has more failures on the reproducible ISO Resolved 2016-11-21
Related to Tails - Bug #12567: fontconfig cache is not generated reproducibly even with patch from Debian#857892 Resolved 2017-05-19

History

#1 Updated by intrigeri 2017-03-13 15:45:27

  • related to Feature #12318: Have our test suite track detailed boot-up performance added

#2 Updated by intrigeri 2017-03-13 15:59:13

In a VM on a quite loaded system:

  • dpkg-reconfigure fontconfig took 27 seconds
  • Updating certificates in /etc/ssl/certs took 13 seconds

In practice, I think this added ~20 seconds to the total boot time after apparmor.service stopped blocking.

#3 Updated by Anonymous 2017-03-13 17:02:31

concerning config/2050-fontconfig

A solution might be to not have font cache at all. But I wonder if that would result in longer loading times for libreoffice for example.

#4 Updated by Anonymous 2017-03-13 21:31:02

I booted a test ISO and everything seems to work fine. I opened LibreOffice, a PDF, Inkscape and could successfully change and read different fonts as well as have a font list. However, I’m in no position to judge if booting is faster than usual nor if running a program using system fonts is slower than usual.

This has been done in tails:tails/feature/11971+fontconfig.
ISO is here: https://nightly.tails.boum.org/build_Tails_ISO_feature-11971-fontconfig/

#5 Updated by anonym 2017-03-14 00:28:03

u wrote:
> This has been done in tails:tails/feature/11971+fontconfig.
> ISO is here: https://nightly.tails.boum.org/build_Tails_ISO_feature-11971-fontconfig/

I see only unrelated failures in the automated test suite run: https://jenkins.tails.boum.org/job/test_Tails_ISO_feature-11971-fontconfig/1/

#6 Updated by intrigeri 2017-03-14 10:19:44

I’ll look into the CA cert updates, while waiting for mksquashfs to crunch numbers. Likely it’s a good candidate to move to a dedicated systemd unit file.

#7 Updated by Anonymous 2017-03-14 10:24:09

Ok, i’ve tested manually in a VM, comparing the latest feature/56300 with the fontconfig ISO mentioned in my previous comment. The VM had 2GB RAM and used 3 cores of an i5.

with fontconfig cache generated at boot time

  • boot until Greeter started = 78 secs
  • login from greeter = 10 secs
  • start libreoffice once = 6.5 secs
  • start libreoffice second time = 2 secs
  • start inkscape = 6.5 secs
  • memory used = 596MB
  • memory used while running libreoffice = 675MB
  • top (after tor has started and tails-iuk and tails-upgrader were run:)
    KiB Mem : 2052372 total, 297868 free, 595472 used, 1159032 buff/cache

without fontconfig cache

  • boot until Greeter started = 68 secs
  • login from greeter = 21 secs
  • start libreoffice once = 6.5 secs
  • start libreoffice second time = 1.8 secs
  • start inkscape = 6.5 secs
  • memory used = 523MB
  • memory used while running libreoffice = 594MB
  • top (after tor has started and tails-iuk and tails-upgrader were run:)
    KiB Mem : 2052372 total, 379516 free, 513800 used, 1159056 buff/cache

tails 3.0 beta2 fontconfig cache in the ISO

  • boot until Greeter started = 67 secs
  • login from greeter = 16 secs
  • start libreoffice once = 15 secs
  • start libreoffice second time = 1.8 secs
  • start inkscape = 9 secs
  • memory used = 580MB
  • memory used while running libreoffice = 652MB
  • top (after tor has started and tails-iuk and tails-upgrader were run:)
    KiB Mem : 2052372 total, 579476 free, 580344 used, 892552 buff/cache

#8 Updated by intrigeri 2017-03-14 11:15:57

  • Status changed from Confirmed to In Progress
  • % Done changed from 0 to 10

#9 Updated by intrigeri 2017-03-14 12:03:26

  • Assignee deleted (intrigeri)
  • % Done changed from 10 to 20

Done (and pushed) my bits about update-ca-certificates, sending to u’s plate wrt. the fontconfig part :)

#10 Updated by Anonymous 2017-03-14 12:30:56

Same test again on bare metal (i3 processor, 16 Gigs of RAM):

with fontconfig cache generated at boot time

  • boot until Greeter started = 84 secs
  • login from greeter = 10 secs
  • start libreoffice once = 7 secs
  • memory used = 551MB
  • memory used while running libreoffice = 617MB
  • top: KiB Mem : 16349932 total, 14860230 free 551400 used, 1195460 buff/cache

without fontconfig cache

  • boot until Greeter started = 73 secs
  • login from greeter = 19 secs
  • start libreoffice once = 6.5 secs
  • memory used = 591MB
  • memory used while running libreoffice = 653MB
  • top: KiB Mem : 16349932 total, 14563116 free 590912 used, 1195840 buff/cache
    After running LibreOffice the last value changes to 1359180 buff/cache.

tails 3.0 beta2 fontconfig cache in the ISO

  • boot until Greeter started = 85 secs
  • login from greeter = 18 secs
  • start libreoffice once = 20 secs
  • memory used = 566MB
  • memory used while running libreoffice = 615MB
  • top: KiB Mem : 16349936 total, 14876420 free 549528 used, 925292 buff/cache

#11 Updated by Anonymous 2017-03-14 12:38:44

Basically, it looks to me like boot until the greeter is faster with fontconfig not generated at build time. However, the login to Xserver is longer.
Starting up libreoffice seems unaffected between fontcache and nofontcache.
What seems weird is that more memory is used on baremetal when fontcache is not generated at build and less memory is used on a VM.

#12 Updated by Anonymous 2017-03-14 13:55:54

  • Assignee set to intrigeri
  • QA Check set to Ready for QA
  • Feature Branch set to 451f:config/chroot_local-includes/lib/live/config/

We should build this branch and see if it works out well please.

#13 Updated by Anonymous 2017-03-14 13:56:14

  • Feature Branch changed from 451f:config/chroot_local-includes/lib/live/config/ to 451f:tails/config/chroot_local-includes/lib/live/config/

#14 Updated by intrigeri 2017-03-14 14:43:17

  • Assignee deleted (intrigeri)
  • % Done changed from 20 to 50
  • Feature Branch changed from 451f:tails/config/chroot_local-includes/lib/live/config/ to 451f:feature/11971+fontconfig_to_systemd

Code review passes! I’d like to do some systemd magics to verify it is ordered as expected, so please reassign to me (unless you prefer we do it together!) once you’ve successfully tested an ISO built from this branch.

#15 Updated by Anonymous 2017-03-14 16:25:57

Using a build from the latest branch, which does invoke fontconfig over systemd, I think we’ve solved our problem:

Test on bare metal (i3 processor, 16 Gigs of RAM):

  • boot until Greeter started = 68 secs
  • login from greeter = 11 secs
  • start libreoffice once = 7 secs
  • memory used = 568MB
  • memory used while running libreoffice = 638MB
  • top: KiB Mem : 16349936 total, 14584664 free 568484 used, 1195472 buff/cache

#16 Updated by Anonymous 2017-03-14 16:26:23

  • Assignee set to intrigeri

#17 Updated by intrigeri 2017-03-14 17:10:10

Yay!

I’ll fetch an ISO and will give it a try.

#18 Updated by intrigeri 2017-03-16 08:15:37

  • Assignee deleted (intrigeri)
  • % Done changed from 50 to 70

Merged and then we’ve improved it. Last step is to benchmark current feature/5630-deterministic-builds vs. 3.0~beta2 on bare metal, to ensure there’s no severe regression in the end.

#19 Updated by intrigeri 2017-03-16 09:52:57

  • QA Check deleted (Ready for QA)

Hold on, we might be able to move the fontconfig cache generation back to ISO build time: https://bugs.debian.org/857892. I’m in favour of trying this first, i.e.:

  1. fork a topic branch dedicated to test this, based on feature/5630-deterministic-builds
  2. build a custom package based on the one from Stretch, with Chris’ patch applied, and upload it to the suite corresponding to the new topic branch in our custom APT repo
  3. enable this suite in APT_overlays.d
  4. drop the fontconfig systemd unit file and drop the fontconfig cache deletion at ISO build time, i.e. go back to how we did things in 2.x
  5. build two ISOs and compare
  6. if the build is reproducible, then benchmark this new ISO against feature/5630-deterministic-builds (that has the fontconfig cache generation done at boot time) and decide what’s best; and if we want to keep generating that cache at boot time, then consider applying https://cgit.freedesktop.org/fontconfig/commit/?id=7a6622f25cdfab5ab775324bef1833b67109801b to make it faster

What do you think? Wanna try this?

#20 Updated by intrigeri 2017-03-16 10:26:37

  • Target version set to Tails_2.12
  • Feature Branch deleted (451f:feature/11971+fontconfig_to_systemd)
  • Type of work changed from Test to Code

Ulrike agreed to do it. Real deadline: have this finalized for the 3.0~rcN we’ll publish mid-May. Please reassign to me (with a target version = 3.0 and priority = Elevated) if this is not done by then :)

#21 Updated by Anonymous 2017-04-08 11:08:32

  • Target version changed from Tails_2.12 to Tails_3.0

#22 Updated by intrigeri 2017-04-18 07:50:29

  • Priority changed from Normal to Elevated

I suspect (Feature #11983#note-14) that the current state of our fontconfig tweaks breaks stuff, so marking as a blocker for 3.0. The deadline set above still holds, but since this somewhat blocks Feature #11983 now, I certainly wouldn’t mind if it was done earlier :)

#23 Updated by intrigeri 2017-04-18 07:54:56

  • blocks Feature #11983: Check if the test suite has more failures on the reproducible ISO added

#24 Updated by intrigeri 2017-04-18 15:25:41

  • Target version changed from Tails_3.0 to Tails_3.0~rc1

#25 Updated by Anonymous 2017-04-27 08:31:10

intrigeri wrote:
> # build a custom package based on the one from Stretch, with Chris’ patch applied, and upload it to the suite corresponding to the new topic branch in our custom APT repo

Why wouldn’t we use the package from experimental instead? seems that this one contains the patch already.

#26 Updated by intrigeri 2017-04-27 10:17:12

> why wouldn’t we use the package from experimental instead? seems that this one contains the patch already.

  • If we do that, then we have to track fontconfig 2.12+ for the entire Tails 3.x series; this will probably work smoothly for a while, but at some point I bet the packages won’t be installable on Stretch anymore (e.g. they’ll get a dependency on a newer libc6 or something) and then we’ll have to maintain backports until Tails 4.x, which will likely require much more work than maintaining a tiny delta against the Stretch package.
  • fontconfig has been poorly maintained in Debian for ages; the last maintainer upload is 3 years old; the upload to experimental was a NMU done by someone who had never uploaded the package before, and I have no idea what’s their plan to transition unstable to 2.12 / to maintain the package in experimental; I’d rather not rely on this upload and its future maintenance.
  • libfontconfig1-dev has many reverse-build-dependencies, so a proper transition (with binNMUs) may be required to have other packages work fine with libfontconfig1 2.12+.
  • It’s very unlikely that fontconfig 2.12 has been tested much on Debian systems; even Ubuntu doesn’t ship 2.12 yet (they’ve diverged from Debian many years ago, and apparently they nowadays ship some snapshot taken somewhere between fontconfig 2.11 and 2.12). So the impact of upgrading from 2.11 to this new upstream release is unknown: it may very well break stuff. I’d rather not Tails users be the ones who discover such breakage first.
  • There’s no security support for packages in experimental, so if we use them we (for some value of “we” :) needs to take responsibility for tracking their security status. One security upload was done during the Jessie lifetime already, so this is not a theoretical concern.

⇒ all in all, pulling these packages from experimental saves a little bit of work up-front, but feels risky (QA-wise) and adds lots more work on our shoulders for the next 2 years. I don’t think the tiny short-term benefits are worth the short and long-term drawbacks.

#27 Updated by Anonymous 2017-05-15 16:47:23

intrigeri wrote:
> Hold on, we might be able to move the fontconfig cache generation back to ISO build time: https://bugs.debian.org/857892. I’m in favour of trying this first, i.e.:
>
> # fork a topic branch dedicated to test this, based on feature/5630-deterministic-builds
> # build a custom package based on the one from Stretch, with Chris’ patch applied, and upload it to the suite corresponding to the new topic branch in our custom APT repo

Interestingly, the line deleted by Chris’s patch is not present in the version he talks about?
I double checked:

wget http://httpredir.debian.org/debian/pool/main/f/fontconfig/fontconfig_2.11.0-6.7.dsc
then see in src/fpat.c
search for “memset (p, 0, sizeof (FcPattern));”
this should be located right at the beginning of the file, line 6.
But it’s not.

#28 Updated by intrigeri 2017-05-16 12:27:53

> Interestingly, the line deleted by Chris’s patch is not present in the version he talks about?

Chris’ patch adds a line, it doesn’t delete any.

#29 Updated by Anonymous 2017-05-16 13:25:42

intrigeri wrote:
> > Interestingly, the line deleted by Chris’s patch is not present in the version he talks about?
>
> Chris’ patch adds a line, it doesn’t delete any.

Haha, I had no idea how tired my eyes are sometimes.

This is probably due to the fact that the fontconfig package does not use version control (!§$%@!) and so this got mixed up in quilt, making me think that I removed the line, but it was simply the other way round.

#30 Updated by intrigeri 2017-05-16 16:52:02

What’s your ETA? If later than Wednesday night, I’ll probably reassign to me (as said a couple months ago) as this blocks merging the reproducible builds branch, which I want to merge in time for 3.0~rc1.

#31 Updated by intrigeri 2017-05-18 12:41:03

  • Assignee set to intrigeri

intrigeri wrote:
> What’s your ETA? If later than Wednesday night, I’ll probably reassign to me (as said a couple months ago) as this blocks merging the reproducible builds branch, which I want to merge in time for 3.0~rc1.

Taking over, hoping to complete this fast enough to fix this problem and then work on Feature #11983 and Feature #12348 in time for 3.0~rc1 that we’ll freeze at some point tomorrow. I didn’t find any published WIP on this front (I’ve looked in the official Git repo, in u’s own one, and in our custom APT repo), so I’ll start from scratch. Still, u: if you read this and want to share what you already did or share some of the next steps, let’s coordinate e.g. on XMPP :)

#32 Updated by intrigeri 2017-05-18 12:51:15

  • Feature Branch set to bugfix/11971-fontconfig-cache-in-iso

#33 Updated by intrigeri 2017-05-18 13:00:39

Patched fontconfig package uploaded to the bugfix-11971-fontconfig-cache-in-iso APT suite.

#34 Updated by intrigeri 2017-05-18 13:03:33

Prepared branch that includes the fontconfig cache, will built & test locally before pushing.

#35 Updated by intrigeri 2017-05-19 07:27:43

Fixed some reproducibility issues (initrd differs due to initramfs-tools in testing having superseded our patched package + forgot about forcecleanup). Building twice again to make sure the fontconfig cache itself doesn’t introduce reproducibility problems.

#36 Updated by intrigeri 2017-05-19 10:05:02

  • Target version changed from Tails_3.0~rc1 to Tails_3.0

intrigeri wrote:
> Hold on, we might be able to move the fontconfig cache generation back to ISO build time: https://bugs.debian.org/857892. I’m in favour of trying this first, i.e.:
>
> # fork a topic branch dedicated to test this, based on feature/5630-deterministic-builds
> # build a custom package based on the one from Stretch, with Chris’ patch applied, and upload it to the suite corresponding to the new topic branch in our custom APT repo
> # enable this suite in APT_overlays.d
> # drop the fontconfig systemd unit file and drop the fontconfig cache deletion at ISO build time, i.e. go back to how we did things in 2.x
> # build two ISOs and compare

Ouch, I see differences in /var/cache/fontconfig/ even with Chris’ patch applied. Too late to investigate this further, so we’ll have to do Feature #11983 without this change.

#37 Updated by intrigeri 2017-05-19 10:16:43

  • blocked by deleted (Feature #11983: Check if the test suite has more failures on the reproducible ISO)

#38 Updated by intrigeri 2017-05-19 10:16:46

  • related to Feature #11983: Check if the test suite has more failures on the reproducible ISO added

#39 Updated by intrigeri 2017-05-19 10:56:37

Actually, anonym and I want this branch in 3.0~rc1, even if it means that release won’t be reproducible: robustness feels more important than reproducibility at this point. So we’ll evaluate this branch with the test suite, merge it, and I’ll file another ticket about making the fontconfig cache reproducible, that anonym or I will try to get help from Chris about.

#40 Updated by intrigeri 2017-05-19 10:57:00

  • Target version changed from Tails_3.0 to Tails_3.0~rc1

#41 Updated by intrigeri 2017-05-19 11:18:34

  • related to Bug #12567: fontconfig cache is not generated reproducibly even with patch from Debian#857892 added

#42 Updated by Anonymous 2017-05-19 16:20:10

intrigeri wrote:
> What’s your ETA? If later than Wednesday night, I’ll probably reassign to me (as said a couple months ago) as this blocks merging the reproducible builds branch, which I want to merge in time for 3.0~rc1.

I had only had time to start building the package, but I did not pursue the initial plan to build and compare the ISOs. Fine with me that you took over and sorry to see that the patch does not function as intended.

#43 Updated by intrigeri 2017-05-19 18:04:46

  • Assignee changed from intrigeri to anonym
  • QA Check set to Ready for QA

I’ve run locally a large part of the test suite (including fragile tests) on this branch today and am killing it now during the Thunderbird tests, as I need to context switch and test other branches now. I’ve seen only fragile tests fail so far. Please review’n’merge :) Bug #12567 tracks the next steps on this topic, so let’s close this ticket that we have already used and reused for follow-ups to the initial issue it was about.

#44 Updated by anonym 2017-05-20 07:59:11

  • Status changed from In Progress to Fix committed
  • Assignee deleted (anonym)
  • % Done changed from 70 to 100
  • QA Check changed from Ready for QA to Pass

#45 Updated by intrigeri 2017-05-20 08:42:38

Merged into the branch for Feature #5630 and reverted “Ship the fontconfig cache in the ISO again”, to try and have that branch build ISOs reproducibly until Bug #12567 is solved.

#46 Updated by intrigeri 2017-05-23 09:08:11

  • Status changed from Fix committed to Resolved