June 21st, 2024

Reference Counting with Linear Types

The `reference-counting` library in the `ghengin` engine manages resources through `Alias` datatype, supporting alias creation, sharing, and deallocation. It's experimental, functional, and seeks feedback, used effectively in `ghengin`.

Read original articleLink Icon
Reference Counting with Linear Types

The GitHub URL provided discusses the `reference-counting` library utilized in the experimental `ghengin` engine. This library enables resource management through reference counting with linear types, allowing alias creation, sharing, and resource deallocation when the last alias is forgotten. The primary datatype is `Alias`, managing references dynamically. Functions like `newAlias`, `share`, and `forget` facilitate alias handling, while `get` and `useM` operate on aliased resources. The library, though experimental, is functional and seeks feedback on design and potential issues. It has been effectively employed in the `ghengin` engine for resource management. Interested individuals can explore the engine's source code for a practical application of `reference-counting`, with simple examples available in the library's `test/` directory.

Related

Eight million pixels and counting: improving texture atlas allocation in Firefox (2021)

Eight million pixels and counting: improving texture atlas allocation in Firefox (2021)

Improving texture atlas allocation in WebRender with the guillotiere crate reduces texture memory usage. The guillotine algorithm was replaced due to fragmentation issues, leading to a more efficient allocator. Visualizing the atlas in SVG aids debugging. Rust's simplicity and Cargo fuzz testing are praised for code development and robustness. Enhancements in draw call batching and texture upload aim to boost performance on low-end Intel GPUs by optimizing texture atlases.

A portable lightweight C FFI for Lua, based on libffi

A portable lightweight C FFI for Lua, based on libffi

A GitHub repository offers a portable lightweight C FFI for Lua, based on libffi. It aims for LuaJIT FFI compatibility, developed in C. Includes features, examples, basic types, build instructions, testing, and acknowledgements.

Writing an IR from Scratch and survive to write a post

Writing an IR from Scratch and survive to write a post

Eduardo Blázquez developed an Intermediate Representation (IR) for the Kunai Static Analyzer during his PhD, aiming to enhance Dalvik bytecode analysis. The project, shared on GitHub and published in SoftwareX, transitioned to Shuriken. Blázquez drew inspiration from Triton and LLVM, exploring various IR structures like ASTs and CFGs. MjolnIR, Kunai's IR, utilized a Medium Level IL design with control-flow graphs representing methods. Blázquez's approach involved studying compiler design resources.

The Abstraction and Reasoning Corpus

The Abstraction and Reasoning Corpus

The GitHub repository for ARC-AGI provides task data and a testing interface for solving tasks involving input/output pairs within 3 trials. Users can access the tasks and detailed instructions on the repository.

Neko: Portable framework for high-order spectral element flow simulations

Neko: Portable framework for high-order spectral element flow simulations

A portable framework named "Neko" for high-order spectral element flow simulations in modern Fortran. Object-oriented, supports various hardware, with detailed documentation, cloning guidelines, publications, and development acknowledgments. Additional support available for inquiries.

Link Icon 3 comments
By @verdagon - 5 months
Good to see some more uses of linear types! Very few languages can use linear types, and their potential is huge IMO.

OP shows the benefits of a linear RC that tracks references dynamically, and one can even imagine a version where the compiler tracks the references instead.

For example (for those who are more familiar with Rust) imagine that it had linear types and that we used them for matthieum's static-RC [0] (like suggested by frank-king at [1] to prevent leaks) and you'd have a pretty good idea of linear static RC.

I also talked about a possible alternative linear static RC at [2] and [3] (I didn't explain it well at all, happy to elaborate), though lately I suspect that one would need to add a GhostToken-ish [4] substance to allow safely reading/writing the shared value, or perhaps a RefCell.

I suspect that something like GhostToken could also solve OP's restriction that types be opaque, if Haskell has something like GhostToken... I could be wrong on that though.

[0] https://github.com/matthieu-m/static-rc

[1] https://github.com/matthieu-m/static-rc/issues/7

[2] "Linear reference counting" in https://verdagon.dev/grimoire/grimoire#the-list

[3] https://www.reddit.com/r/rust/comments/1d06gjo/comment/l61qm...

[4] https://www.reddit.com/r/rust/comments/p5f78s/ghostcell_sepa...

By @o11c - 5 months
What does this do regarding reference cycles?

* Do strong reference cycles break soundness?

* Are weak references supported yet? Using the slim, fat, indirect, or reverse model?

By @c0balt - 5 months
Does someone know general ressources on this type of algorithm for concurrent environments? I've had to implement it recently and it was quite hard to find anything.