Overview
| Artifact ID: | 4f29842dd38a7c4449686a8c24777b57479ce610 |
|---|---|
| Ticket: | 32c5740a4d3e86b1973915d92f07d5aee6104a14
Undesirable [lappend] performance as LIST_MAX is reached |
| User & Date: | dgp on 2015-11-23 20:52:27 |
Changes
- icomment:
Looking some more, we find that Tcl_ListObjReplace() is getting called because the instruction INST_LAPPEND_LIST_STK is doing the work. This is a recent invention. Tcl_ListObjReplace() is not the only routine that grows lists. Tcl_ListObjAppendElement() also does so, and is a more direct implementation to use here. The instructions we need to get that routine working for us are INST_LAPPEND_SCALAR* The easy path to that is to wrap the whole test script in an [apply {{} {...}}] Indeed this performs much much better, growing up all the way to the LIST_MAX limit in the time it takes the original demo to fill less than the first 200M elements. It is not hard to make the compiler use INST_LAPPEND_SCALAR instead of INST_LAPPEND_LIST_STK in the demonstrated case. The problem is that the two instructions exhibit different behaviors regarding read traces, and the test suite is not happy with the change. This is a long, sick, sad tale. Explore if you like; it's not pretty. We've apparently decided the least bad option we have is to leave things inconsistent and broken. The next thing to examine, though, is just why Tcl_ListObjAppendElement does so much better than Tcl_ListObjReplace. The answer appears to be that the former takes an extra step in attempting to use the realloc() call of the memory allocation subsystem before moving on to a full copy and extend. The copies are what kills us in the time, and apparently in precisely this demo case, realloc() is able to do what it exists to do -- grow a (virutal) memory buffer while avoiding copies as much as it can. - login: "dgp"
- mimetype: "text/plain"