r-devel / r-project-sprint-2023

Material for the R project sprint
https://contributor.r-project.org/r-project-sprint-2023/
17 stars 3 forks source link

Extend garbage collection (GC) to cover symbols #68

Open gmbecker opened 1 year ago

gmbecker commented 1 year ago

Endorsed by Luke

Currently symbols are never garbage collected. Some usage patterns create many symbols that are no longer needed after a computation, but will never be reclaimed. It should be possible to modify the GC to remove symbols no longer referenced from the symbol table.

It might also be useful to allow for symbols not in the symbol
table (uninterned symbols, or gensyms).
aitap commented 1 year ago

This sounds like a long-term project. Given the amount of code that keeps the pointers returned by install() forever, there will probably be need for separate API for creating "perishable" symbols, and the old-style API will have to promote such symbols to keep them from being discarded if it locates and has to return such a symbol.

ltierney commented 1 year ago

Yes there will need to be a separate interface for creating transient symbols, and an efficient way to distinguish whether a symbol is permanent or transient (probably a bit in sxpinfo.gp).

The main places where transient symbols can be created are in the parser for new symbols in RR code, the as.name implementation, and for tags in attributes. There are probably other places as well, but they don't need to be identified all at once.