Overview
| Artifact ID: | 57f61a26fe02e7399690020f1134e02bf2bcfb99 |
|---|---|
| Ticket: | e76f0a6ca52a2ff3c2b1e9cb2585f3de0c44ab5d
[namespace delete] unbearably slow |
| User & Date: | anonymous on 2015-07-23 09:45:58 |
Changes
- comment changed to:
Invoking [namespace delete] in a namespace with a huge number of procs/commands takes an excessively long time. That is not the case when removing the procedures individually. This causes issues to packages that create great many commands in a namespace, such as TclXML (one command per used node). The following snippet exhibits the issue: ~~~ proc timed {script} { puts [::uplevel 1 [list time $script 1]]; } foreach N {1000 10000 50000 100000 200000} { puts "== $N =="; # [rename] before [namespace delete] timed { namespace eval test {}; for {set i 0} {$i < $N} {incr i} { ::proc ::test::abc$i {args} { puts $args; }; } foreach cmd [info proc test::*] { ::rename $cmd {} } namespace delete ::test; }; # plain [namespace delete]; timed { namespace eval test {}; for {set i 0} {$i < $N} {incr i} { proc ::test::abc$i {args} { puts $args; }; } namespace delete ::test; }; } ~~~ This is the output: ~~~ == 1000 == 5266 microseconds per iteration 6140 microseconds per iteration == 10000 == 44048 microseconds per iteration 32618 microseconds per iteration == 50000 == 2153807 microseconds per iteration 167686 microseconds per iteration == 100000 == 3373670 microseconds per iteration 338030 microseconds per iteration == 200000 == 25682504 microseconds per iteration 691066 microseconds per iteration ~~~ The elapsed time is greater than linear on the number of commands for [namespace delete]. - icomment:
Sadly there seems to be no change with the patch. The test script is remarkably similar to that of 4ee020. I have run the latter with the patched tcl and am able to see the improvement. Sadly there is no improvement for this case. Please, note that we are comparing the following two forms of deleting a namespace: ~~~ namespace delete ::test; ~~~ and: ~~~ foreach cmd [info proc test::*] { ::rename $cmd {} } namespace delete ::test; ~~~ The difference in the time it takes is so large, that one wonders whether one of them (TclTeardowNamespace) or ::rename are doing something wrong. From my understanding, the behaviour is no different. ------------------------ Please, note also that I have modified the test script to make it a little more clear. The results with patched Tcl are below: ~~~ == 10 == 150 microseconds per iteration 87 microseconds per iteration == 100 == 599 microseconds per iteration 370 microseconds per iteration == 1000 == 6458 microseconds per iteration 4784 microseconds per iteration == 10000 == 37656 microseconds per iteration 41629 microseconds per iteration == 100000 == 351145 microseconds per iteration 3421361 microseconds per iteration == 200000 == 747001 microseconds per iteration 26004022 microseconds per iteration ~~~ - login: "anonymous"
- mimetype: "text/plain"
- status changed to: "Open"
- username: "Adrián Medraño Calvo <[email protected]>"