Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

*Excruciatingly* slow (over ten seconds for `(+ 1 1)`) with language "How To Design Programs - Beginning Student"

Tags:

racket

htdp

I just installed DrRacket, and tried out the language "How To Design Programs - Beginning Student".

Racket - A programmable programming language

Racket - Getting Started

I run (+ 1 1), and it takes over ten seconds for this to show up:

Welcome to DrRacket, version 6.5 [3m].
Language: Beginning Student; memory limit: 128 MB.
2
> 

As far as I can tell, my installation is pretty much "out of the box".

What I'm wondering is if my experience is unusual,
and if there's any obvious way to troubleshoot it if so
(I've looked around the settings and didn't find anything obvious to tweak),
or if maybe the whole HTDP language was quietly abandoned or something...?

EDIT 1

I have these files:

/usr/share/racket $
find -iname "*htdp*.zo"
./pkgs/htdp-lib/lang/private/compiled/create-htdp-executable_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-reader_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-beginner-abbr-reader_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-langs-save-file-prefix_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-advanced-reader_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-intermediate-lambda-reader_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-advanced_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-beginner-abbr_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-intermediate_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-intermediate-reader_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-langs_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-beginner_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-intermediate-lambda_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-beginner-reader_rkt.zo
./pkgs/htdp-doc/scribblings/htdp-langs/compiled/htdp-langs_scrbl.zo
./pkgs/htdp-doc/scribblings/htdp-langs/compiled/htdp-ptr_scrbl.zo
./pkgs/htdp-doc/htdp/compiled/htdp_scrbl.zo
./pkgs/htdp-doc/htdp/compiled/htdp-lib_scrbl.zo
./pkgs/htdp-doc/teachpack/htdp/scribblings/compiled/htdp_scrbl.zo
./pkgs/htdp-doc/teachpack/2htdp/scribblings/compiled/2htdp_scrbl.zo

EDIT 2 - cpu and harddrive specs

CPU

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model               : 28
model name      : Intel(R) Atom(TM) CPU N450   @ 1.66GHz
stepping        : 10
microcode       : 0x107
cpu MHz             : 1000.000
cache size      : 512 KB
physical id     : 0
siblings        : 2
core id             : 0
cpu cores       : 1
apicid              : 0
initial apicid  : 0
fpu                 : yes
fpu_exception   : yes
cpuid level     : 10
wp                  : yes
flags               : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm movbe lahf_lm dtherm
bugs                :
bogomips        : 3325.00
clflush size    : 64
cache_alignment : 64
address sizes   : 32 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model               : 28
model name      : Intel(R) Atom(TM) CPU N450   @ 1.66GHz
stepping        : 10
microcode       : 0x107
cpu MHz             : 1000.000
cache size      : 512 KB
physical id     : 0
siblings        : 2
core id             : 0
cpu cores       : 1
apicid              : 1
initial apicid  : 1
fpu                 : yes
fpu_exception   : yes
cpuid level     : 10
wp                  : yes
flags               : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm movbe lahf_lm dtherm
bugs                :
bogomips        : 3325.00
clflush size    : 64
cache_alignment : 64
address sizes   : 32 bits physical, 48 bits virtual
power management:

HD

$ sudo hdparm -I /dev/sda
/dev/sda:

ATA device, with non-removable media
    Model Number:       Hitachi HTS545016B9A300                 
    Serial Number:      100324PBPB06ECC0K6XL
    Firmware Revision:  PBBOC60F
    Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6; Revision: ATA8-AST T13 Project D1697 Revision 0b
Standards:
    Used: unknown (minor revision code 0x0028) 
    Supported: 8 7 6 5 
    Likely used: 8
Configuration:
    Logical                 max current
    cylinders       16383   16383
    heads                   16  16
    sectors/track   63      63
    --
    CHS current addressable sectors:   16514064
    LBA    user addressable sectors:  268435455
    LBA48  user addressable sectors:  312581808
    Logical/Physical Sector size:           512 bytes
    device size with M = 1024*1024:      152627 MBytes
    device size with M = 1000*1000:      160041 MBytes (160 GB)
    cache/buffer size  = 7208 KBytes (type=DualPortCache)
    Form Factor: 2.5 inch
    Nominal Media Rotation Rate: 5400
Capabilities:
    LBA, IORDY(can be disabled)
    Queue depth: 32
    Standby timer values: spec'd by Vendor, no device specific minimum
    R/W multiple sector transfer: Max = 16  Current = 16
    Advanced power management level: 254
    Recommended acoustic management value: 128, current value: 254
    DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
         Cycle time: min=120ns recommended=120ns
    PIO: pio0 pio1 pio2 pio3 pio4 
         Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
    Enabled Supported:
       *    SMART feature set
            Security Mode feature set
       *    Power Management feature set
       *    Write cache
       *    Look-ahead
       *    Host Protected Area feature set
       *    WRITE_BUFFER command
       *    READ_BUFFER command
       *    NOP cmd
       *    DOWNLOAD_MICROCODE
       *    Advanced Power Management feature set
            Power-Up In Standby feature set
       *    SET_FEATURES required to spinup after power up
            SET_MAX security extension
            Automatic Acoustic Management feature set
       *    48-bit Address feature set
       *    Device Configuration Overlay feature set
       *    Mandatory FLUSH_CACHE
       *    FLUSH_CACHE_EXT
       *    SMART error logging
       *    SMART self-test
       *    General Purpose Logging feature set
       *    WRITE_{DMA|MULTIPLE}_FUA_EXT
       *    64-bit World wide name
       *    IDLE_IMMEDIATE with UNLOAD
       *    WRITE_UNCORRECTABLE_EXT command
       *    {READ,WRITE}_DMA_EXT_GPL commands
       *    Segmented DOWNLOAD_MICROCODE
       *    Gen1 signaling speed (1.5Gb/s)
       *    Gen2 signaling speed (3.0Gb/s)
       *    Native Command Queueing (NCQ)
       *    Host-initiated interface power management
       *    Phy event counters
       *    NCQ priority information
            Non-Zero buffer offsets in DMA Setup FIS
       *    DMA Setup Auto-Activate optimization
            Device-initiated interface power management
            In-order data delivery
       *    Software settings preservation
       *    SMART Command Transport (SCT) feature set
       *    SCT Write Same (AC2)
       *    SCT Error Recovery Control (AC3)
       *    SCT Features Control (AC4)
       *    SCT Data Tables (AC5)
Security: 
    Master password revision code = 65534
        supported
    not enabled
    not locked
        frozen
    not expired: security count
        supported: enhanced erase
    64min for SECURITY ERASE UNIT. 66min for ENHANCED SECURITY ERASE UNIT. 
Logical Unit WWN Device Identifier: 5000cca5ffc040a7
    NAA             : 5
    IEEE OUI    : 000cca
    Unique ID   : 5ffc040a7
Checksum: correct

EDIT 3 command-line times

ran (+ 1 1) in HTDP-beginner 3 times -- Over 5 seconds.

$ time racket -t racket_HTDP_beginner.rkt
2
5.60user 1.04system 0:08.46elapsed 78%CPU (0avgtext+0avgdata 127968maxresident)k
5496inputs+0outputs (46major+40955minor)pagefaults 0swaps

$ time racket -t racket_HTDP_beginner.rkt
2
5.51user 0.67system 0:06.71elapsed 92%CPU (0avgtext+0avgdata 128124maxresident)k
24inputs+0outputs (0major+41790minor)pagefaults 0swaps

$ time racket -t racket_HTDP_beginner.rkt
2
5.41user 0.67system 0:06.55elapsed 92%CPU (0avgtext+0avgdata 128180maxresident)k
0inputs+0outputs (0major+36683minor)pagefaults 0swaps

ran (+ 1 1) in #lang racket 3 times -- A bit over 2 seconds.

$ time racket -t racket_lang_racket.rkt
2
2.13user 0.25system 0:02.71elapsed 87%CPU (0avgtext+0avgdata 64996maxresident)k
0inputs+0outputs (0major+12437minor)pagefaults 0swaps

$ time racket -t racket_lang_racket.rkt
2
2.15user 0.25system 0:02.63elapsed 91%CPU (0avgtext+0avgdata 61700maxresident)k
0inputs+0outputs (0major+15853minor)pagefaults 0swaps

$ time racket -t racket_lang_racket.rkt
2
2.28user 0.29system 0:02.89elapsed 89%CPU (0avgtext+0avgdata 61500maxresident)k
0inputs+0outputs (0major+15015minor)pagefaults 0swaps

EDIT 4

Running free -h every second while DrRacket is running (+ 1 1) in lang HTDP-beginner
(not running any other applications besides DrRacket and my basic system (ie window manager etc))
(this is fish shell, by the way):

http://pastebin.com/2RdZAuXj

At that point I had to kill DrRacket cuz everything was freezing up.

Anyway, yeah, it's leaking, obviously.

Everytime I re-ran the code in DrRacket, memory usage went up and stayed up.

I had only run it about twenty...two-ish (?) more times
(so maybe thirty-ish in total?)
by the point where it started getting near the limit
and I killed it to unfreeze the system.

I guess I should try this with normal #lang racket and see what happens...

EDIT 5

Yup, it leaks the same way:

http://pastebin.com/373PNnY7

like image 833
Owen_AR Avatar asked May 29 '16 10:05

Owen_AR


1 Answers

I am 90% sure that the reason you had to wait was that your installation of Racket wasn't done properly.

During installation the program setup-plt needs to be run. It precompiles all racket files (.rkt) into so-called zo-files. If this step is omitted, then DrRacket do the compilation for you the first time a file is needed.

In your case (I am guessing) it it your first time using the Beginner language, so all files relating to it needs to be compiled. And that takes a while.

The best solution is to use the official installers from http://download.racket-lang.org/ they all include precompiled zo-files.

If you happen to have used such an installer, then try again - and if the problem persist - do file a bug report (use the bug report in the Help menu in DrRacket).

like image 143
soegaard Avatar answered Sep 24 '22 00:09

soegaard