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:
there is no support for multithreading in this changeset so far. We don't really need it for now, but perhaps best to add it as a compile-time configuration option. not any more
question: the thread-safe intrusive ptr is disabled right now; what kind of option would make sense for enabling it? answer after discussion: always enable thread-safety. Implemented.
this is a breaking change wherever a client was aware of aliases like Node being shared_ptr specifically. One notable example is the shared_from_this() method, which has an equivalent in the new version but is renamed. We could simplify the change by keeping the "shared" name, or we could go with a generic name like ptr_from_this to be robust against this problem in the future. answer after discussion: current name is ok, change behavior of ->parent() in other PR
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 foryamlc
).Notes:
there is no support for multithreading in this changeset so far. We don't really need it for now, but perhaps best to add it as a compile-time configuration option.not any morequestion: the thread-safe intrusive ptr is disabled right now; what kind of option would make sense for enabling it?answer after discussion: always enable thread-safety. Implemented.this is a breaking change wherever a client was aware of aliases likeanswer after discussion: current name is ok, change behavior ofNode
beingshared_ptr
specifically. One notable example is theshared_from_this()
method, which has an equivalent in the new version but is renamed. We could simplify the change by keeping the "shared" name, or we could go with a generic name likeptr_from_this
to be robust against this problem in the future.->parent()
in other PR