User:Vazhnov/Dirty hacks

Maybe it will help to anybody who wants to do some digging.

Add GNU time to emerge
I want to see "Maximum resident set size" for ebuild compile, to get some memory usage info for problem User:Vazhnov/Knowledge Base:emerge out of memory. I use "/usr/bin/time -v" (GNU time) for this.

Iteration one: /usr/bin/ebuild
First I tried to replace which is symlink to.

I did it successfully, but then I realized not use, it uses some python code to run.

Iteration two: /usr/lib/portage/python3.6/ebuild.sh
Save original file:

Create file:

I tried to save information I need to, but unfortunately it is sandboxed:

* ACCESS DENIED: open_wr:      /var/log/emerge-time.log /usr/lib/portage/python3.6/ebuild.sh: line 8: /var/log/emerge-time.log: Permission denied * ACCESS DENIED: fopen_wr:     /var/log/emerge-time.log /usr/bin/time: /var/log/emerge-time.log: Permission denied * ACCESS DENIED: open_wr:      /var/log/emerge-time.log /usr/lib/portage/python3.6/ebuild.sh: line 10: /var/log/emerge-time.log: Permission denied * --- ACCESS VIOLATION SUMMARY --- * LOG FILE: "/var/tmp/portage/gnome-extra/gnome-calculator-3.32.2/temp/sandbox.log"

So I can write into.

Then I found PORTAGE_LOGDIR allows to save build logs, with all(?) STDERR output.

Result
Final output example : >>> Compiling source in /var/tmp/portage/gnome-extra/gnome-calculator-3.32.2/work/gnome-calculator-3.32.2 ... ninja -v -j6 -l0 -C /var/tmp/portage/gnome-extra/gnome-calculator-3.32.2/work/gnome-calculator-3.32.2-build … >>> Source compiled. Command being timed: "/usr/lib/portage/python3.6/ebuild.sh.ORIG compile" User time (seconds): 29.38 System time (seconds): 2.63 Percent of CPU this job got: 403% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:07.93 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 145368 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 735962 Voluntary context switches: 2626 Involuntary context switches: 9964 Swaps: 0 File system inputs: 0 File system outputs: 20312 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0