Skip to content

Improves memory efficiency of building indexes.#331

Merged
alex-kulakov merged 9 commits intomasterfrom
master-indexinfo-imp
Aug 18, 2023
Merged

Improves memory efficiency of building indexes.#331
alex-kulakov merged 9 commits intomasterfrom
master-indexinfo-imp

Conversation

@alex-kulakov
Copy link
Copy Markdown
Contributor

  • allows to skip some copying of underlying indexes for Union and Join indexes
  • shrinks size of final ColumnIndexMap for real-world models, reduce amount of lists (and capacity changes)

This should be merged after #297.

@alex-kulakov
Copy link
Copy Markdown
Contributor Author

@SergeiPavlov, this should reduce memory usage, especially on big models without lazy columns (declared lazy in FieldAttribute). Similar to List<T>, it may waste some array space, but not more than (number of lazy columns + TypeId column) but it doesn't use copying when capacity of list changes. Since list grows x2 every time for regular columns we could easily stuck with inner array of 32 items with 15 wasted items or worse. Statistically, memory consumption will grow if >50% of all of columns in index are lazy but I assume it is very rare case.

P.S. On my test model of 400 entities in 200 hierarchies containing 8700 IndexInfo instances (domain.Model.Types.SelectMany(t => t.Indexes).Count()), this change reduced allocated memory by 1 MB (from 244MB down to 243MB).

Comment thread Orm/Xtensive.Orm/Orm/Model/IndexInfo.cs Outdated
Comment thread Orm/Xtensive.Orm/Orm/Model/IndexInfo.cs Outdated
@SergeiPavlov
Copy link
Copy Markdown
Contributor

Looks good to me

Comment thread Orm/Xtensive.Orm/Orm/Model/IndexInfo.cs
@alex-kulakov alex-kulakov merged commit ca837a4 into master Aug 18, 2023
@alex-kulakov alex-kulakov deleted the master-indexinfo-imp branch August 18, 2023 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants