Introduction
In the field of natural language processing (NLP), unification-based grammar parsing remains a computationally intensive task. Graph unification, the core operation in these systems, often acts as the primary performance bottleneck. Traditional high-performance algorithms, such as those developed by Tomabechi and Wroblewski, utilize "scratch fields"—temporary administrative data stored directly within graph nodes to track the state of an ongoing unification.
While effective for single-threaded execution, this approach suffers from two critical limitations. First, it leads to significant memory waste, as these scratch fields occupy space even when nodes are idle. Second, it compromises thread-safety; because unification modifies the source graphs, concurrent processing on multi-core hardware is hindered by the need for complex locking or expensive data copying.
Methodology: Quasi-Destructive Unification
This paper presents a "quasi-destructive" algorithm designed to decouple the permanent graph definition from the transient control data required during unification. This separation is achieved through several key innovations.
External Scratch Tables and Interleaved Indexing
Instead of embedding scratch data within nodes, the proposed method moves this information to a separate, reusable array. To facilitate the unification of two graphs (Graph A and Graph B) using a shared scratch table, the algorithm employs an interleaved indexing technique.
As shown in the figure above, nodes are assigned unique indices. By assigning even indices to Graph A and odd indices to Graph B, the algorithm ensures that temporary data for both graphs can coexist in the same scratch table without collisions. This allows the source graphs to remain strictly read-only.
Node Packing and Structure Sharing
To further optimize memory, the algorithm implements "node packing," where type information is stored in the least significant bits of pointers. This reduces the size of atom and bottom nodes to a mere 4 bytes. Additionally, structure sharing is enabled through the use of relative offsets in arcs rather than absolute pointers, allowing subgraphs to be reused across different structures without duplication.
Experimental Evaluation
The algorithm was evaluated using a medium-sized Dutch grammar and a test set of 22 sentences. The implementation was coded in Objective-C and benchmarked on Pentium III and dual Pentium II systems to assess both sequential performance and parallel scalability.
Key Results and Discussion
The experimental results demonstrate that the proposed optimizations yield substantial improvements in both memory efficiency and execution speed.
Memory Efficiency
The combination of node packing and structure sharing significantly reduces the memory footprint of the parser. As illustrated in the performance data, the "packed" and "pack+share" variants maintain a much lower heap size compared to the standard Tomabechi implementation as sentence length increases.
The "packed" version alone reduced memory consumption by nearly 40%, while the addition of structure sharing halved usage again in many cases.
Performance and Scalability
Contrary to the expectation that external table lookups might introduce latency, the algorithm achieved a 7% speed increase over the Tomabechi standard. This is attributed to improved cache locality; smaller nodes allow more data to fit into the L2 cache, and the frequently accessed scratch table remains "hot."
Furthermore, the read-only nature of the source graphs enables seamless concurrent unification. On dual-processor systems, assigning independent scratch tables to each thread allowed for parallel processing without the overhead of synchronization locks.
Conclusion
By separating temporary unification data from permanent graph structures, this quasi-destructive approach addresses the dual challenges of memory overhead and thread-safety in NLP parsing. The resulting system is not only more memory-efficient but also faster and inherently scalable for modern multi-core architectures.
Summary updated