Logo
  • Assets
  • Contact
  • About
  • Forums
  • Login

strongly recommended to improve the efficiency of deserialization

Forums › 💬 NodeCanvas › ⚙️ Support › strongly recommended to improve the efficiency of deserialization

  • This topic has 0 replies, 4 voices, and was last updated 9 years, 8 months ago by Gavalakis.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • August 27, 2015 at 11:58 am #18970
    fenglin
    Participant

      Our project stuck when loading ai. Load a ai, json parsing and graph reconstruction will take up almost 80% resources , memory consumption exceeded more than 5M. Although we use the preload mechanism when the level is loaded , but the memory consumption increases, and the placing of the monster has a lot of limitations. It is strongly recommended to improve the efficiency of deserialization. Otherwise, for a gaming experience that there is a lot of damage . Sorry , my native language is not English , I hope not wrong expression , thank you 🙂

      August 28, 2015 at 12:42 pm #18975
      Gavalakis
      Keymaster

        Hey,

        Indeed, I will have to greatly optimize deserialization. It is already in the immediate TODO list and I hope I manage to improve it for the next version.

        Thanks!

        September 14, 2015 at 11:39 pm #18974
        akyangliao
        Participant

          This is a great product, but I am having the same issue with my company games. This really limit us how many monsters to put into each level. Right now, it use about 40MB to deserialize and the tree is not even big. I have about 30 nodes and 10 variables in the character. And there is about 10 to 20 different characters in each level. I hope you can improve this soon.

          Cheers!!

          October 15, 2015 at 6:34 pm #18973
          etouve
          Participant

            I posted about my solution here (did this back in v.2.1)

            http://nodecanvas.com/forums/topic/optimizations-2/

            Essentially I end up caching off the parsed JSON data.

            JSONSerializer:

            1
            2
            3
            4
            5
            6
            7
            8
            9
            10
            11
            12
            13
            14
            15
            16
            17
            18
            19
            20
            21
             
            public static object Deserialize(Type type, string serializedState, fsData parsedDataIn, out fsData parsedDataOut, List<UnityEngine.Object> objectReferences = null)
            {
                 .
                 .
                 fsData data = null;
                 if (parsedDataIn == null)
                 {
                    data = fsJsonParser.Parse(serializedState);
                    parsedDataOut = data;
                 }
                 else
                 {
                    data = parsedDataIn;
                 }
                 .
                 .
                 .
            }
             
             

            Then Deserialized calls look like this, which saves the parsed json, and also passes it in for additional calls to deserialize:

            Graph.cs:

            1
            2
            3
            4
            5
            6
            7
            8
            9
            10
            11
            12
            13
            14
            15
            16
             
            private fsData _jsonCached; // member to hold parsed json
             
            public bool Deserialize(string serializedGraph, bool validate, List<UnityEngine.Object> objectReferences)
            {
               .
               .
               .
               fsData jsonParsed;
               var data = JSONSerializer.Deserialize<GraphSerializationData>(serializedGraph, _jsonCached, out jsonParsed, objectReferences);
               _jsonCached = jsonParsed;
               .
               .
               .
            }
             

            There maybe a better way to do this with newer versions.

            October 16, 2015 at 12:28 am #18972
            Gavalakis
            Keymaster

              Hey,

              I honestly missed your other post entirely :/
              Thanks for this info. It’s something I still look into vastly improve soon.

              I think what you did is a good idea. I will try this and some other similar things that come in mind soon and will reply back on your other post.

              Thanks! 🙂

              October 16, 2015 at 6:00 pm #18971
              etouve
              Participant

                Thanks Gavalakis

                Btw – here is my custom Graph.Clone:

                1
                2
                3
                4
                5
                6
                7
                8
                9
                10
                11
                12
                13
                14
                 
                ///Clones the graph and returns the new one. Currently exactly the same as Instantiate, but could change in the future
                public static T Clone<T>(T graph) where T:Graph{
                    var newGraph = (T)Instantiate(graph);
                    .
                    .
                    .
                    // Manual deserialization taking advantage of pre-parsed graph in source graph
                    newGraph._jsonCached = graph._jsonCached;
                    newGraph.Deserialize(newGraph._serializedGraph, false, newGraph._objectReferences);
                 
                    return newGraph;
                }
                 
              • Author
                Posts
              Viewing 6 posts - 1 through 6 (of 6 total)
              • You must be logged in to reply to this topic.
              Log In

              Footer Logo

              Home | Contact | Privacy Policy
              Twitter | Discord | YouTube
              Paradox Notion

              • Login
              • Register
              Forgot Password?
              Lost your password? Please enter your username or email address. You will receive a link to create a new password via email.
              body::-webkit-scrollbar { width: 7px; } body::-webkit-scrollbar-track { border-radius: 10px; background: #f0f0f0; } body::-webkit-scrollbar-thumb { border-radius: 50px; background: #dfdbdb }