View Ticket
Not logged in
2026-03-14
04:18 Closed ticket [62019f8aa9]: Performance penalty by creation of interp compared to old versions plus 5 other changes artifact: 0a3bd6f46a user: apnadkarni
04:07 Ticket [62019f8aa9]: 3 changes artifact: 717bf2c910 user: apnadkarni
2025-08-23
08:29 Ticket [62019f8aa9]: 3 changes artifact: b82cec7d1d user: dkf
2025-08-16
06:12 Ticket [62019f8aa9]: 3 changes artifact: 34c4ce8663 user: apnadkarni
05:36 New ticket [effa2e2346] RFE - lazy loading of TclOO for faster interp creation. artifact: f7adab6025 user: apnadkarni
2025-07-26
14:53 Ticket [62019f8aa9] Performance penalty by creation of interp compared to old versions status still Open with 3 other changes artifact: ff19c49619 user: sebres
14:35
rebased lazy load implementation of clock-engine (based on TIP 689); also illustrates performance ga... Leaf check-in: 04742d889c user: sebres tags: sebres-tip-689-clock-auto-load
2025-07-23
06:31 Ticket [62019f8aa9] Performance penalty by creation of interp compared to old versions status still Open with 3 other changes artifact: f63b9fa26d user: oehhar
2025-07-22
18:49
cherry-pick from 9.0: improve interpreter creation speed, if there is no zipfs tcl-library (avoid pe... check-in: 7fbbdb09fb user: sebres tags: core-8-branch
18:34 Ticket [62019f8aa9] Performance penalty by creation of interp compared to old versions status still Open with 3 other changes artifact: ad6719d9b9 user: sebres
18:20
merge 9.0: improve interpreter creation speed, if there is no zipfs tcl-library (avoid performance p... check-in: 026ae2bdcc user: sebres tags: trunk, main
18:18
improve interpreter creation speed, if there is no zipfs tcl-library (avoid performance penalty [620... check-in: 4318f0e945 user: sebres tags: core-9-0-branch
16:48 New ticket [62019f8aa9] Performance penalty by creation of interp compared to old versions. artifact: 6d338c0252 user: sebres

Ticket UUID: 62019f8aa9f5ec73743be6f7d90f3b346c8cd29b
Title: Performance penalty by creation of interp compared to old versions
Type: Bug Version: 9.0+
Submitter: sebres Created on: 2025-07-22 16:48:56
Subsystem: 38. Init - Library - Autoload Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-03-14 04:18:35
Resolution: Fixed Closed By: apnadkarni
    Closed on: 2026-03-14 04:18:35
Description:

Working on the fix for use-after-free bug, I noticed that there is performance penalty by creation (and/or deletion) of interp.

Here is the comparison 9.0 (-) vs 8.6 (+):

  % timerate {interp create i; interp delete i} 5000
- 3574.98 µs/# 1398 # 279.72 #/sec 4997.816 net-ms
+ 1756.77 µs/# 2846 # 569.23 #/sec 4999.777 net-ms

# still worse it looks with safe interp: % timerate {interp create -safe i; interp delete i} 5000 - 1228.34 µs/# 4070 # 814.11 #/sec 4999.341 net-ms + 460.025 µs/# 10869 # 2173.8 #/sec 5000.009 net-ms

However 8.7 seems to have the same "bottleneck" (although a bit faster).

I had a 9.x-based branch with lazy load of clock, OO and few other stuff... it is significantly faster, but anyway a bit slower than 8.6...

Since I don't have time right now to profile it, but it looks significant, I let it here as a ticket.

User Comments: apnadkarni added on 2026-03-14 04:07:14:
Closing this while cleaning up bug reports as performance is now 2x even 8.6. Further improvements are always possible but that is a generic goal not specific to this ticket.

Current trunk:

```
% timerate {interp create i; interp delete i} 5000
1066.21 µs/# 4689 # 937.90 #/sec 4999.442 net-ms
```

9.0.2:

```
%  timerate {interp create i; interp delete i} 5000
4725.25 µs/# 1057 # 211.63 #/sec 4994.590 net-ms
```

8.6:

```
% timerate {interp create i; interp delete i} 5000
2153.04 µs/# 2322 # 464.46 #/sec 4999.364 net-ms
```

dkf added on 2025-08-23 08:29:26:
TclOO was one of the contributors to this. I've cut about 25% of the time off of the whole interp create/delete cycle from making the initialisation script contain less (by moving pieces into C). There might be further places that can be improved.

apnadkarni added on 2025-08-16 06:12:19:
For one proposed improvement see [5773c78e86](https://core.tcl-lang.org/tcl/tktview/5773c78e86)

sebres added on 2025-07-26 14:53:44:

Branch for lazy load of clock ([04742d889c]) illustrates the possible win of changeover for single namespace/ensemble to on-demand load, where the performance win is ca. 200 µs/#. The switch of further subsystems to lazy loading may reduce interpreter creation time to ca. 1000 µs/# what would be almost double as fast than current 8.6 (and tipple as fast than current 9.x).

However, as already said, it'd expect at least TIP#689 (namespace unknown), and some of the subsystems also further improvements, that may help to load namespace on demand by any access (e. g. on variable or on namespace resolution).


oehhar added on 2025-07-23 06:31:13:
Great ! And the source code change is documented, I appreciate !
Thanks for all,
Harald

sebres added on 2025-07-22 18:34:50:

[4318f0e945ce26ee] fixes a part of it (improves interpreter creation speed also in case if there is no zipfs tcl-library), so eliminating the costs of ca. 1200 µs/#.

I'd let this ticket open till I found remaining extra costs and/or provide my lazy-loading stuff for clock/etc as ready solution for 9.x (however I guess we'd at least resume TIP#689 and further namespace unknown improvements).