Overview
| Artifact ID: | 45fb2c4453aca9cf71ec3c02489acbb8f66cd3ca |
|---|---|
| Ticket: | 1701202fffffffffffffffffffffffffffffffff
Tcl stack reform |
| User & Date: | msofer on 2007-04-16 00:30:38 |
Changes
- assignee changed to: "dgp"
- cmimetype changed to: "text/plain"
- comment changed to:
Since we started using TclStackAlloc, some of the basic assumptions underlying tebc's mem design ceased being correct. In particular, when the stack is grown the old stack will now typically remain active until every bytecode running in it returns - as the corresponding CallFrames live there, the old stacks remain active. This means that the recopying of stack items is not really necessary. This patch redesigns the ExecEnv system to work differently: there may be many stacks (in a doubly-linked list). When there is not enough room left in the active stack, the next one is used if it exists (it will be both the last one and empty) - but no elements are typically copied over (exception: growth for {*}-expansion). On freeing of a stack requirement, empty stacks that are not last are ckfree'd. In this manner the largest stack allocated remains always here, smaller stacks are ckfreed when they cease being used. This behaviour is similar to what de facto we have now, with the old copies being blocked by TclStackAlloc'ed frames. With this patch both performance and memory usage should improve in general, although it is possible to devise cases where it consumes more memory than the current scheme. Performance improvements (small, seem to be about 5% on my very unreliable benchmariking setup) due to: (a) CACHE_STACK_INFO now necessary, a running bc can not get its stack changed (except by it using {*}, so the adaptation is localised there) (b) when a new stack is needed for a new bytecode, no data is copied over. When {*} requires a new stack, only the data corresponding to the current bc is copied over. The current scheme requires a copy of the complete stack contents, including every TclStackAlloc'ed sections. (c) (epsilon squared) there is no more refcounting of the stacks Memory improvements: when a new stack is allocated, the complete memory is available as nothing is copied over from older stacks. The *2 growth might be too generous under these circumstances, maybe 1.5 would be enough? The patch also creates a new TclStackRealloc, that permits resizing of the last TclStackAlloc'ed memory (unused, just very easy to add as it uses functionality needed for {*}). - foundin changed to: "TIP Implementation"
- is_private changed to: "0"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "msofer"
- subsystem changed to: "41. Memory Allocation"
- title changed to: "Tcl stack reform"
- type changed to: "Patch"