eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. ๐—น๐—ถ๐—ป๐—ธ๐—ฒ๐—ฑ๐—ถ๐—ป.๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ.๐—ฐ๐—ผ๐—บ, ๐˜†๐—ผ๐˜‚๐˜๐˜‚๐—ฏ๐—ฒ.๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ.๐—ฐ๐—ผ๐—บ and ๐˜๐˜„๐—ถ๐˜๐˜๐—ฒ๐—ฟ @๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ and or simply ๐—ฆ๐˜๐—ฎ๐—ฟ/๐˜„๐—ฎ๐˜๐—ฐ๐—ต this repository and get notified from ๐—š๐—ถ๐˜๐—›๐˜‚๐—ฏ
http://expand.expandframework.com
Microsoft Public License
222 stars 115 forks source link

Improve ModelCache Generation in Xpand #814

Closed vimarx closed 10 months ago

vimarx commented 3 years ago

test.zip If you enable Model Caching (https://docs.devexpress.com/eXpressAppFramework/DevExpress.ExpressApp.XafApplication.EnableModelCache) expand generates a lot of unnecessary nodes. Attached test.zip with demo program and Model Cache file, if you analyze it, you can see a very unuseful node info for each column, something as `

      <OptionsColumnGridView>
        <ModelMappers>
          <MapperContextContainer Id="Default" />
          <MapperContextContainer Id="ModelMapperAttribute" />
        </ModelMappers>
      </OptionsColumnGridView>
      <OptionsColumnLayoutView>
        <ModelMappers>
          <MapperContextContainer Id="Default" />
          <MapperContextContainer Id="ModelMapperAttribute" />
        </ModelMappers>
      </OptionsColumnLayoutView>
      <OptionsPivotField>
        <ModelMappers>
          <MapperContextContainer Id="Default" />
          <MapperContextContainer Id="ModelMapperAttribute" />
        </ModelMappers>
      </OptionsPivotField>
      <TreeListColumnOptions>
        <ModelMappers>
          <MapperContextContainer Id="Default" />
          <MapperContextContainer Id="ModelMapperAttribute" />
        </ModelMappers>
      </TreeListColumnOptions>
    </ColumnInfo>`

Please note, that also, with medium-to-large apps, the model generation throws an Out-of-Memory exception while trying to generate model cache. Memory consumption is nearly 10 x during this process

apobekiaris commented 3 years ago

ith medium-to-large apps, the model generation throws an Out-of-Memory exception

model generation on what context? Run with Debugger?, without Debugger?, what platform? need as many details as u can think

vimarx commented 3 years ago

Win app, runtime, without a debugger. If you take a look at the generated Modecache.xafml, it is too large.

apobekiaris commented 3 years ago

are these extradiffs to blame? can u tell?

apobekiaris commented 3 years ago

how large is the cache file

vimarx commented 3 years ago

how large is the cache file

In a production app (1200 bo, 10000 properties),, model cache is about 60mg (attached) and memory consumption increase to 8000 megabytes during model generation, while in normal use, it uses about 500 mg. Model.Cache.xafml.zip

apobekiaris commented 3 years ago

Huge app how long it takes to runtime with debugger attached?

vimarx commented 3 years ago

Huge app how long it takes to runtime with debugger attached?

a couple of minutes, but memory requirement breaks my debugger session for this app. I'm curious about the repeated '<ColumnInfo Id> </ColumnInfo>'that is automatically generated for EACH column ...

apobekiaris commented 3 years ago

the ModelMapper can be improved to globally prevent caching but at the moment it is possible to experiement your self

class MyClass:ModelNodesGeneratorUpdater<ModelViewsNodesGenerator> {
    public override void UpdateNode(ModelNode node) {
        ((ModelNode) node.GetValue("MyCustomObject")).SetValue(ModelValueNames.NeedsCachingKey, false);
    }
}

Replace the MyCustomObject with large model trees u have e.g. GridView, Dashboard etc. and let me know your results please

apobekiaris commented 3 years ago

the MyClass needs registration in your Module.cs

vimarx commented 3 years ago

GridView

what is the exactly string "GridView" , "GridViewOptions"? they give null reference

image

apobekiaris commented 3 years ago

the position u try to invoke the GridViewOptions is wrong the node is an IModelVIews interface

u have to find the location its the root of each map

image

apobekiaris commented 3 years ago

so for the screenshot u have a GridView property in the IModelListView interface and since u have an IModelViews u can enumerate it and change the caching behaviour as in the snippet

vimarx commented 3 years ago

Not sure what I'm doing ... but something as

class MyClass : ModelNodesGeneratorUpdater<ModelViewsNodesGenerator>
    {
        public override void UpdateNode(ModelNode node) { node.SetValue(ModelValueNames.NeedsCachingKey, false); }
    }

do not reduce or change output modelcache file

apobekiaris commented 3 years ago

hmm I would expect this to effect all VIews, need to ask the XAF team I will get back to u on this on Mon

apobekiaris commented 3 years ago

We will try to answer all questions that do not require research within 24hr. To prioritize cases that require research we use the following labels in order. For all other issues the posting time is respected.

  1. โ‡๏ธ Exclusive-Services
    1. โค Bronze Sponsor
    2. โค Sponsor
    3. โค Backer
    4. Installation
    5. ShowStopper
    6. Nuget
    7. Contribution
    8. BreakingChange
    9. ReproSample
    10. Deployment
    11. must-have

This case is prioritized.

apobekiaris commented 2 years ago

Issue is deprioritized as no Assignee found and scheduled for auto-close if no activity in the next 60 days. Thanks a lot for your contribution.

expand commented 10 months ago

Closing issue for age. Feel free to reopen it at any time.

.Thank you for your contribution.