Skip to content
Tcl Source Code History Of Ticket 735388ffffffffffffffffffffffffffffffffff
Login

History Of Ticket 735388ffffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 735388ffffffffffffffffffffffffffffffffff

  1. Ticket change [c181bea826] (rid 111331) by msofer on 2003-05-09 18:48:00:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Freeing large arrays (or large numbers of arrays?)
      takes non-linear time on linux:
      
      % info patch
      8.5a0
      % for { set x 1 } { $x <  5} {incr x } {
           set data [list]
           set newcount [expr $x * 100000]
           for  {set i 0}  {$i <  $newcount } {incr i} {
                  lappend data [ list $i.0 $i.1 $i.2 ]
            }
            puts -nonewline "listsize =  [llength $data]  "
            set unsetime  [ lindex [time { unset data }] 0 ]
            set unitTime [expr {$unsetime / $newcount}]
            puts " $unitTime us/item"
      }
      listsize =  100000   5 us/item
      listsize =  200000   20 us/item
      listsize =  300000   41 us/item
      listsize =  400000   60 us/item
      
      Notes:
      
      1. This does *not* happen with the threaded allocator
      
      2. The problem does not seem to appear in either W2000
      or Solaris
      
      3. It may be depend on the glibc/gcc version used: the
      above is with gcc-2.96 and glibc-2.2.4 (RH 7.1 builds).
      Rolf Ade reported linear time with gcc-3.2 and glibc-2.3.2
      
      See also clt threads at
      http://groups.google.com/groups?threadm=3EBBC0DC.7050805%40houston.rr.com
      http://groups.google.com.ar/groups?threadm=vbngfpddpjr1a7%40corp.supernews.com
      
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "msofer"
    9. subsystem initialized to: "41. Memory Allocation"
    10. title initialized to: "freeing lists takes nonlinear time"
    11. type initialized to: "Bug"
  2. Ticket change [fc799093ab] (rid 108247) by msofer on 2003-05-10 02:02:24:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Don Porter sees the same problem both on i386 and alpha
      platforms:
        Intel: glibc-2.2.4 on 2.4.10 kernel
        Alpha: glibc-2.1.3 on 2.2.23 kernel
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  3. Ticket change [5e4438b099] (rid 115610) by mitchu on 2003-05-10 03:52:02:

    1. icomment:
      Logged In: YES 
      user_id=775554
      
      my Tcl and Wish are now  8.4.2
      from the precompiled distribution available from  ActiveState,
      
       I get the same results as before,   so my glibc doesn't
      matter I presume.
      
      slackware linux 2.4.20    smp
      twin Xeon-2.2   2.0 Gb   Ram
      
      just for th erecord
      
      glibc  2.2.5
      gcc version 2.95.3 20010315 (release)
      
      
      
    2. login: "mitchu"
    3. mimetype: "text/plain"
    4. username: "mitchu"
  4. Ticket change [c1d289be89] (rid 111386) by msofer on 2003-05-10 04:25:58:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Roy Terry reports on clt that he sees the nonlinear
      behaviour under win2k in tcl8.4.2 but *not* in tcl8.3.2
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  5. Ticket change [a1a4440afd] (rid 109763) by dkf on 2003-05-12 15:51:28:

    1. foundin changed to: "obsolete: 8.5a0"
  6. Ticket change [ef32f9e5c6] (rid 108953) by dkf on 2003-05-12 15:51:30:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Hmm.  Sounds to me like an unpleasant interaction between
      the low-level memory management engine and Tcl.  AIUI, the
      problem is that libc tries to free unused blocks of memory,
      which is laudable but potentially very expensive in time
      cost.  If the problem goes away with newer libc's the
      resolution is 'upgrade libc' though that's a really major
      undertaking... :^/
      
      I see no way to avoid this BTW.  The cost is not in Tcl
      itself and who knows how well the libc copes with things
      like madvise()?
      
      The difference between 8.3.2 and 8.4.2 seems strange to me.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  7. Ticket change [3e489b8d82] (rid 121235) by dkf on 2003-05-12 15:54:09:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Hmm.  Sounds to me like an unpleasant interaction between
      the low-level memory management engine and Tcl.  AIUI, the
      problem is that libc tries to free unused blocks of memory,
      which is laudable but potentially very expensive in time
      cost.  If the problem goes away with newer libc's the
      resolution is 'upgrade libc' though that's a really major
      undertaking... :^/
      
      I see no way to avoid this BTW.  The cost is not in Tcl
      itself and who knows how well the libc copes with things
      like madvise()?
      
      The difference between 8.3.2 and 8.4.2 seems strange to me.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  8. Ticket change [1ae2b45a9c] (rid 123051) by dgp on 2003-10-03 05:26:08:

    1. priority changed to: "8"
  9. Ticket change [485aba27a0] (rid 99871) by jenglish on 2004-02-21 08:15:24:

    1. icomment:
      Logged In: YES 
      user_id=68433
      
      This behaviour is symptomatic of all reference-counting
      memory management schemes.  As long as the working set fits
      in available RAM, everything is fine; but when you're
      freeing a large number of blocks each call to
      Tcl_DecrRefCount() may potentially cause a page fault. 
      Locality of reference plays a large part too -- freeing 100
      Tcl_Obj's in a row is very quick if they happen to be in the
      same cache line, expensive if they happen to be in different
      ones (and *very* expensive if they're paged out in different
      pages).
      
      FWIW, on my Fast Overpowered machine, (dual 1.6 Mhz Athlon,
      256K cache, ~1Gb RAM), the above test takes ~0.8 us/item all
      the way up to 900000 items; while on my Slightly Wimpy
      machine (400 Mhz PIII, 60 Mb RAM) I get the following:
      
      listsize = 100000  2.71754 us/item
      listsize = 200000  2.62894 us/item
      listsize = 300000  10.7855933333 us/item
      listsize = 400000  49.1984825 us/item
      listsize = 500000  45.585162 us/item
      listsize = 600000  61.9319466667 us/item
      listsize = 700000  67.7324 us/item
      listsize = 800000  77.3131225 us/item
      listsize = 900000  79.3220922222 us/item
      
      Note that the time is relatively constant for the first two
      iterations, jumps sharply, then stays relatively constant. 
      Watching a 'gkrellm' monitor, the jump occurred almost
      exactly at the time the RAM meter pegged out.
      
      This has more to do with your CPU and cache size and how
      many other processes are active on the system than it does
      with glibc.
      
      
    2. login: "jenglish"
    3. mimetype: "text/plain"
    4. username: "jenglish"
  10. Ticket change [c894cd2890] (rid 122129) by dkf on 2004-02-21 17:59:17:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Perhaps we should make it easier for people to tune the
      Tcl_Obj allocator for special applications?  Currently we're
      allocating in blocks of 100 (look for symbol
      OBJS_TO_ALLOC_EACH_TIME in tclObj.c) and it is quite
      possible that setting that to a few thousand would be better
      for apps that have heavy peak object use.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  11. Ticket change [9cdc20e03e] (rid 96219) by msofer on 2004-03-30 09:34:45:

    1. closedate changed to: "2004-03-30T02:34:45"
    2. closer changed to: "msofer"
    3. icomment:
      Logged In: YES 
      user_id=148712
      
      Software is getting better and faster! 
      
      On the same hardware (but with added ram), running tcl8.5a2
      (today's HEAD), gcc-3.3.3 and glibc-2.3.2 (debian unstable),
      kernel 2.4.20 (debian unstable) I now get:
      listsize = 100000  1 us/item
      listsize = 200000  1 us/item
      listsize = 300000  1 us/item
      listsize = 400000  1 us/item
      
      I guess we should close this as "not a tcl bug"? Or one that
      is no more?
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "Invalid"
    7. status changed to: "Pending"
    8. username: "msofer"
  12. Ticket change [1c86aaf8ae] (rid 90619) by hobbs on 2004-03-31 00:18:24:

    1. closedate changed to: "2004-03-30T17:18:24"
    2. closer changed to: "hobbs"
    3. icomment:
      Logged In: YES 
      user_id=72656
      
      My guess is that it was related to the old malloc
      implementation of gcc (glibc).
      
      
    4. login: "hobbs"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "hobbs"
  13. Ticket change [f4f3be05b9] (rid 130015) by jenglish on 2004-03-31 03:58:38:

    1. icomment:
      Logged In: YES 
      user_id=68433
      
      Just a followup for future reference  -- it's much more
      likely that "(but with added ram)"  is the most important
      factor.  The timing tests I ran used identical glibc
      versions; the machine with less RAM exhibited the slowdown,
      the one with more RAM did not.
      
      
    2. login: "jenglish"
    3. mimetype: "text/plain"
    4. username: "jenglish"