soartech / jsoar

Pure Java implementation of the Soar cognitive architecture.
http://soartech.github.com/jsoar/
BSD 3-Clause "New" or "Revised" License
53 stars 19 forks source link

Wmes as list #130

Closed msche closed 3 years ago

msche commented 3 years ago

Refactored code so that WMEs are using java lists instead of custom linked list.

marinier commented 3 years ago

Unfortunately, jsoar did not use standard lists for performance reasons. The original analysis is described here:

https://github.com/soartech/jsoar/wiki/ListPerformanceAnalysis

ListHead (aka intrusive) lists are much faster for iteration, and jsoar does a LOT of list iteration. Additionally, jsoar's use of intrusive lists closely mirrors csoar's implementation, which helps port changes from csoar to jsoar, as the code is very similar in most cases.

marinier commented 3 years ago

Sorry, I don't mean to be discouraging, as this looks like it was a lot of work. Given the original analysis was done 8 years ago, it may be that Java has improved in ways that reduce or eliminate the performance difference. If that were the case, I agree that using standard lists would probably be easier for future development (it remains to be seen on the csoar porting, but that doesn't happen regularly anyway).

If an analysis could show that the changes were as performant as the current implementation, I'd consider this more deeply.

msche commented 3 years ago

Hi Marinier, no worries what I'm trying to do (for myself) is making the core a bit more understandable and start to understand it. Best way for me is doing some refactoring. How could I test the performance of JSoar to see whether my changes made it better or worse?

marinier commented 3 years ago

There is a jsoar-performance-testing subproject you could try. It was originally designed to compare jsoar and csoar, but they have diverged enough (which is to say, jsoar has not updated with the latest csoar changes in some years) that this doesn't work well for agents that use any of the advanced features (epmem, smem, chunking, RL, SVS). But for agents that are just straight rules (e.g., the simplest waterjugs, TOH, etc.) it's still works.

Anyway, what you really want to compare is two versions of jsoar. You can use jsoar-performance-testing for that, too. For this purpose I would suggest you look at jsoar-performance-testing/src/main/resources/example_configuration.yaml you can see how to make a test configuration (I recommend doing everything in the default settings, unless you really want to vary settings per test):

That's pretty much it. There are other settings you can play with -- it's easy to get lost in trying lots of different combinations of things :) The output will be a csv file with basic stats (e.g., average, min, max run times). You can easily import it into something like Excel.