Why SymbolDCE::computeLiveness uses a len 16 SmallVector to store worklists?

I found the SymbolDCE::computeLiveness choose to use a pretty small length of worklist :

LogicalResult SymbolDCE::computeLiveness(Operation *symbolTableOp,
                                         SymbolTableCollection &symbolTable,
                                         bool symbolTableIsHidden,
                                         DenseSet<Operation *> &liveSymbols) {
  // A worklist of live operations to propagate uses from.
  SmallVector<Operation *, 16> worklist;

i don’t kown why use this fixed-threshold of SmallVector. In real mlir dialects, somehow i think we always have a large number of operations in a block?

The 16 here for SmallVector is intended to be a stack allocation (so very limited) that is used to avoid an allocation for the case where we visit smaller input IR. When the IR goes above the threshold we pay the price of malloc (and copy to grow the vector), but in general when the IR is large enough this cost is not very important.

thanks :slight_smile: