microsoft / Trieste

A term rewriting system for experimental programming language development.
MIT License
37 stars 20 forks source link

Use intrusive reference counting #128

Closed fhackett closed 1 month ago

fhackett commented 1 month ago

This proposed change relates to the ongoing discussion of #115, regarding how Trieste can reduce its impact on binary size.

One thing we identified was the footprint of shared_ptr destructors, which will be included whenever the ubiquitous Node goes out of scope. We considered switching to a customized intrusive reference counted pointer implementation, which might be a bit more efficient, and would give us more control over code generation of such a common case in code that uses Trieste.

The resulting pointer implementation, and its non-inline refcount decrement, saves 300KB on the yamlc executable, and saved 1.3MB on rego-cpp's main executable, or about 20% of its original size (6.8MB). Keeping the refcount decrement inlineable (but otherwise the same) saves some space still, but less (200KB for yamlc).

Notes: