Overview
| Artifact ID: | 669b2fcebbb84841ebfcd1091b9dbc2ce0cf110aee13b57c01c63235002986e2 |
|---|---|
| Ticket: | c9663296fd31fbb2fa1ff1cf019b59f432983516
GrowStringBuffer and GrowUnicodeBuffer do not check for overflows |
| User & Date: | apnadkarni on 2023-05-05 06:57:10 |
Changes
- icomment:
Broadening the scope of this ticket: As Tcl 9 deals with larger sized data, the aggressive overallocation of memory results in memory allocation panics when in reality there is enough memory to satisfy the actual request sizes. To keep amortized cost of allocation at O(1), it is not actually necessary to double requested size on overflow. Any factor > 1 suffices. Many implementations have changed to 1.5. This change is implemented in branch bug-c9663296fd. The branch also makes one other change - when the overallocation fails, it falls back to a "binary" scheme of reducing overallocation instead of allocating the exact or a small fixed overallocation. The results of these changes are shown in the table below. Since the change has the potential to impact performance both memory commit and time/op is shown. | Operation | Trunk | bug-c9663296f | ----------------------------------------------------------------- | timerate {lappend l x} 20000 | 0.147346 µs/# | 0.146707 µs/# | | | 1.58GB | 1.07GB | | time {lappend l x} 1000000000 | 0.229233 us/# | 0.219229 us/# | | | 12.61GB | 8.07GB | | time {append s x} 1000000000 | 0.153472 us/# | 0.155471 us/# | | | 1.58GB | 1.17GB | As seen above, there is very significant savings in memory without sacrificing performance. - login: "apnadkarni"
- mimetype: "text/x-markdown"