Tcl Source Code

View Ticket
Login
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: Open Last Modified: 2025-07-26 14:53:44
Resolution: None Closed By: nobody
    Closed on:
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: 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).