Overview
| Artifact ID: | 153a1cb7e7899b5db913f0e1792bcb320b6840c0063f59f300227f43d8e0451a |
|---|---|
| Ticket: | 62dafd9c53882dc27f4bbd68ad5b2160f06129ff
Namespace import can cause quadratic big-O and affects all siblings of same original command |
| User & Date: | sebres on 2025-03-28 13:42:58 |
Changes
- comment changed to:
<code>[namespace import]</code> looks to be affected by quadratic big-O... Every NS, OO-context, etc importing the command causes that it's deletion costs <code>O(n**2)*m</code>, where <code>n<code> - number of imports for original command, and <code>m</code> - number of such imported commands in NS/OO/etc. PoC: <code><pre> namespace eval A { proc c1 {} {}; proc c2 {} {}; proc c3 {} {}; namespace export * } foreach count {100 1000 10000 100000} { puts "=== $count ===" set i 0; puts [timerate { namespace eval ::B[incr i] {namespace import ::A::*} } 1000 $count] set i 0; puts [timerate { namespace delete ::B[incr i]; } 1000 $count] } </pre></code> result: <code><pre> === 100 === 26.0500 µs/# 100 # 38387.7 #/sec 2.605 net-ms 2.540000 µs/# 100 # 393700 #/sec 0.254 net-ms === 1000 === 13.8020 µs/# 1000 # 72453.3 #/sec 13.802 net-ms 9.236000 µs/# 1000 # 108271 #/sec 9.236 net-ms === 10000 === 11.0121 µs/# 10000 # 90809.2 #/sec 110.121 net-ms 285.814 µs/# 3498 # 3498.8 #/sec 999.776 net-ms === 100000 === 10.9604 µs/# 90967 # 91237.9 #/sec 997.031 net-ms 14274.5 µs/# 70 # 70.055 #/sec 999.212 net-ms </pre></code> (the last two are not achieved the whole set (would take a small eternity for the last), it has mastered only 70 deletions in a second, where on previous order of magnitude it was 3.5k in a second). Causation is <code>ImportRef *importRefPtr</code> in <code>Command</code> structure, what is unidirectional list. Moreover it's existence is not justified at all - this causes drastic performance impacts in any cases, and basically needed only to pass namespace-56.6 (deletion of original command shall cause the invocation of deletion-traces on imported commands). This (if needed at all) can be achieved with other way without that list. - login: "sebres"
- mimetype: "text/plain"