Artifacts Associated With Ticket 62dafd9c53882dc2
Ticket change [c7383a10cc] (rid 238728) by sebres on 2025-03-27 13:53:45:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized 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 * } proc create {ns} { namespace eval $ns { namespace import ::A::* } } foreach count {100 1000 10000 100000} { puts "=== $count ===" set i 0; puts [timerate { create ::B[incr i]; } 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. - foundin initialized to: "any"
- is_private initialized to: "0"
- login: "sebres"
- priority initialized to: "5 Medium"
- private_contact initialized to: "50e9528765c18296566374b3fde2df942c394efd"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "sebres"
- subsystem initialized to: "- New Builtin Commands"
- title initialized to:
Namespace import can cause quadratic big-O and affects all siblings of same original command
- type initialized to: "Bug"
Ticket change [7319784346] (rid 238729) by sebres on 2025-03-27 13:53:58:
- assignee changed to: "sebres"
- login: "sebres"
- mimetype: "text/plain"
Ticket change [11607f56db] (rid 238730) by sebres on 2025-03-27 14:18:52:
- icomment:
Here how it looks without the impact of importRefPtr list (I already rewrote that in my fork, with replacing importRefPtr by "default" ref-counting of cmdPtr through the import): <code><pre> === 100 === 7.640000 µs/# 100 # 130890 #/sec 0.764 net-ms 0.490000 µs/# 100 # 2040816 #/sec 0.049 net-ms === 1000 === 7.243000 µs/# 1000 # 138064 #/sec 7.243 net-ms 0.496000 µs/# 1000 # 2016129 #/sec 0.496 net-ms === 10000 === 7.788300 µs/# 10000 # 128397 #/sec 77.883 net-ms 0.592700 µs/# 10000 # 1687194 #/sec 5.927 net-ms === 100000 === 7.683910 µs/# 100000 # 130142 #/sec 768.391 net-ms 0.621080 µs/# 100000 # 1610098 #/sec 62.108 net-ms </pre></code> The issue is now - how to backport that all and resolve 1000 conflicts.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [153a1cb7e7] (rid 238732) by sebres on 2025-03-28 13:42:58:
- 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"
- comment changed to:
Ticket change [0f17ff9d54] (rid 238759) by sebres on 2025-03-29 18:07:09:
- login: "sebres"
- mimetype: "text/plain"
- subsystem changed to: "21. [namespace]"