[TUHS] Lorinda Cherry

Otto Moerbeek otto at drijf.net
Fri Feb 18 18:33:49 AEST 2022


On Thu, Feb 17, 2022 at 01:44:07PM -0800, Bakul Shah wrote:

> On Feb 17, 2022, at 1:18 PM, Dave Horsfall <dave at horsfall.org> wrote:
> > 
> > On Thu, 17 Feb 2022, Tom Ivar Helbekkmo via TUHS wrote:
> > 
> >> Watching the prime number generator (from the Wikipedia page on dc) 
> >> running on the 11/23 is much more entertaining than doing it on the 
> >> modern workstation I'm typing this on:
> >> 
> >> 2p3p[dl!d2+s!%0=@l!l^!<#]s#[s/0ds^]s@[p]s&[ddvs^3s!l#x0<&2+l.x]ds.x
> > 
> > Wow...  About 10s on my old MacBook Pro, and I gave up on my ancient 
> > FreeBSD box.
> 
> That may be because FreeBSD continues computing primes while the MacOS
> dc gives up after a while!
> 
> freebsd (ryzen 2700 3.2Ghz): # note: I interrupted dc after a while
> $ command time dc <<< '2p3p[dl!d2+s!%0=@l!l^!<#]s#[s/0ds^]s@[p]s&[ddvs^3s!l#x0<&2+l.x]ds.x' > xxx
> ^C       11.93 real        11.79 user         0.13 sys
> $ wc xxx
>    47161   47161  319109 xxx
> $ size `which dc`
>     text   data     bss      dec       hex   filename
>   238159   2784   11072   252015   0x3d86f   /usr/bin/dc
> 
> MacOS (m1 pro, prob. 2Ghz)
> $ command time dc <<< '2p3p[dl!d2+s!%0=@l!l^!<#]s#[s/0ds^]s@[p]s&[ddvs^3s!l#x0<&2+l.x]ds.x' > xxx
> time: command terminated abnormally
>         1.00 real         0.98 user         0.01 sys
> [2]    37135 segmentation fault  command time dc <<<  > xxx
> $ wc xxx
>     7342    7342   42626 xxx
> $ size `which dc`
> __TEXT	__DATA	__OBJC	others	dec	hex
> 32768	16384	0	4295016448	4295065600	100018000
> 

MacOS uses the GNU implementation which has a long standing issue with
deep recursion. It even cannot handle the tail recursive calls used
here and will run out of its stack.

	-Otto


More information about the TUHS mailing list