Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 3ed9ab4cd824676d5ce24e4bdc8056242b41a4067ef713c1b04f2d76901c4ebb
Ticket: 93eb73784ae4c3b2285133a98df8163144eba291
zipfs interaction with tcl_findLibrary causes slow loading
User & Date: juliannoble2 on 2023-09-05 20:12:12
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-plain"
  4. comment changed to:
    Loading Tk on windows (non-tclkit) can be excruciatingly slow. e.g 5+ seconds 
    The slow loading occurs within tcl_findLibrary
    
    (related but different code path - if the tcl8.7 library files aren't installed - Tcl_Init seems to take a long time before eventually loading successfully from tcl87.dll)
    
    This appears to be a combination of bugs/isues. 
    
    1) zipfs exists $filename  always returns 0 when prefixed with the ZIPFS_VOLUME "//zipfs:/" but can be used if the prefix is dropped e.g
    
        % zipfs mount
        //zipfs:/lib/tk C:/tcl87/bin/tk87.dll
        % zipfs list //zipfs:/lib/tk/tk_library/tk.*
        //zipfs:/lib/tk/tk_library/tk.tcl
        % zipfs exists //zipfs:/lib/tk/tk_library/tk.tcl
        0
        % zipfs exists /lib/tk/tk_library/tk.tcl
        1
    
    I notice the androwish zipfs implementation (which is diverging in interesting ways as noted in an earlier ticket) has fixed this so that it is consistent with for example 'zipfs info' which requires the prefix. 
    
    2) tcl_findLibrary is using zipfs exists with the prefix so always returns zero.
    This means the zipfs is mounted ok - but:
    
      mount is called twice with different capitalisations of driveletter
    
      catch {zipfs unmount $archive}  is called after the first mount - which does nothing because $archive is the wrong argument here - it should be the mountpoint not the name of the zip file 
    
    (no-args error message from zipfs unmount is misleading in this regard)
    
        The second mount will fail because the first one is still in place - but it's wrapped in a big catch so things go on.
    
    
    3) bad interaction with tcl's 'file exists'
    tcl_findLibrary now has a list of paths to check - some of which begin with //zipfs:/  others from the external filesystem
    
      Presumably because //zipfs:/  looks roughly like a UNC path:
    
      file exists //zipfs:/somewhere
    
      will be very slow - on the order of seconds, when the path doesn't exist.
      
      (file exists on a //zipfs:/ path which is mounted and exists is fine)
    
    This problem with file exists - whilst at the core of the delay - could be worked around if the 'zipfs exists' issue was fixed as this could be used for fast testing of those paths.
    
    Once //zipfs:/ paths are mounted - they perform well on windows (faster than reading equivalent files from installed files)
    
    There is an inconsistency between tcl with library files resulting in no //zipfs:/ mount
    
    and Tk with library files installed results in them being accessed from the //zipfs:/ mount
    
    In summary:
    Tcl loading is slow without libs installed - Tk loading is slow whether they're present or not.
    
    Given the performance boost from //zipfs:/ mounts - it may make sense to always load from the dlls in tclsh/wish when available even if user has installed the libs - as presumably they can use the relevant environment var to force loading from the filesystem if required (untested).
    
  5. foundin changed to: "8.7"
  6. is_private changed to: "0"
  7. login: "juliannoble2"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "957fdfcd8744611e3fe1f4896c7538b1d9bf47b2"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "juliannoble2"
  14. subsystem changed to: "37. File System"
  15. title changed to:
    zipfs interaction with tcl_findLibrary causes slow loading
    
  16. type changed to: "Bug"