User loginNavigation |
Deallocation patterns and linear types (e.g. Rust)I've been [much] belatedly poking at Rust - particularly the move/borrow model, and I was then thinking about implications for allocation and deallocation performance. Though I haven't looked seriously, a couple of things occurred to me that I haven't seen people talking about. Nothing in any way profound here, but perhaps worth considering for those of you designing or implementing new languages, and it appears to me that this applies to many langugaes using linear type. Rust's reference counted pointers fall outside of what I'm going to describe. I was pondering lifespans in Rust, thinking that there are probably cases where deallocations in Rust occur later (for naive lifespan reasons) than we might like - at least according to the simple description of lifespans in the specification, which is conservative. Also that the rules for object deallocation have the consequence that the cost of function return becomes hard to understand because it is difficult for a programmer to have good intuitions about deallocation overheads associated with the return. This got me to pondering deallocation and heap fragmentation to try to understand whether that's an actual problem, and then to wonder how many of Rust's allocations can be stack allocated and deallocated in the style of
If I have this right, region deallocation for statically sized objects is reduced to running destructors (in Rust: There are practical concerns - many operating systems make naive stack overflow tests that would need to be worked around - but that's neither new nor hard. The handling of "uncertain death" regions can be improved. Even if we don't know the exact order of region death, we can generally determine some place in the region exit ordering where we know conservatively that a region has become unreachable. It seems to me that we end up with three kinds of allocation areas:
The absence of reference counting (or analogous general object heap allocation mechanisms) in a program tells us whether we need to bind the collector into the binary. For anybody whose thought carefully about implementing linear type, I suspect all of this is pretty obvious. I hadn't gotten quite that far in my thinking about heap management in BitC, though I had certainly been thinking about compiler-driven stack allocation. By shap at 2022-10-21 16:01 | LtU Forum | previous forum topic | next forum topic | other blogs | 2347 reads
|
Browse archives
Active forum topics |
Recent comments
27 weeks 6 days ago
27 weeks 6 days ago
27 weeks 6 days ago
50 weeks 19 hours ago
1 year 2 weeks ago
1 year 3 weeks ago
1 year 3 weeks ago
1 year 6 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago