Skip to content

tee: increase buf size for large input#11441

Merged
sylvestre merged 1 commit intouutils:mainfrom
oech3:tee-pv
Apr 4, 2026
Merged

tee: increase buf size for large input#11441
sylvestre merged 1 commit intouutils:mainfrom
oech3:tee-pv

Conversation

@oech3
Copy link
Copy Markdown
Contributor

@oech3 oech3 commented Mar 21, 2026

taskset -c 1 yes|taskset -c 2 target/release/tee|taskset -c 3 pv>/dev/null

This PR: [3.83GiB/s]
gnu58d88d243/tee: [2.83GiB/s]
closes #11432

@xtqqczze
Copy link
Copy Markdown
Contributor

The existing code is documented to use same DEFAULT_BUF_SIZE as Rust std library for the stack allocated array.

@xtqqczze
Copy link
Copy Markdown
Contributor

GNU coreutils uses IO_BUFSIZE = 256 * 1024, we have overhead from zero-initialization though.

@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Mar 21, 2026

Optimal value might different at each PC. 64*1024 was best for me.

@oech3

This comment was marked as outdated.

@oech3

This comment was marked as outdated.

@xtqqczze
Copy link
Copy Markdown
Contributor

taskset -c 1 yes|taskset -c 2 target/release/tee|taskset -c 3 pv>/dev/null

This measures throughput in the most ideal scenario for a large buffer, we should ensure performance does not regress in other cases where output is small.

@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Mar 21, 2026

Time for small input is bounded. But I could use smaller buf only for 1st cycle.

@xtqqczze
Copy link
Copy Markdown
Contributor

Please test something like: taskset -c 1 yes | head -c 8192 | taskset -c 2 target/release/tee|taskset -c 3 pv>/dev/null

@oech3

This comment was marked as outdated.

@oech3 oech3 force-pushed the tee-pv branch 3 times, most recently from 6897cbc to 0a8e582 Compare March 21, 2026 14:30
@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Mar 21, 2026

I added a code path for smaller input. There is variance at
taskset -c 1 hyperfine --runs 100 -N --warmup 10 -- "target/release/tee8 <in" "target/release/tee64 <in" "target/release/tee8and64 <in",

Both of win and lose happen at tee8and64 vs tee8, but tee64 never win.

@oech3 oech3 force-pushed the tee-pv branch 2 times, most recently from 7c43c1f to dac8b97 Compare March 21, 2026 16:38
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/symlink (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/symlink (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/follow-name (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tail/pipe-f2 is no longer failing!
Note: The gnu test tests/cut/bounded-memory is now being skipped but was previously passing.
Note: The gnu test tests/expand/bounded-memory is now being skipped but was previously passing.

@sylvestre
Copy link
Copy Markdown
Contributor

needs to be rebased

@oech3 oech3 changed the title tee: increase buf size for |pv>/dev/null tee: increase buf size for large input Mar 24, 2026
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

@xtqqczze
Copy link
Copy Markdown
Contributor

I added a code path for smaller input.

@oech3 Could you quantify the performance improvement from the additional code path to justify the added complexity?

@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Mar 24, 2026

This PR was opened for larger files. Mostly 0 perf change for small files.

@sylvestre
Copy link
Copy Markdown
Contributor

Please add a benchmark in a different PR
Once it is landed, we will retrigger this one to evaluate the performance impact
thanks

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)

@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Mar 24, 2026

Is it equivalint with

truncate -s SIZE b
time tee < b >/dev/null

?

@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Mar 24, 2026

How to use stdin at benchmark?

@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Mar 25, 2026

Would you suggest how to use stdin at CodSpeed?

@sylvestre sylvestre merged commit 13fb3be into uutils:main Apr 4, 2026
162 checks passed
@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Apr 4, 2026

We don't have bench for stream yet. Was this really OK to merge?

@oech3 oech3 deleted the tee-pv branch April 4, 2026 10:41
@sylvestre
Copy link
Copy Markdown
Contributor

you did some testing, i trust you :)

@aidanharris
Copy link
Copy Markdown

This broke on my Gentoo system for some reason:

git bisect start
# status: waiting for both good and bad commits
# bad: [c4093734e2ebe2efb7d65e216cd1444664bcf26a] ci: install hu_HU.UTF-8 (and peers) for l10n cargo test job
git bisect bad c4093734e2ebe2efb7d65e216cd1444664bcf26a
# status: waiting for good commit(s), bad commit known
# good: [995c9e04a6cc34a3a95b23a26fa59ae87e7744bd] date: Remove eprintln! to avoid 2>/dev/full abort (#11228)
git bisect good 995c9e04a6cc34a3a95b23a26fa59ae87e7744bd
# good: [e71e022464b3779fb94c11829dffe3db6e745021] pre-commit: add Cargo.lock sync check
git bisect good e71e022464b3779fb94c11829dffe3db6e745021
# good: [8b98d18e22851cd604ccbf0c30a582c579ea837b] tail: fix clippy warnings on wasi target
git bisect good 8b98d18e22851cd604ccbf0c30a582c579ea837b
# skip: [8d03a6aaf90bd77af8e9fc0fc5be23b9fa0e7584] numfmt: add GNU test patch for devdebug, help-1, and field-range errors
git bisect skip 8d03a6aaf90bd77af8e9fc0fc5be23b9fa0e7584
# skip: [32a58cc7fd2651ee328c278100ccefcefe1d685a] numfmt: add unit tests for detailed_error_message, parse_number_part, and apply_grouping
git bisect skip 32a58cc7fd2651ee328c278100ccefcefe1d685a
# bad: [12cdba237ee8fa954c6b93818a555313d60ffa01] df: source SI/IEC bases from uucore::parser::parse_size
git bisect bad 12cdba237ee8fa954c6b93818a555313d60ffa01
# skip: [45af2375a39e7d2430d85d22a97a4ebf22fc5072] numfmt: replace double-reverse with forward pass in apply_grouping
git bisect skip 45af2375a39e7d2430d85d22a97a4ebf22fc5072
# bad: [774431672a6b8c424e8d037699150bd6a7040879] build: embed all locale files when targeting WASI
git bisect bad 774431672a6b8c424e8d037699150bd6a7040879
# good: [4ceb880a877e081b385195710e82e920f8c96f5d] uucore: add a function returning /dev/null to use splice() for wc,dd,tail
git bisect good 4ceb880a877e081b385195710e82e920f8c96f5d
# bad: [13fb3bede8185bfe12d0579027dfd6ab13793185] tee: increase buf size for large input
git bisect bad 13fb3bede8185bfe12d0579027dfd6ab13793185
# good: [49e7a6b53218bbd72a29a9719ed377ee46d8eada] perf(uucore): call rt_sigaction once not 62 times
git bisect good 49e7a6b53218bbd72a29a9719ed377ee46d8eada
# good: [60d448be4825e5e1a4ebbb2cbb74f562a9c899ea] uucore: add missing fs feature to rustix
git bisect good 60d448be4825e5e1a4ebbb2cbb74f562a9c899ea
# first bad commit: [13fb3bede8185bfe12d0579027dfd6ab13793185] tee: increase buf size for large input

Reproducer

gentoo-reproducer.bats

#!/usr/bin/env bats

good_commit="60d448be4825e5e1a4ebbb2cbb74f562a9c899ea"
bad_commit="13fb3bede8185bfe12d0579027dfd6ab13793185"

setup() {
        [ -d /var/db/repos/gentoo/dev-lang/rust-bin ] || emerge-webrsync
        command -v rustc || emerge -q1 dev-lang/rust-bin
        command -v git || emerge -q1 dev-vcs/git
        keyword_file="/etc/portage/package.accept_keywords/uutils"
        [ -e "$keyword_file" ] || printf "%s **\n" sys-apps/uutils-coreutils > "$keyword_file"
        [ -e /usr/bin/gnu-tee ] || cp -afv /usr/bin/tee /usr/bin/gnu-tee
}

teardown() {
        echo "Restoring GNU tee"
        cp -afv /usr/bin/gnu-tee /usr/bin/tee
}

@test "uucore: add missing fs feature to rustix $good_commit" {
        env EGIT_OVERRIDE_COMMIT_UUTILS_COREUTILS="$good_commit" emerge -q1 uutils-coreutils
        cp -afv /usr/bin/uu-tee /usr/bin/tee
        emerge -v1 sys-apps/portage
}

@test "tee: increase buf size for large input $bad_commit" {
        env EGIT_OVERRIDE_COMMIT_UUTILS_COREUTILS="$bad_commit" emerge -q1 uutils-coreutils
        cp -afv /usr/bin/uu-tee /usr/bin/tee
        emerge -v1 sys-apps/portage
}

Run it like:

docker run -it --rm --pull always -v $PWD/gentoo-reproducer.bats:/gentoo-reproducer.bats gentoo/stage3 bash -x -c 'cat /gentoo-reproducer.bats && emerge-webrsync && emerge -q1 dev-util/bats && bats --verbose-run --trace --formatter tap /gentoo-reproducer.bats'

Output

+ cat /gentoo-reproducer.bats
#!/usr/bin/env bats

good_commit="60d448be4825e5e1a4ebbb2cbb74f562a9c899ea"
bad_commit="13fb3bede8185bfe12d0579027dfd6ab13793185"

setup() {
        [ -d /var/db/repos/gentoo/dev-lang/rust-bin ] || emerge-webrsync
        command -v rustc || emerge -q1 dev-lang/rust-bin
        command -v git || emerge -q1 dev-vcs/git
        keyword_file="/etc/portage/package.accept_keywords/uutils"
        [ -e "$keyword_file" ] || printf "%s **\n" sys-apps/uutils-coreutils > "$keyword_file"
        [ -e /usr/bin/gnu-tee ] || cp -afv /usr/bin/tee /usr/bin/gnu-tee
}

teardown() {
        echo "Restoring GNU tee"
        cp -afv /usr/bin/gnu-tee /usr/bin/tee
}

@test "uucore: add missing fs feature to rustix $good_commit" {
        env EGIT_OVERRIDE_COMMIT_UUTILS_COREUTILS="$good_commit" emerge -q1 uutils-coreutils
        cp -afv /usr/bin/uu-tee /usr/bin/tee
        emerge -v1 sys-apps/portage
}

@test "tee: increase buf size for large input $bad_commit" {
        env EGIT_OVERRIDE_COMMIT_UUTILS_COREUTILS="$bad_commit" emerge -q1 uutils-coreutils
        cp -afv /usr/bin/uu-tee /usr/bin/tee
        emerge -v1 sys-apps/portage
}
+ emerge-webrsync
!!! Section 'gentoo' in repos.conf has location attribute set to nonexistent directory: '/var/db/repos/gentoo'
!!! Invalid Repository Location (not a dir): '/var/db/repos/gentoo'
 * PGP verification method: gemato
 * Fetching most recent snapshot ...
 * Trying to retrieve 20260405 snapshot from http://distfiles.gentoo.org ...
 * Fetching file gentoo-20260405.tar.xz.md5sum ...

/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz.m   0%[                                                                                                                                ]       0  --.-KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz.m 100%[===============================================================================================================================>]      57  --.-KB/s    in 0s      
2026-04-06 17:42:49 URL:http://distfiles.gentoo.org/snapshots/gentoo-20260405.tar.xz.md5sum [57/57] -> "/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz.md5sum" [1]
 * Fetching file gentoo-20260405.tar.xz.gpgsig ...

/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz.g   0%[                                                                                                                                ]       0  --.-KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz.g 100%[===============================================================================================================================>]    1000  --.-KB/s    in 0s      
2026-04-06 17:42:50 URL:http://distfiles.gentoo.org/snapshots/gentoo-20260405.tar.xz.gpgsig [1000/1000] -> "/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz.gpgsig" [1]
 * Fetching file gentoo-20260405.tar.xz ...

/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     0%[                                                                                                                                ]       0  --.-KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     0%[                                                                                                                                ]  14.91K  54.5KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     0%[                                                                                                                                ]  42.80K  78.2KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     0%[                                                                                                                                ]  77.67K   103KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     0%[                                                                                                                                ] 127.87K   133KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     0%[                                                                                                                                ] 198.99K   170KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     0%[                                                                                                                                ] 331.47K   242KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     1%[>                                                                                                                               ] 536.47K   341KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     1%[=>                                                                                                                              ] 889.28K   502KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     3%[===>                                                                                                                            ]   1.43M   745KB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     5%[=====>                                                                                                                          ]   2.40M  1.10MB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz     8%[==========>                                                                                                                     ]   3.98M  1.68MB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    14%[=================>                                                                                                              ]   6.58M  2.56MB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    16%[====================>                                                                                                           ]   7.55M  2.71MB/s               
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    19%[=======================>                                                                                                        ]   8.79M  2.91MB/s    eta 13s    
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    27%[==================================>                                                                                             ]  12.60M  3.91MB/s    eta 13s    
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    34%[==========================================>                                                                                     ]  15.67M  4.97MB/s    eta 13s    
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    35%[============================================>                                                                                   ]  16.31M  5.01MB/s    eta 13s    
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    36%[=============================================>                                                                                  ]  16.82M  5.24MB/s    eta 13s    
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    37%[===============================================>                                                                                ]  17.30M  5.23MB/s    eta 7s     
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    38%[================================================>                                                                               ]  17.80M  5.28MB/s    eta 7s     
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    40%[==================================================>                                                                             ]  18.60M  5.55MB/s    eta 7s     
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    42%[=====================================================>                                                                          ]  19.64M  5.71MB/s    eta 7s     
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    50%[===============================================================>                                                                ]  23.14M  6.67MB/s    eta 7s     
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    59%[==========================================================================>                                                     ]  27.15M  7.60MB/s    eta 4s     
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    61%[=============================================================================>                                                  ]  28.14M  7.59MB/s    eta 4s     
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    64%[=================================================================================>                                              ]  29.56M  7.51MB/s    eta 4s     
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    74%[==============================================================================================>                                 ]  34.33M  8.19MB/s    eta 4s     
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz    91%[====================================================================================================================>           ]  42.02M  10.1MB/s    eta 4s     
/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz   100%[===============================================================================================================================>]  45.91M  11.1MB/s    in 6.3s    
2026-04-06 17:42:57 URL:http://distfiles.gentoo.org/snapshots/gentoo-20260405.tar.xz [48140628/48140628] -> "/var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz" [1]
 * Checking digest ...
 * Checking signature with gemato ...
[   INFO] Refreshing keys...
[   INFO] Keys refreshed.
[   INFO] File /var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz verified successfully against the signature in /var/tmp/emerge-webrsync.gWQrD2/gentoo-20260405.tar.xz.gpgsig:
[   INFO] - status: OpenPGPSignatureStatus.GOOD
[   INFO] - valid: True, trusted: True
[   INFO] - primary key: DCD05B71EAB94199527F44ACDB6B8C1F96D8BF6D
[   INFO] - subkey: E1D6ABB63BFCFB4BA02FDF1CEC590EEAC9189250
[   INFO] - timestamp: 2026-04-06 00:50:11 UTC
 * Getting snapshot timestamp ...
 * Extracting 'gentoo-20260405.tar.xz' ...
 * Using rsync to refresh '/var/db/repos/gentoo' ...

Number of files: 156,524 (reg: 128,938, dir: 27,586)
Number of created files: 156,523 (reg: 128,938, dir: 27,585)
Number of deleted files: 0
Number of regular files transferred: 128,938
Total file size: 236.06M bytes
Total transferred file size: 236.06M bytes
Literal data: 236.06M bytes
Matched data: 0 bytes
File list size: 2.92M
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 120.64M
Total bytes received: 2.57M

sent 120.64M bytes  received 2.57M bytes  9.86M bytes/sec
total size is 236.06M  speedup is 1.92

Performing Global Updates
(Could take a couple of minutes if you have a lot of binary packages.)


�]0;724f536406a2: emerge�
 * IMPORTANT:�[39;49;00m 18 news items need reading for repository 'gentoo'.
 *�[39;49;00m Use eselect news read�[39;49;00m to view new items.

�]0;@724f536406a2:/var/tmp/emerge-webrsync.gWQrD2/snapshot�+ emerge -q1 dev-util/bats
�]0;724f536406a2: emerge�
 * IMPORTANT:�[39;49;00m 18 news items need reading for repository 'gentoo'.
 *�[39;49;00m Use eselect news read�[39;49;00m to view new items.

>>> Verifying ebuild manifests�E>>> Emerging (1�[39;49;00m of 1�[39;49;00m) dev-util/bats-1.13.0::gentoo�[39;49;00m�E�]0;724f536406a2: emerge: (1 of 1) dev-util/bats-1.13.0 Clean��]0;724f536406a2: emerge: (1 of 1) dev-util/bats-1.13.0 Compile�>>> Installing (1�[39;49;00m of 1�[39;49;00m) dev-util/bats-1.13.0::gentoo�[39;49;00m�E�]0;724f536406a2: emerge: (1 of 1) dev-util/bats-1.13.0 Merge��]0;724f536406a2: emerge: (1 of 1) dev-util/bats-1.13.0 Clean Post�>>> Completed (1�[39;49;00m of 1�[39;49;00m) dev-util/bats-1.13.0::gentoo�[39;49;00m�E
 * �[39;49;00mMessages for package dev-util/bats-1.13.0�[39;49;00m:

 * �[39;49;00mInstall additional packages for optional runtime features:
 * �[39;49;00m  sys-process/parallel for Parallel Execution

 * IMPORTANT:�[39;49;00m 18 news items need reading for repository 'gentoo'.
 *�[39;49;00m Use eselect news read�[39;49;00m to view new items.

�]0;@724f536406a2:/�+ bats --verbose-run --trace --formatter tap /gentoo-reproducer.bats
1..2
$ [gentoo-reproducer.bats, line 16]
$ echo "Restoring GNU tee"
$ cp -afv /usr/bin/gnu-tee /usr/bin/tee
ok 1 uucore: add missing fs feature to rustix 60d448be4825e5e1a4ebbb2cbb74f562a9c899ea
not ok 2 tee: increase buf size for large input 13fb3bede8185bfe12d0579027dfd6ab13793185
# (in test file gentoo-reproducer.bats, line 29)
#   `emerge -v1 sys-apps/portage' failed
# $ [gentoo-reproducer.bats, line 7]
# $ [ -d /var/db/repos/gentoo/dev-lang/rust-bin ]
# $ command -v rustc
# /usr/sbin/rustc
# $ command -v git
# /usr/sbin/git
# $ keyword_file="/etc/portage/package.accept_keywords/uutils"
# $ [ -e "$keyword_file" ]
# $ [ -e /usr/bin/gnu-tee ]
# $ "$@"
# $ env EGIT_OVERRIDE_COMMIT_UUTILS_COREUTILS="$bad_commit" emerge -q1 uutils-coreutils
# >>> Verifying ebuild manifests
#
#  * IMPORTANT: 18 news items need reading for repository 'gentoo'.
#  * Use eselect news read to view new items.
#
# >>> Emerging (1 of 1) sys-apps/uutils-coreutils-9999::gentoo
# >>> Installing (1 of 1) sys-apps/uutils-coreutils-9999::gentoo
# >>> Completed (1 of 1) sys-apps/uutils-coreutils-9999::gentoo
#
#  * Messages for package sys-apps/uutils-coreutils-9999:
#
#  * Using EGIT_OVERRIDE_COMMIT_UUTILS_COREUTILS=13fb3bede8185bfe12d0579027dfd6ab13793185
#  * No support will be provided.
#
#  * IMPORTANT: 18 news items need reading for repository 'gentoo'.
#  * Use eselect news read to view new items.
#
# $ cp -afv /usr/bin/uu-tee /usr/bin/tee
# '/usr/bin/uu-tee' -> '/usr/bin/tee'
# $ emerge -v1 sys-apps/portage
#
#  * IMPORTANT: 18 news items need reading for repository 'gentoo'.
#  * Use eselect news read to view new items.
#
#
# These are the packages that would be merged, in order:
#
# Calculating dependencies  ... done!
# Dependency resolution took 0.48 s (backtrack: 0/20).
#
# [ebuild   R    ] sys-apps/portage-3.0.77-r4::gentoo  USE="(ipc) native-extensions rsync-verify xattr -apidoc -build -doc -gentoo-dev (-selinux) -test" PYTHON_TARGETS="python3_13 -python3_12 -python3_14" 0 KiB
#
# Total: 1 package (1 reinstall), Size of downloads: 0 KiB
#
#
# >>> Verifying ebuild manifests
#
# >>> Running pre-merge checks for sys-apps/portage-3.0.77-r4
# Unable to unshare: EPERM (for FEATURES="pid-sandbox")
#  * Determining the location of the kernel source code
#  * Unable to find kernel sources at /usr/src/linux
#  * Please make sure that /usr/src/linux points at your running kernel,
#  * (or the kernel you wish to build against).
#  * Alternatively, set the KERNEL_DIR environment variable to the kernel sources location
#  * Unable to calculate Linux Kernel version for build, attempting to use running version
#  * Checking for suitable kernel configuration options ...
# �[A�[72C [ ok ]
# Unable to unshare: EPERM (for FEATURES="ipc-sandbox network-sandbox pid-sandbox")
#
# >>> Emerging (1 of 1) sys-apps/portage-3.0.77-r4::gentoo
# Unable to unshare: EPERM (for FEATURES="ipc-sandbox network-sandbox pid-sandbox")
#  * portage-3.0.77.tar.bz2 BLAKE2B SHA512 size ;-) ...                    [ ok ]
# Unable to unshare: EPERM (for FEATURES="pid-sandbox")
#  * Determining the location of the kernel source code
#  * Unable to find kernel sources at /usr/src/linux
#  * Please make sure that /usr/src/linux points at your running kernel,
#  * (or the kernel you wish to build against).
#  * Alternatively, set the KERNEL_DIR environment variable to the kernel sources location
#  * Unable to calculate Linux Kernel version for build, attempting to use running version
# Unable to unshare: EPERM (for FEATURES="ipc-sandbox network-sandbox pid-sandbox")
# >>> Unpacking source...
# >>> Unpacking 'portage-3.0.77.tar.bz2' to /var/tmp/portage/sys-apps/portage-3.0.77-r4/work
# >>> Source unpacked in /var/tmp/portage/sys-apps/portage-3.0.77-r4/work
# Unable to unshare: EPERM (for FEATURES="ipc-sandbox network-sandbox pid-sandbox")
# >>> Preparing source in /var/tmp/portage/sys-apps/portage-3.0.77-r4/work/portage-3.0.77 ...
#  * Applying 0001-estrip-silence-noise-from-objcopy-if-build-ID-sectio.patch ...
# �[A�[72C [ ok ]
#  * Applying 0002-Revert-depgraph-earlier-slot-operator-backtracking.patch ...
# �[A�[72C [ ok ]
#  * Applying 0003-estrip-Don-t-break-the-debuglink-CRC-with-the-salted.patch ...
# patching file NEWS
# Hunk #1 succeeded at 6 with fuzz 2 (offset -64 lines).
# patching file bin/estrip
# �[A�[72C [ ok ]
# >>> Source prepared.
# Unable to unshare: EPERM (for FEATURES="ipc-sandbox network-sandbox pid-sandbox")
# >>> Configuring source in /var/tmp/portage/sys-apps/portage-3.0.77-r4/work/portage-3.0.77 ...
#  * python3_13: running my_src_configure
#
# >>> Failed to emerge sys-apps/portage-3.0.77-r4, Log file:
#
# >>>  '/var/tmp/portage/sys-apps/portage-3.0.77-r4/temp/build.log'
#
#  * Messages for package sys-apps/portage-3.0.77-r4:
#
#  * Unable to find kernel sources at /usr/src/linux
#  * Unable to calculate Linux Kernel version for build, attempting to use running version
#
#  * Messages for package sys-apps/portage-3.0.77-r4:
#
#  * Unable to find kernel sources at /usr/src/linux
#  * Unable to calculate Linux Kernel version for build, attempting to use running version
#  * ERROR: sys-apps/portage-3.0.77-r4::gentoo failed (configure phase):
#  *   configure failed
#  * Call stack:
#  *     ebuild.sh, line  143:  Called src_configure
#  *   environment, line 3384:  Called python_foreach_impl 'my_src_configure'
#  *   environment, line 2704:  Called multibuild_foreach_variant '_python_multibuild_wrapper' 'my_src_configure'
#  *   environment, line 2384:  Called _multibuild_run '_python_multibuild_wrapper' 'my_src_configure'
#  *   environment, line 2382:  Called _python_multibuild_wrapper 'my_src_configure'
#  *   environment, line  800:  Called my_src_configure
#  *   environment, line 2411:  Called meson_src_configure
#  *   environment, line 2316:  Called die
#  * The specific snippet of code:
#  *       [[ ${rv} -eq 0 ]] || die -n "configure failed";
#  * If you need support, post the output of `emerge --info '=sys-apps/portage-3.0.77-r4::gentoo'`,
#  * the complete build log and the output of `emerge -pqv '=sys-apps/portage-3.0.77-r4::gentoo'`.
#  * The complete build log is located at '/var/tmp/portage/sys-apps/portage-3.0.77-r4/temp/build.log'.
#  * The ebuild environment file is located at '/var/tmp/portage/sys-apps/portage-3.0.77-r4/temp/environment'.
#  * Working directory: '/var/tmp/portage/sys-apps/portage-3.0.77-r4/work/portage-3.0.77'
#  * S: '/var/tmp/portage/sys-apps/portage-3.0.77-r4/work/portage-3.0.77'
# Restoring GNU tee
# '/usr/bin/gnu-tee' -> '/usr/bin/tee'

@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Apr 6, 2026 via email

@aidanharris
Copy link
Copy Markdown

I don't know why yet. I'll try to find out. I made a wrapper like this at /usr/bin/tee:

#!/bin/sh
echo "tee $@" >> /tmp/tee-invoc.txt
exec uu-tee "$@"

The last thing it ran was:

tee -a /var/tmp/portage/sys-apps/portage-3.0.77-r4/temp/build-python3_12.log

I don't know what was on the other end of the pipe to cause it to break though. I'll try to find it.

@aidanharris
Copy link
Copy Markdown

Claude was able to spot the issue:
https://claude.ai/share/08c9e543-1233-4428-8969-186efadd8bb7

The sanity check it came up with:

(for i in $(seq 5); do echo "line $i"; sleep 0.1; done) \
  | ./target/release/coreutils tee /tmp/portage_log_test.log
line 1

With Busybox tee:

(for i in $(seq 5); do echo "line $i"; sleep 0.1; done) \
  | busybox tee /tmp/portage_log_test.log
line 1
line 2
line 3
line 4
line 5

// flush the buffer to comply with POSIX requirement that
// `tee` does not buffer the input.
output.flush()?;
return Ok(len);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe, this return caused it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tee: slower than GNU

4 participants