I hear there are plans for garbage collection for the Tezos blockchain. What does this mean exactly? What are these "garbage" that needs to be collected, why are they there in the first place? Is garbage collection only used for non-full nodes or for all nodes? How much space will we save from garbage collection?
Each Tezos node maintains a representation of the current state of the ledger. That state includes things like the storage of each contract, the balance of different addresses, etc. The goal of the blockchain is to allow a decentralized network of participants to reach consensus on what that state is.
Since the chain can have reorganizations, it's sometimes necessary for the nodes to go back in time by a few blocks and compute a different state. In order to do so efficiently, they need to be able to quickly remember what the state was as off a few blocks ago.
In the current implementation, the node remembers every single state it ever went through. This is in addition to remember all the blocks!
Garbage collection means discarding past states which are no longer needed by the node and take up valuable disk space. By design, the protocol does not allow reorganizations longer than 5 cycles, therefore it is safe to discard all states older than that. However, states can be discarded more aggressively since large reorganizations are very unlikely.
In practice, a good approach is to store a few recent states as a well and a few, sparse, old ones. If a long reorganization happens, the node will pick whichever state it knows about prior to the reorganization point and reconstruct the state up to that point.
When only the past 5 cycles are kept, the disk space occupied is at least 10 times smaller.
If you are interested in a study on the impact of storage improvements, see here (there is also a link towards a storage-efficient tezos node).