4 Replies Latest reply on Mar 15, 2007 10:52 AM by bob_ninja

    PojoCache vs serialized bean in TreeCache

    bob_ninja

      I am looking at both TreeCache and PojoCache for beans. My primary focus at the moment is performance of updates. The bean contains the usual mix of string and integer properties. Nothing fancy.

      I am following the PojoCache examples to store my bean in a PojoCache. The alternative would be to serialize it and store byte[] in a TreeCache. In terms of modifications, about the worst case scenario (for TC) would be update to a boolean property which is encoded in an integer. Thus what happens when a single integer property is modified.

      PojoCache using AOP updates the single attribute in the bean's node. The transaction will update bean's node.
      The alternative is to serialize modified bean and put (update) it in tree cache. The transaction will update entire bean's serialized state.
      The default logic is that single attribute update is cheaper/faster than entire serialized state.

      However, my bean is simple (no child objects). It is about 170 bytes serialized. Serialization processing itself is fast, about 37 ns/bean on an average PC. Seems that the actual data content sent for replication purposes is minor between the 2 cases. So really performance is almost the same.

      I do have another bean which is parent of this one. I would serialize them separately and update them individually. I could use special locking attributes to ensure atomic updates to parent and children.

      The reason I am asking this is because I am not sure that the added complexity of PojoCache and aspects are worth the minor benefit. When I started using Hibernate it instrumented my beans automatically without extra compiling steps and classes (or at least very few classes). Also PojoCache seems to be still young and API is changing, so difficult to use. TreeCache is fairly simple.

      Anyway let me know what ou think. thanks

        • 1. Re: PojoCache vs serialized bean in TreeCache
          genman

          I would try the PojoCache and then decide. Personally, I side on writing easier to maintain code, at the expense of efficiency. The APIs do change, but likely the places you need to access the API are few.

          • 2. Re: PojoCache vs serialized bean in TreeCache
            bob_ninja

            Agreed. I would prefer simpler PojoCache.
            However, I am running into problems. Also, the new version 2.0 seems to contain a lot of changes, so I wonder how stable/finished PojoCache is, or if it has a lot more API adjustments and bug fixing to go.

            • 3. Re: PojoCache vs serialized bean in TreeCache
              manik

              What problem sare you running into?

              2.0 is a big API change from the 1.x series, not just for PojoCache but for TreeCache as well. In terms of API, this should not change again so writing against the 2.0 API is what I'd recommend.

              Regarding the PojoCache vs TreeCache debate, I'd go with the "simpler code" option as well, and use PojoCache.

              That said, I don't see why you need to serialize your beans to use TreeCache? You could just put the objects directly in TreeCache, the only difference is that the entire object will be replicated rather than the object being broken down into primitives.

              • 4. Re: PojoCache vs serialized bean in TreeCache
                bob_ninja

                 

                "manik.surtani@jboss.com" wrote:
                What problem sare you running into?


                Here is the post:

                http://www.jboss.com/index.html?module=bb&op=viewtopic&t=103869

                Should I enter it into JIRA?

                "manik.surtani@jboss.com" wrote:

                2.0 is a big API change from the 1.x series, not just for PojoCache but for TreeCache as well. In terms of API, this should not change again so writing against the 2.0 API is what I'd recommend.


                So I should skip 1.4.x and start with the latest 2.x beta? Ok, I'll try that.

                "manik.surtani@jboss.com" wrote:

                Regarding the PojoCache vs TreeCache debate, I'd go with the "simpler code" option as well, and use PojoCache.

                That said, I don't see why you need to serialize your beans to use TreeCache? You could just put the objects directly in TreeCache, the only difference is that the entire object will be replicated rather than the object being broken down into primitives.


                Ah, so TreeCache automatically handles serialization. Good stuff.

                Ok, so I'll try again PojoCache using the latest 2.x

                thanks