Re: `time ( someCmd )` Doesn't Print Time Under 5.2
On 11/22/22 5:04 PM, Dabrien 'Dabe' Murphy wrote: On 11/22/22 5:01 PM, Chet Ramey wrote: Thanks for the report. It's an easy fix; bash was optimizing away the fork and therefore not printing the timing information. Awesome! Hitting it with a hammer: $10 Knowing WHERE to hit it: $9,990 Well, it's not a big hammer. It was a one-line change. :-) -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: `time ( someCmd )` Doesn't Print Time Under 5.2
On 11/21/22 9:36 PM, Dabrien 'Dabe' Murphy wrote: More crumbs, FTR: 19:51 this comment looks very suspicious https://git.savannah.gnu.org/cgit/bash.git/diff/execute_cmd.c?h=devel=9928dcb48f35d957d936f9c6d8bec8cec8b76317 19:52 that patch addresses this bug https://lists.gnu.org/archive/html/bug-bash/2021-09/msg00047.html No, all that stuff is a red herring. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: `time ( someCmd )` Doesn't Print Time Under 5.2
On 11/22/22 5:01 PM, Chet Ramey wrote: Thanks for the report. It's an easy fix; bash was optimizing away the fork and therefore not printing the timing information. Awesome! Hitting it with a hammer: $10 Knowing WHERE to hit it: $9,990 «grin» -- :- Dabe
Re: `time ( someCmd )` Doesn't Print Time Under 5.2
On 11/21/22 7:07 PM, d...@dabe.com wrote: Bash Version: 5.2 Patch Level: 9 Release Status: release Description: Under 5.2.x, measuring the `time` of a subshell -- `time ( sleep 1 )` for example -- doesn't display any timing information, whereas `5.1.x` and before did. Thanks for the report. It's an easy fix; bash was optimizing away the fork and therefore not printing the timing information. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: `time ( someCmd )` Doesn't Print Time Under 5.2
On 11/21/22 9:32 PM, Koichi Murase wrote: `git bisect' finds the following commit (2022-01-31) which introduced the behavior: commit b325b0e96bd05c76bbfc4d60d0707fc93d58f03f (HEAD, refs/bisect/bad) execute_cmd.c - execute_in_subshell: call optimize_subshell_command for (list) subshells to either set CMD_NO_FORK for simple commands or set CMD_TRY_OPTIMIZING for likely candidates for later optimization More crumbs, FTR: 19:51 this comment looks very suspicious https://git.savannah.gnu.org/cgit/bash.git/diff/execute_cmd.c?h=devel=9928dcb48f35d957d936f9c6d8bec8cec8b76317 19:52 that patch addresses this bug https://lists.gnu.org/archive/html/bug-bash/2021-09/msg00047.html -- :- Dabe
Re: `time ( someCmd )` Doesn't Print Time Under 5.2
2022年11月22日(火) 9:36 Emanuele Torre : > No, actually later, I said that it has probably been introduced earlier > since I tried running 'time (sleep 1)' in a version of bash that > preceeds that change (namely 6711d2dc7793ed3d35e91b2bd4ecbdfccfcf469f > (2022-10-24)), and it still didn't print the timing report. `git bisect' finds the following commit (2022-01-31) which introduced the behavior: > commit b325b0e96bd05c76bbfc4d60d0707fc93d58f03f (HEAD, refs/bisect/bad) > Author: Chet Ramey > Date: Mon Jan 31 09:53:03 2022 -0500 > > more changes for here-docs and $'...'; command optimization updates > > [CWRU/CWRU.chlog] > >1/25 > > parse.y > - parse_matched_pair: ansi-expand $'...' in WORD for ${PARAM OP WORD} > and single-quote the result if dolbrace_state == DOLBRACE_QUOTE > (posix pattern removal operators) even if extended_quote == 0 > > subst.c > - extract_heredoc_dolbrace_string: add logic to align with parse.y: > parse_matched_pair and its $'...' expansion, including handling > extended_quote > >1/27 > > builtins/evalstring.c > - should_optimize_fork: broke conditions for optimizing away the fork > for a simple command out of optimize_fork into new function, call > from should_suppress_fork and optimize_subshell_command. Call from > optimize_fork if (subshell_environment & SUBSHELL_PAREN), relying > on fact that CMD_TRY_OPTIMIZING is only set in a couple of specific > conditions > - optimize_fork: call should_suppress_fork only if startup_state == 2; > it does the extra checks for that specific case > - optimize_fork: call should_optimize_fork if we're in a (list) > subshell (subshell_environment & SUBSHELL_PAREN) > - optimize_subshell_command: set CMD_TRY_OPTIMIZING on the right side > of a `&&', `||', or `;' list as long as it's a simple command so > we can check with optimize_fork() when it's time to execute it > > execute_cmd.c > - execute_in_subshell: call optimize_subshell_command for (list) > subshells to either set CMD_NO_FORK for simple commands or set > CMD_TRY_OPTIMIZING for likely candidates for later optimization > > builtins/common.h,builtins/evalstring.c > - optimize_fork: renamed to optimize_connection_fork; changed callers
Re: `time ( someCmd )` Doesn't Print Time Under 5.2
On 11/21/22 7:36 PM, Emanuele Torre wrote: On Mon, Nov 21, 2022 at 07:07:08PM -0500, d...@dabe.com wrote: emanuele6 suspects it has to do with https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00107.html No, actually later, I said that it has probably been introduced earlier since I tried running 'time (sleep 1)' in a version of bash that preceeds that change (namely 6711d2dc7793ed3d35e91b2bd4ecbdfccfcf469f (2022-10-24)), and it still didn't print the timing report. Mea culpa... Thanks for the clarification! :-D -- :- Dabe
Re: `time ( someCmd )` Doesn't Print Time Under 5.2
On Mon, Nov 21, 2022 at 07:07:08PM -0500, d...@dabe.com wrote: > emanuele6 suspects it has to do with > https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00107.html No, actually later, I said that it has probably been introduced earlier since I tried running 'time (sleep 1)' in a version of bash that preceeds that change (namely 6711d2dc7793ed3d35e91b2bd4ecbdfccfcf469f (2022-10-24)), and it still didn't print the timing report. But I said it may have something to do with bash running some code that should run in the main shell, in the subshell that runs the command, since bash 5.2 prints timing information for `time (echo hi)' (builtin command), but not for `time (/bin/echo hi)' (external command). But I have not investigated what is the actual cause of the issue. emanuele6
`time ( someCmd )` Doesn't Print Time Under 5.2
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: darwin22.1.0 Compiler: clang Compilation CFLAGS: -DSSH_SOURCE_BASHRC uname output: Darwin triton.parabon.com 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64 x86_64 Machine Type: x86_64-apple-darwin22.1.0 Bash Version: 5.2 Patch Level: 9 Release Status: release Description: Under 5.2.x, measuring the `time` of a subshell -- `time ( sleep 1 )` for example -- doesn't display any timing information, whereas `5.1.x` and before did. Builtins work[*] but if "someCmd" includes an external program, bupkis: bash-5.2% time ( sleep 1 ) # No timing output bash-5.2% time ( sleep 1 /dev/null ) # Okay bash-5.2% time ( sleep 1 ) /dev/null # No timing output bash-5.2% time ( sleep 1 ) | cat# Okay bash-5.2% time ( sleep 1 ) > >(cat) # No timing output bash-5.2% time ( exec 2>/dev/null; : ) # Builtin(s), but no timing output (/dev/fd/2 leaks?) bash-5.2% time ( echo Hi ) # Okay (Builtin) bash-5.2% time ( exec echo Hi ) # No timing output bash-5.2% time ( eval echo Hi ) # Okay bash-5.2% time ( eval sleep 1 ) # Okay (...!) bash-5.2% time ( eval exec echo Hi )# No timing output bash-5.2% time ( { sleep 1; } ) # Okay, FWIW bash-5.2% time { ( sleep 1 ); } # Okay, FWIW emanuele6 suspects it has to do with https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00107.html Also: i tried to run this script bash 5.2 with little memory .source_code/bash/bash -c 'ulimit -v 5000; for (( x = 0; i < 200; ++i )); do echo "$i"; time (:); done' it fails after 20 calls with OOM and in bash 5.1, that code runs without problems