Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: fc45aad279ca34d273f80bd7819fb5f65a8b80ed
Ticket: 680169ffffffffffffffffffffffffffffffffff
Tcl interpreter pkgIndex 'cache'
User & Date: basilik99 on 2012-05-02 02:02:05
Changes

  1. icomment:
    I attached an enhanced version of dgp's script. I run Tcl 8.5. on Windows. I put the code right after Windows implementation of auto_execok.
    
    1- Replaced "~" by "$env(APPDATA)" as I am on Windows.
    
    2- Replaced ugly foreaches (sorry dgp!) by "lassign" new command.
    
    Now for real changes:
    3- Fixed a problem which was probably not present for Tcl 8.4 (for which you initialy developped the patch right?) Parameter "version" sometimes gets sets to "0-", which is not accepted as a version in [package ifneeded]. So, when reading the cache, avoided the call to ifneeded when version was not found. Anyway, ifneeded cannot return different from "" in that case...
    
    4- The proposed solution worked for almost all packages, but not for Thread. Indeed, its pkgIndex.tcl contains:
    package ifneeded Thread 2.6.5 [list thread_load $dir]
    where "thread_load" is a proc declared in the pkgIndex.tcl. So caching only [package ifneeded] scripts was not enough. I had to cache the pkgIndex.tcl itself. I didn't copy the pkgIndex.tcl's content, but only its path. Then I sourced it while having set $dir. I needed a special trick at the end to effectively execute the script inside the [package ifneeded], not only the pkgIndex.tcl's content. For TM, I used the previous solution.
    I am seeking your comments about this change.
    
    With your initial patch, I got the following:
    % time {package require md5}
    115286 microseconds per iteration
    % time {package require tdom}
    125298 microseconds per iteration
    % time {package require Tclx}
    468442 microseconds per iteration
    
    With my new patch, it is similar, but a bit slower. But that's acceptable for me as the solution is generic:
    % time {package require md5}
    178442 microseconds per iteration
    % time {package require tdom}
    138962 microseconds per iteration
    % time {package require Tclx}
    497901 microseconds per iteration
    
    Previously, loading md5 took 5 seconds, tdom around 3 seconds, asme for Tclx!
    
    Now for questions:
    Q1- I do not understand the benefit of putting the cache on the Tcl installation directory (which is a network drive for me). Anyway the cache is per-machine. A cache in user's local directory would be enough I think. Moreoever, for a single machine, we reached a cache file of around 5000 lines. When 10 or 20 users will use that cache system, the file is gonna get huge! .. probably slow to [source]...
    
    
  2. login: "basilik99"
  3. mimetype: "text/plain"
  4. username: "basilik99"