Skip to content
Tcl Source Code History Of Ticket 218181
Login

History Of Ticket 218181

Artifacts Associated With Ticket 218181

  1. Ticket change [6d8c8f8d04] (rid 128721) by nobody on 2000-10-26 00:54:13:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 2332 Bug
      Version: 8.0.5
      SubmitDate: '1999-07-06'
      LastModified: '1999-08-05'
      Severity: MED
      Status: Closed
      Submitter: techsupp
      ChangedBy: hobbs
      OS: HP-UX
      OSVersion: 10.20
      Machine: Other
      FixedDate: '2000-10-25'
      ClosedDate: '1999-08-05'
      
      
      Name:
      Ted Romer
      
      ReproducibleScript:
      Script "slow-array.tcl"
          
          # demonstrate slowness of tcl arrays as the array gets big
          
          #
          # Build an array with 2^exponent entries, and return
          # the average of 10 array accesses (measured in "clicks")
          #
          proc onepoint {exponent} {
              global g_val
          
              #
              # Build the array
              #
              set limit [expr {int(pow(2,$exponent))}]
              for { set i 0 } {$i < $limit} {incr i} {
                  set arr($i) $i
              }
          
              #
              # Some arbitrary members of the array; we mod by the
              # array size to make sure they are legal
              #
              set samples [list 0 31 63 127 255 511 1023 2047 4095 8191]
              foreach sample $samples {
                  lappend indices [expr $sample % $limit]
              }
          
              #
              # So how long does it take to look up those indices?
              #
              set start [clock clicks]
              foreach index $indices {
                  set g_val $arr($index)
              }
              set end [clock clicks]
              
              #
              # Return the average access time.
              #
              return [expr { ($end-$start+0.0)/[llength $indices] }]
          }
          
          #
          # Generate a table of (array size, avg access time in microseconds (on
          HP-UX))
          #
          proc main {argc argv} {
              puts "Array size   Access time (us)"
              for { set exponent 0 } {$exponent <= 16} {incr exponent} {
                  set limit [expr {int(pow(2,$exponent))}]
                  puts [format "%10d %18.1f" $limit [onepoint $exponent]]
                  flush stdout
              }
          }
          
          main $argc $argv
          
          Invocation:
          tclsh slow-array.tcl
      
      ObservedBehavior:
      Output:
          
          Array size   Access time (us)
                   1               17.9
                   2               15.3
                   4               15.0
                   8               14.4
                  16               14.3
                  32               14.6
                  64               15.1
                 128               15.1
                 256               16.1
                 512               17.6
                1024               21.4
                2048               26.8
                4096               56.3
                8192              115.8
               16384              121.0
               32768              562.6
               65536             1842.7
          
          i.e. in an array with 65536 elements, looking up a *single* element
          takes on average nearly 0.2 seconds!
      
      DesiredBehavior:
      I expect hash tables to have roughly constant access time, independent
          of size, until the amount of space dedicated to array storage is at 
          least a few megabytes.
      
      
      
      Discussion on the newsgroup showed that this seemed to be the using
      hitting some file system resource limit (swap, or such). 
      -- 08/05/1999 hobbs
      
    4. foundin initialized to: "final: 8.0.5"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to: "Array performance degrades as array size increases"
    11. type initialized to: "Bug"
  2. Ticket change [8b8b2fe84c] (rid 127588) by welch on 2000-10-26 08:16:55:

    1. closedate changed to: "2000-10-26T01:16:55"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [a6fc9fd47c] (rid 98708) by dgp on 2001-04-21 02:48:37:

    1. closedate changed to: "2001-04-20T19:48:37"
    2. closer changed to: "dgp"
    3. subsystem changed to: "07. Variables"