Open dyzheng opened 8 months ago
As we know, memory usage involves several cases:
So usually we should focus on the 1st and 2nd point, especially the 2nd one. Furthermore, I think it is better to analyze them independently(stack-memory v.s. time, heap-memory v.s. time) rather than analyze the whole memory usage(memory v.s. time).
I suggest some tools for profiling of stack memory and heap memory as follows:
At last, we should define the problem:
I suggest to overload new and delete operators to record memory usage. Reference: https://www.cprogramming.com/tutorial/operator_new.html cc: @dyzheng @Religious-J
I suggest to overload new and delete operators to record memory usage. Reference: https://www.cprogramming.com/tutorial/operator_new.html cc: @dyzheng
I don't think so, the first reason is the new and delete would be called many times, the record memory operators would lead to poor performance; the second reason is there are some containers don't use the new or delete, such as containers in STL, maybe they use malloc or others; the third reason is the purpose of memory records in ABACUS is not for record exact memory cost, but for developers to analyze the memory cost of algorithm, only few classes or functions are the hotspots, we only need to find and record them.
I don't think so, the first reason is the new and delete would be called many times, the record memory operators would lead to poor performance; the second reason is there are some containers don't use the new or delete, such as containers in STL, maybe they use malloc or others; the third reason is the purpose of memory records in ABACUS is not for record exact memory cost, but for developers to analyze the memory cost of algorithm, only few classes or functions are the hotspots, we only need to find and record them.
To the first reason, the overloaded operators can only used in memory debugging mode but not global scope. To the second reason, that's right and maybe we should find some solutions. To the third reason, we need to discuss how we invent tools for developers to analyze the memory cost of algorithm and in which cases.
Solving the current memory record error is important, however we may not depend on developers to find and record memory every time in the future.
Please also pay attention to #3852
Describe the Code Quality Issue
There are memory related issues now:
3789 there are some errors in memory loggings.
3675 Memory cost is too large in LCAO code, and the loggings is not enough.
3710 Memory cost in PW code is not enough too.
3657 Memory cost is too large in NSPIN=4 calculation in LCAO code.
Additional Context
There are two methods to record the used memory in ABACUS:
cmake -B build -DDEBUG_INFO=1
and then check the remaining memory in everyModuleBase::TITLE()
function.MEMORY(MB)
block in OUT.{suffix}/running_{calculation}.log .Ideally, these two method can get same peak memory cost in one calculation, but now they are not.
We should try to follow all memory records in
TITLE
to fix the omissiveModuleBase::Memory::record()
.Task list for Issue attackers (only for developers)