Use the known Blob length to allocate the result of blob2list() and all its list items together, avoiding one allocation per byte. Add coverage for removing, inserting, appending, reversing, and changing the type of result elements while preserving the original Blob.
Before/after timings for repeated conversions of a Blob containing repeating bytes 0–255 (median of five runs, GCC -O2; baseline 1b405bb705, patched 23992b6d17):
| Blob bytes | Calls per run | Before | After | Time reduction |
|---|---|---|---|---|
| 4,096 | 488 | 35.639 ms | 20.749 ms | 41.8% |
| 65,536 | 30 | 33.735 ms | 20.311 ms | 39.8% |
Setup is excluded; replacing and freeing the previous result is included. These are focused microbenchmarks and were not CPU-pinned.
Batch allocation reduces memory while the full result is retained, but its item storage remains allocated until the result list is freed. Removing a range also requires allocating separate list items for the removed values. With a one-million-byte Blob, whole-process allocated memory on Linux/glibc was:
| State | Before | After |
|---|---|---|
| Full result retained, source Blob freed | 48.35 MB | 32.35 MB |
| Result filtered down to one element | 0.35 MB | 32.36 MB |
remove(result, 1, 999999), both lists retained |
48.35 MB | 80.35 MB |
These are mallinfo2() measurements, not RSS; MB means 1,000,000 bytes. The change also requires a contiguous allocation proportional to the Blob length.
https://github.com/vim/vim/pull/21386
(2 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
thanks
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()