Artifacts Associated With Ticket fa5c8a8230
Ticket change [0643cd548d] (rid 153785) by pooryorick on 2017-05-18 05:49:19:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
The following script consumes at least 1GB of memory: <code><verbatim> for {set i 0} {$i < 10000} {incr i} { set name [namespace eval ${name}[set name {}]::namespace$i { namespace current }] } </verbatim></code> It seems that the fully-qualified name of each created namespace is getting stored somewhere. - foundin initialized to: "8.7"
- is_private initialized to: "0"
- login: "pooryorick"
- priority initialized to: "5 Medium"
- private_contact initialized to: "e476148cded301ffff84bcdc432536dc0c949e88"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "pooryorick"
- subsystem initialized to: "21. [namespace]"
- title initialized to: "memory cost of nested namespaces"
- type initialized to: "Bug"
Ticket change [3a1529fdc9] (rid 153786) by sebres on 2017-05-18 07:26:06:
- assignee changed to: "sebres"
- foundin changed to: ">= 8.5"
- icomment:
Seems to affect 8.5 and 8.6 in same manner also. Additionally it've very large execution time exploding. Just as comparison to not-nested (>= 8.6, x86): <code><verbatim> # not nested: set i 0; time {namespace eval ::namespace[incr i] {}} 10000 ----> 4.74 microseconds per iteration (and 8.0MB memory) # nested: set name {}; set i 0; time {namespace eval [set name ${name}::namespace[incr i]] {}} 10000 ----> 70110.60 microseconds per iteration (and 770.0MB memory) </verbatim></code> This difference looks in 8.5 still many times worse and the execution time exploding is very grave (with the similar memory consumption like 8.6). <code><verbatim> % # not nested: % set i 0; time {namespace eval ::namespace[incr i] {}} 10000 2.91753049225468 microseconds per iteration % % # nested: % set name {}; % # 1. thousand: % set i 0; time {namespace eval [set name ${name}::namespace[incr i]] {}} 1000 1153.3163043544507 microseconds per iteration % # 2. thousand: % set i 0; time {namespace eval [set name ${name}::namespace[incr i]] {}} 1000 7032.770893726276 microseconds per iteration % # 3. thousand: % set i 0; time {namespace eval [set name ${name}::namespace[incr i]] {}} 1000 18984.08208553774 microseconds per iteration % </verbatim></code> - login: "sebres"
- mimetype: "text/x-fossil-wiki"
- title changed to:
memory cost and execution time exploding of nested namespaces
Ticket change [ca4addf7d4] (rid 153787) by sebres on 2017-05-18 08:12:41:
- icomment:
The memory consumption going to large full-qualified namespace name. Following example explain it (has comparable memory consumption as "namespace eval"): <code><pre> set name {}; set i 0; time {set ns($i) [set name ${name}::namespace[incr i]]} 10000 </pre></code> > pooryorick: <blockquote>It seems that the fully-qualified name of each created namespace is getting stored somewhere.</blockquote> Yes, see struct Namespace declaration "fullName" in tclInt.h. It is currently impossible without this member, because used everywhere and the auto-retrieving on demand would be admittedly possible, but will used almost immediately. I'll take a look later what would be possible to optimize it. - login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment: