|
[namespace import] looks to be affected by quadratic big-O...
Every NS, OO-context, etc importing the command causes that it's deletion costs O(n**2)*m, where n - number of imports for original command, and m - number of such imported commands in NS/OO/etc.
PoC:
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]
}
result:
=== 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
(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 ImportRef *importRefPtr in Command 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.
|