[pseudo] Store shift and goto actions in a compact structure with faster lookup.
The actions table is very compact but the binary search to find the correct action is relatively expensive. A hashtable is faster but pretty large (64 bits per value, plus empty slots, and lookup is constant time but not trivial due to collisions). The structure in this patch uses 1.25 bits per entry (whether present or absent) plus the size of the values, and lookup is trivial. The Shift table is 119KB = 27KB values + 92KB keys. The Goto table is 86KB = 30KB values + 57KB keys. (Goto has a smaller keyspace as #nonterminals < #terminals, and more entries). This patch improves glrParse speed by 28%: 4.69 => 5.99 MB/s Overall the table grows by 60%: 142 => 228KB. By comparison, DenseMap<unsigned, StateID> is "only" 16% faster (5.43 MB/s), and results in a 285% larger table (547 KB) vs the baseline. Differential Revision: https://reviews.llvm.org/D128485
Loading
Please sign in to comment