Search Unity

Large Code Base Lag

Discussion in 'Scripting' started by deus0, Jul 18, 2021.

  1. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    Hey, so my lines of code is around 70k atm. It's primarily in ECS and I've done most things from the ground up since its a procedural project. Just wondering if the code size is what's lagging it (for every code update I make)? And if it might be worth looking into compiling DLL's or something out of modules of my code, to make working on it faster?

    This is my largest project so far, as before ECS it was too hard to manage this much code in a performant way. Either way I thought it'd be worth asking on the forums as I couldn't find answers from googling.

    Screenshot_2021-07-19_03-44-45.png
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,747
    I'm told using asmdefs and partitioning your codebase can help reduce overall compilation times. I have not experienced this myself but I haven't really agonizingly tested it.

    I also know that asmdefs have lots of other little "Oh this works differently now" issues as well, such as binding your folder structures to your class namespaces.

    I would not use DLLs because they a) don't really seem to help speed-wise, b) they come with a whole host of other assembly related hassles issues, and c) with interactive code, the ability instantly modify and instrument code anywhere in the codebase is simply too valuable to give up.
     
    deus0 likes this.
  3. flytraparts

    flytraparts

    Joined:
    Dec 2, 2019
    Posts:
    11
    Like kurt said
    it would be best to create separate assembly definitions for different components
    it's gonna be hard if your code wired too tight together with a lot of references

    think of each part of the game as a separate asset
    for example give the Character controller a separate assembly definition or something like that
    it's pretty hard to do in a later phase of development but you can do it and i hope you'll get it to work
     
    deus0 likes this.
  4. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    Hey! Okay neat! I'm looking into asmdefs now. Thank you for your help :)
    https://letsmakeagame.net/assembly-definition-files-tutorial/

    Maybe this will help me keep some of my core code in them? Is this how one can create packages as well?
    My codes ECS so it's really modular (ECS is amazing :D)
    ... But still some of the gameplay stuff is a bit tighter, and UI is everywhere! So lots of core gameplay stuff has some UI reliance. And i've been trying to use generic components to cut down my code haha..
     
  5. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    After lots and lots of file changes over several hours. I managed to find my least coupled system group and give it an assembler definition :) I believe the compilation time for changes has been slightly reduced haha.
    This was what I was after I think, can't believe it's been around for a few years now.
    Time to keep working on my dependencies haha. :D:eek:o_O
    BurstCompilation.png BurstCompilation2.png
     
  6. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    Actually, scratch that. I did a test with a single file (a test asm definition and a test script file). When I update it, it still updates all the burst methods. BurstTest.png

    Edit: After some thinking, perhaps it will only speed up after I've set up the entire project to use assembler references?
     
    Last edited: Jul 22, 2021
  7. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    I ran into Type Manager errors during the process, because unity entities type manager had kept my old types, had to reinstall the Burst Package and restart the editor to fix that bug.