Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1a82157f5dd478e8b6a88e43c7465715b2319599
Ticket: 3519865fffffffffffffffffffffffffffffffff
[package require] is too slow
User & Date: basilik99 on 2012-04-20 15:46:45
Changes

  1. assignee changed to: "mistachkin"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Hi,
    
    As we find at multiple places on the Net, a problem with Tcl is the slowness of [package require] commands. My Tcl distribution is on a network drive and I cannot change that. Here is my loading time:
    
    % time {package require tdom; package require md5}
    8310807 microseconds per iteration
    
    And I also computed 8 seconds on my watch. Very slow... For small scripts that run often, this is big problem. It tends developpers to avoid using any packages. Tclx is a good example: re-code yourself its simple functions if you can to avoid its long loading time!
    
    I searched the Internet to see if it could be possible to load packages in background, i.e. when the main Tcl code is interrupted by the OS (during [glob] or [read] commands, or anything that makes the OS interrupt our process). I didn't find anything. I tried the [after] command, but that is not true multiprocessing so [after idle] command is not executed while accessing the I/Os.
    
    I would like them to be loaded in background for situations where I don't need these packages right away. I could start doing work while the packages load, then wait for the [package require] cpmpletion and then use the package commands. The overral script time would be smaller.
    
    I looked a bit at the Thread package. But I don't think a children thread can load a package for the main program. I doubt that the tdom package for example will be visible in the main script.
    
    I also looked at the threaded version of tclsh (base-tcl8.6-thread-win32-ix86.exe), but I didn't understand its benefits...
    
    Is there a solution to this problem? Is loading a package into another process possible?
    
    Thanks,
    Etienne
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "basilik99"
  10. subsystem changed to: "49. Threading"
  11. title changed to: "Running [package require] in background"
  12. type changed to: "RFE"