{"action":"created","issue":{"url":"https://api.github.com/repos/jmacglashan/burlap/issues/132","repository_url":"https://api.github.com/repos/jmacglashan/burlap","labels_url":"https://api.github.com/repos/jmacglashan/burlap/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/jmacglashan/burlap/issues/132/comments","events_url":"https://api.github.com/repos/jmacglashan/burlap/issues/132/events","html_url":"https://github.com/jmacglashan/burlap/issues/132","id":170148164,"number":132,"title":"Hashing Performance in SimpleHashableState","user":{"login":"Addy90","id":6824664,"avatar_url":"https://avatars.githubusercontent.com/u/6824664?v=3","gravatar_id":"","url":"https://api.github.com/users/Addy90","html_url":"https://github.com/Addy90","followers_url":"https://api.github.com/users/Addy90/followers","following_url":"https://api.github.com/users/Addy90/following{/other_user}","gists_url":"https://api.github.com/users/Addy90/gists{/gist_id}","starred_url":"https://api.github.com/users/Addy90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Addy90/subscriptions","organizations_url":"https://api.github.com/users/Addy90/orgs","repos_url":"https://api.github.com/users/Addy90/repos","events_url":"https://api.github.com/users/Addy90/events{/privacy}","received_events_url":"https://api.github.com/users/Addy90/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-09T11:57:34Z","updated_at":"2016-08-09T16:32:32Z","closed_at":null,"body":"While doing performance profiles, I noticed that in the IISimpleHashableState-Class in the valuesEqual()-Method the isArray()-Call is used. That call has a quite bad performance and perhaps it can be replaced by something more efficient... like you can see here: [http://stackoverflow.com/questions/16170548/object-isarray-is-slow-is-there-a-fast-way-to-do-that](http://stackoverflow.com/questions/16170548/object-isarray-is-slow-is-there-a-fast-way-to-do-that)\r\n\r\n![showcase](https://cloud.githubusercontent.com/assets/6824664/17515456/c465078c-5e38-11e6-9999-ac09971739e2.JPG)\r\n\r\nPerhaps by replacing with instanceof Object[] like supposed on stackoverflow we get a significant performance gain in the HashableState Comparison as the isArray()-Methods are called for every variable compared... Just a suggestion! Maybe there are more places like this in the code, you should do a search for \"isArray\" maybe..."},"comment":{"url":"https://api.github.com/repos/jmacglashan/burlap/issues/comments/238610558","html_url":"https://github.com/jmacglashan/burlap/issues/132#issuecomment-238610558","issue_url":"https://api.github.com/repos/jmacglashan/burlap/issues/132","id":238610558,"user":{"login":"brawner","id":1044986,"avatar_url":"https://avatars.githubusercontent.com/u/1044986?v=3","gravatar_id":"","url":"https://api.github.com/users/brawner","html_url":"https://github.com/brawner","followers_url":"https://api.github.com/users/brawner/followers","following_url":"https://api.github.com/users/brawner/following{/other_user}","gists_url":"https://api.github.com/users/brawner/gists{/gist_id}","starred_url":"https://api.github.com/users/brawner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brawner/subscriptions","organizations_url":"https://api.github.com/users/brawner/orgs","repos_url":"https://api.github.com/users/brawner/repos","events_url":"https://api.github.com/users/brawner/events{/privacy}","received_events_url":"https://api.github.com/users/brawner/received_events","type":"User","site_admin":false},"created_at":"2016-08-09T16:32:32Z","updated_at":"2016-08-09T16:32:32Z","body":"I'm not sure if this functionality exists in burlap 3, but I had fairly\ngood results by using immutable states (copy on write) that also used\nimmutable objects and attributes. When new states were created by taking\nactions, they just modified the attributes and objects that were necessary,\nand kept references to everything else. I believe this has been carried\nforward into burlap 3.\n\nThe advantage of this with regard to hashing, is that you can write a\nHashFactory, and associated HashedState that cache the hash values. Then,\nonly the modified objects and values need to be rehashed. It can\nsignificantly reduce cache times, which has large advantages in state\nexploration.\n\nJames, does this functionality exist in burlap 3 at the moment?\n\nOn Tue, Aug 9, 2016 at 12:20 PM, Adrian <notifications@github.com> wrote:\n\n> I made various tests with replacing isArray but finally tried out the\n> benchmark I linked to on stackoverflow. Well the result is kind of\n> annoying... it looks like the Java VM already optimized this case.\n>\n> These are my results of the same benchmark that was linked on\n> stackoverflow:\n> {s instanceof Object[]} spends 14ms\n> {s.getClass().isArray()} spends 14ms\n> {s.getClass().getName().charAt(0) == '['} spends 16ms\n>\n> That was the same in my tests I did this afternoon. Though in the\n> Profiler, one can see that the isArray() Method uses a lot of time, when I\n> replace it with instanceof Object\n> <http://so%20that%20the%20software%20works%20as%20before>, the time it\n> needs stays the same, it just is not used within isArray() anymore.\n>\n> So after all this never was an issue, it just looked like one that fooled\n> both of us - I am sorry for that.\n> The reason I was digging this deep around is that I am writing several\n> Reflection-Classes for building domains via Annotations so that\n> ObjectInstances, PropositionalMethods, RewardMethods, SampleStates,\n> OOStates and all of that are generated by the Reflection-Classes.\n>\n> Of course this approach leads to two problems: Performance and what\n> happens if you have special problems that the reflection classes do not\n> cover. Well in the latter one you need to write your own code again or\n> expand the reflection classes until they cover all possibilities. For my\n> special problem I do the latter as it keeps the composition of the classes\n> away so that I can focus on the domain variables, actions and method\n> implementations with having dependency injection that calls my methods with\n> the right objects already casted (and no String[] params variables). It's\n> some kind of simplification.\n>\n> What I want is that this approach is not much slower than the normal way\n> from the tutorials. And it indeed is possible to be nearly as fast with two\n> ideas: Caching and MethodHandles\n> <https://docs.oracle.com/javase/8/docs/api/java/lang/invoke/MethodHandles.html>.\n> So while building the domain via reflecting the classes, I generate\n> MethodHandles that I later can call nearly as fast as native calls. And I\n> cache all that so when the planning runs it uses the already created\n> MethodHandles. Well and while digging with the StateHashing (like I can\n> annotate a field wether it is relevant for the state hash or not, what is\n> the reason why I use the MaskedHashableState) I found that \"issue\".\n>\n> So at the moment, I am depending heavily on your provided\n> HashableStateFactories as I am mostly optimizing for usability though still\n> thinking of the performance so that it does not become too slow, which\n> works quite good for now... but it is not finished, just something I am\n> trying for being able to work faster with BURLAP.\n>\n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/jmacglashan/burlap/issues/132#issuecomment-238606744>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/AA_x-jDa9ZnMBV3opeGj4r-oC1K-RR6Qks5qeKi5gaJpZM4Jf_6t>\n> .\n>\n"}}
{"actor":{"display_login":"brawner"}}