Tcl Source Code

Ticket Change Details
Login
Overview

Artifact ID: f7adab6025476834b652e4a346596a09a2d4c038e844c8acec706f09b0c88455
Ticket: effa2e2346f8372ad4982d16bad189fab96ceb56
RFE - lazy loading of TclOO for faster interp creation
User & Date: apnadkarni 2025-08-16 05:36:29
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-markdown"
  4. comment changed to:
    Tcl interp creation time more than doubled in 9.{0,1,2} compared to 8.6 as reported in [62019f8aa9](https://core.tcl-lang.org/tcl/tktview/62019f8aa9). This difference has mostly been negated for 9.0.3 with zipfs related fixes. However, opportunities for further optimization remain. One of these is loading of TclOO. As measured on my system, TclOO initialization takes up close to 40% of interp creation time.
    
    Since a very substantial (majority even?) number of Tcl applications do not use oo, one possibility is to lazy load TclOO. The [apn-oo-lazy-init](https://core.tcl-lang.org/tcl/timeline?r=apn-oo-lazy-init) branch implements a proof of concept for this.
    
    For comparison:
    
    Current main branch:
    ```
    %  timerate {interp delete [interp create]}
    1861.39 µs/# 537 # 537.23 #/sec 999.566 net-ms
    ```
    
    apn-oo-lazy-init branch:
    ```
    % timerate {interp delete [interp create]}
    1175.20 µs/# 850 # 850.92 #/sec 998.919 net-ms
    ```
    
    Test suite passes.
    
    The implementation creates stubs commands for the public oo commands that do initialization on first call. The initialization in turn overwrites the stub implementations with the "real" oo implementation.
    
    Other implementation strategies may be possible (tclIndex, unknown etc.) but need to keep in mind all code paths need to be covered (e.g. initial invocation through `namespace path`, use of `info class` commands before any public oo commands etc.
    
    Comments on the proposal, improvements, breakage or even alternative methods appreciated.
    
  5. is_private changed to: "0"
  6. login: "apnadkarni"
  7. priority changed to: "5 Medium"
  8. private_contact changed to: "9546e9877f1a8899e25a89082561ee694e7fb402"
  9. resolution changed to: "None"
  10. severity changed to: "Minor"
  11. status changed to: "Open"
  12. submitter changed to: "apnadkarni"
  13. subsystem changed to: "- New Builtin Commands"
  14. title changed to:
    RFE - lazy loading of TclOO for faster interp creation
    
  15. type changed to: "Bug"