Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: fe37f6c6e7ff419c522a59a777919672a56524bdd434af8a353ce6224482203b
Ticket: f5c01e42a759e6a01329256ab4c21b4402719526
Performance regression in 9.0 accessing dicts as lists
User & Date: griffin on 2023-08-16 22:30:19
Changes

  1. icomment:
    With some details added to the testcase:
    
    ```
    puts "Using Tcl [info patchlevel] on $tcl_platform(platform)"
    catch { puts "Build-Info: [tcl::build-info]" }
    
    set startTime [clock milliseconds]
    for { set i 1 } { $i < 60000 } { incr i } {
         set arr(Key-$i) "Value-$i"
    }
    set bt [expr { [clock milliseconds] - $startTime }]
    puts "Build time: $bt msec"
    
    set startTime [clock milliseconds]
    set agx [array get arr "*"]
    set at [expr { [clock milliseconds] - $startTime }]
    puts "array get time  : $at msec"
    puts agx-is-a:[lrange [tcl::unsupported::representation $agx] 1 3]
    
    set startTime [clock milliseconds]
    set llen [llength $agx]
    set lt [expr { [clock milliseconds] - $startTime }]
    puts "llength time: $lt msec"
    puts llen=$llen
    set startTime [clock milliseconds]
    set tmp [list]
    foreach {key val} $agx {
         lappend tmp $val
    }
    set gt [expr { [clock milliseconds] - $startTime }]
    puts "Get time  : $gt msec"
    
    exit 0
    ```
    Part 1 fix improves llength operation:
    
    ````
    # main code
    #
    Using Tcl 9.0a4 on unix
    Build-Info: 9.0a4+35275c285b06f3932d83aadec6dd9df85dd34214ca0202316409e117b8abe496.compiledebug.debug.gcc-1104.memdebug.no-optimize
    Build time: 1287 msec
    array get time  : 160 msec
    agx-is-a:is a dict
    llength time: 80 msec
    llen=119998
    Get time  : 916 msec
    
    
    # with dict llength function (branch [bug-f5c01e42a7])
    #
    Using Tcl 9.0a4 on unix
    Build-Info: 9.0a4+840ebea1b54a1edbefb5f74244bee34c43afef69111ac4f12f0b4a165003bd1a.compiledebug.debug.gcc-1104.memdebug.no-optimize
    Build time: 1035 msec
    array get time  : 142 msec
    agx-is-a:is a dict
    llength time: 0 msec
    llen=119998
    Get time  : 499 msec
    ````
    
    More to come...
    
  2. login: "griffin"
  3. mimetype: "text/x-markdown"