Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: cf0f88b1261d965ba12fa296e8248d6eb74f7362
Ticket: e76f0a6ca52a2ff3c2b1e9cb2585f3de0c44ab5d
[namespace delete] unbearably slow
User & Date: anonymous on 2015-07-24 07:43:27
Changes

  1. icomment:
    Upon further inspection, I attest that the code in branch bug-f97d4ee020 cannot possibly fix the issue in this ticket.  The underlying cause is analogous: deleting a hash table requires more work if the table is subject to change during the iteration.
    
    The difference between this issue and that of http://core.tcl.tk/tcl/info/f97d4ee020 is that the latter fills the namespace with sub-namespaces, where this one fills the namespace with procedures.
    
    The changes in branch bug-f97d4ee020 affect the iteration through the nsPtr->childTable.  Changing the iteration through the nsPtr->cmdTable in a similar way:
    
    ~~~
    --- generic/tclNamesp.c 2015-07-24 09:26:47.621134045 +0200
    +++ generic/tclNamesp.c.orig    2015-07-24 09:27:21.598132784 +0200
    @@ -1128,11 +1128,7 @@
     
         for (entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search);
                entryPtr != NULL;
    -#if 0
                entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search)
    -#else
    -           entryPtr = Tcl_NextHashEntry(&search)
    -#endif
            ) {
            cmd = Tcl_GetHashValue(entryPtr);
            Tcl_DeleteCommandFromToken((Tcl_Interp *) iPtr, cmd);
    ~~~
    
    does indeed "fix" the timings.
    
    It could be said that this issue duplicates http://core.tcl.tk/tcl/info/f97d4ee020 in that a fix for the latter would probably apply as well for this one.  Nevertheless, the explanation as to why renaming the commands then deleting the namespace is faster than simply deleting the namespace would remain (for me) mysteriously unknown.  That is, why can the former perform linearly and the latter not?
    
  2. login: "anonymous"
  3. mimetype: "text/plain"
  4. username: "Adrián Medraño Calvo <[email protected]>"