Abstract
Tabling is an implementation technique that improves the declarativeness and expressiveness of Prolog systems in dealing with recursion and redundant sub-computations. A critical component in the design of a concurrent tabling system is the implementation of the table space. One of the most successful proposals for representing tables is based on a two-level trie data structure, where one trie level stores the tabled subgoal calls and the other stores the computed answers. In previous work, we have presented a sophisticated lock-free design where both levels of the tries where shared among threads in a concurrent environment. To implement lock-freedom we used the CAS atomic instruction that nowadays is widely found on many common architectures. CAS reduces the granularity of the synchronization when threads access concurrent areas, but still suffers from problems such as false sharing or cache memory effects. In this work, we present a simpler and efficient lock-free design based on hash tries that minimizes these problems by dispersing the concurrent areas as much as possible. Experimental results in the Yap Prolog system show that our new lock-free design can effectively reduce the execution time and scales better than previous designs.
Similar content being viewed by others
Notes
In general, a tabled program is deterministic, finite and only executes search and insert operations over the table space data structures. In Yap Prolog, space is recovered when the last running thread abolishes a table. Since no delete operations are performed, the size of the tables always grows monotonically during an evaluation.
Available at https://github.com/axel22/Ctries
We have experimented with multiple configurations for the separate chaining and hash levels. Our best results were obtained with four nodes for the separate chaining and 8 entries for the hash levels, which are the current default values for the experiments that follow.
Due to the lack of space, we are not including mixed insert/lookup benchmarks. Yet, we have experimented with a lot of mixed scenarios and we have verified that the results obtained are within the bounds of the results shown next for the insert(N) and lookup(N) benchmarks.
Note that we have separate implementations for Yap and for JDK.
References
Areias, M., Rocha, R.: An efficient and scalable memory allocator for multithreaded tabled evaluation of logic programs. In: International Conference on Parallel and Distributed Systems, pp. 636–643. IEEE Computer Society (2012)
Areias, M., Rocha, R.: Towards multi-threaded local tabling using a common table space. J. Theory Pract. Logic Program. 12(4 & 5), 427–443 (2012)
Areias, M., Rocha, R.: On the correctness and efficiency of lock-free expandable tries for tabled logic programs. In: International Symposium on Practical Aspects of Declarative Languages, no. 8324 in LNCS, pp. 168–183. Springer (2014)
Bagwell, P.: Ideal hash trees. Es Grands Champs 1195 (2001)
Chen, W., Warren, D.S.: Tabled evaluation with delaying for general logic programs. J. ACM 43(1), 20–74 (1996)
Dawson, S., Ramakrishnan, C.R., Warren, D.S.: Practical program analysis using general purpose logic programming systems—a case study. In: ACM Conference on Programming Language Design and Implementation, pp. 117–126. ACM (1996)
Fredkin, E.: Trie memory. Commun. ACM 3, 490–499 (1962)
Herlihy, M., Shavit, N.: The Art of Multiprocessor Programming. Morgan Kaufmann, Burlington (2008)
Herlihy, M., Wing, J.M.: Linearizability: a correctness condition for concurrent objects. ACM Trans. Program. Lang. Syst. 12(3), 463–492 (1990)
Johnson, M.: Memoization in top-down parsing. Comput. Linguist. 21(3), 405–417 (1995)
Marques, R., Swift, T.: Concurrent and local evaluation of normal programs. In: International Conference on Logic Programming, no. 5366 in LNCS, pp. 206–222. Springer (2008)
Marques, R., Swift, T., Cunha, J.C.: A Simple and efficient implementation of concurrent local tabling. In: International Symposium on Practical Aspects of Declarative Languages, no. 5937 in LNCS, pp. 264–278. Springer (2010)
Moura, P.: ISO/IEC DTR 13211–5:2007 Prolog multi-threading predicates (2008). http://logtalk.org/plstd/threads.pdf
Prokopec, A., Bronson, N.G., Bagwell, P., Odersky, M.: Concurrent tries with efficient non-blocking snapshots. In: ACM Symposium on Principles and Practice of Parallel Programming, pp. 151–160. ACM (2012)
Ramakrishna, Y.S., Ramakrishnan, C.R., Ramakrishnan, I.V., Smolka, S.A., Swift, T., Warren, D.S.: Efficient model checking using tabled resolution. In: Computer Aided Verification, no. 1254 in LNCS, pp. 143–154. Springer (1997)
Rocha, R., Silva, F., Santos Costa, V.: On applying or-parallelism and tabling to logic programs. Theory Pract. Log. Program. 5(1 & 2), 161–205 (2005)
Sagonas, K., Swift, T., Warren, D.S.: XSB as an efficient deductive database engine. In: ACM International Conference on the Management of Data, pp. 442–453. ACM (1994)
Santos Costa, V., Rocha, R., Damas, L.: The YAP Prolog system. J. Theory Pract. Log. Program. 12(1 & 2), 5–34 (2012)
Shalev, O., Shavit, N.: Split-ordered lists: lock-free extensible hash tables. J. ACM 53(3), 379–405 (2006)
Triplett, J., McKenney, P.E., Walpole, J.: Resizable, scalable, concurrent hash tables via relativistic programming. In: USENIX Annual Technical Conference, p. 11. USENIX Association (2011)
Zou, Y., Finin, T.W., Chen, H.: F-OWL: An inference engine for semantic web. In: International Workshop on Formal Approaches to Agent-Based Systems, LNCS, vol. 3228, pp. 238–248. Springer (2004)
Acknowledgments
This work is partially funded by the ERDF (European Regional Development Fund) through the COMPETE Programme and by FCT (Portuguese Foundation for Science and Technology) within projects SIBILA (NORTE-07-0124-FEDER-000059) and PEst (FCOMP-01-0124-FEDER-037281). Miguel Areias is funded by the FCT Grant SFRH/BD/69673/2010.
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
About this article
Cite this article
Areias, M., Rocha, R. A Lock-Free Hash Trie Design for Concurrent Tabled Logic Programs. Int J Parallel Prog 44, 386–406 (2016). https://doi.org/10.1007/s10766-014-0346-1
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10766-014-0346-1