From: Terrance S. <ts...@cs...> - 2007-03-19 12:00:29
|
Michael, and others: I really need to stop assuming that problems people encounter are the result of problems in XSB. Its often true, but not always. This test does not use indexing. XSB is slow since assert runs the indexing chain to put the term at the end -- so the time is quadratic in the number of facts asserted. I don't know of a Prolog that doesn't behave this way -- does anyone on this list? However if you use star indexing: :- index(p/3,*(1)), you get the following results (with minor changes to Michael's file). | ?- assert_them(50000). *** Inserting... Insert time = 0.5090 yes | ?- retract_them(50000). *** Deleting... Delete time = 0.4830 So XSB is actually very efficient at asserts and retracts. As an aside, to cut down on the assert time you could use asserta, but this does nothing much for the retract time. XSB's indexing of dynamic facts is actually one of its most useful features -- probably David (who did most of the implementation) should have written a paper about it just so people would know if and use it. Terry On Fri, 16 Mar 2007, Michael Kifer wrote: > > > I tried to run a simple test to see how assert/retract perform now, and the > results are no good. > > The attached program is supposed to do 50K inserts and then 50K deletes of > the same. The inserts finished in 51 secs on a 2G dual core, but I am still > waiting for the deletes to finish after more than 1 hour!! > > In contrast, a similar FLORA-2 program was doing 500K inserts and 500K > deletes (i.e., 1 times more). The inserts finished after 10 secs and > deletes after 899 secs. > > The difference is that FLORA-2 uses trie_intern, while XSB uses assert. > The deletes in trie_intern have a known inefficiency, which Terry promised > to fix "real soon", so I expect that it will take significantly less after > the fix. (For 50K deletes FLORA-2 takes only 6 secs, and only 1 sec for 50K > inserts.) > > I also did a simple test to insert 50K records into MySQL. I couldn't > figure out how long it takes exactly, but it came back after 3-4 seconds. > (as opposed to 50 secs for assert and 1 sec for trie_intern). > How can it be? > (Deleting records in MySQL also sucks -- probably because I didn't do any > indexing -- but at least it returns after some 30 minutes.) > > I think XSB asserts/retracts needs a serious look into. > > By the way, I did the same test with XSB 2.7.1. Interestingly, 50K inserts > too 78 secs there vs 51 secs now. It's a progress :-) > > > --michael > > > > |