Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 02eaeb1a4a0d7899cddfaeb4bdba77e2a5fbcd84
Ticket: e76f0a6ca52a2ff3c2b1e9cb2585f3de0c44ab5d
[namespace delete] unbearably slow
User & Date: anonymous on 2015-07-20 09:59:01
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. 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:
    
    ~~~
    set N 10000;
    foreach N {1000 10000 50000 100000 200000} {
        puts "== $N ==";
        puts [time {
    	namespace eval test {};
    	for {set i 0} {$i < $N} {incr i} {
    	    proc ::test::abc$i {args} { puts $args; };
    	}
    	namespace delete ::test;
        } 1];
    
        puts [time {
    	namespace eval test {};
    	for {set i 0} {$i < $N} {incr i} {
    	    proc ::test::abc$i {args} { puts $args; };
    	}
    	for {set i 0} {$i < $N} {incr i} {
    	    ::rename ::test::abc$i {}
    	}
    	namespace delete ::test;
        } 1];
    }
    ~~~
    
    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].
    
  5. foundin changed to: "8.6.3"
  6. is_private changed to: "0"
  7. login: "anonymous"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "3410fe6f8504d01909e548b02e0cec50a5f7fab3"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "anonymous"
  14. subsystem changed to: "- New Builtin Commands"
  15. title changed to: "[namespace delete] unbearably slow"
  16. type changed to: "Bug"