[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #57321] Performance degradation due to memory
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #57321] Performance degradation due to memory allocation |
Date: |
Fri, 6 Dec 2019 13:18:39 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:60.9) Goanna/4.1 PaleMoon/28.2.0a1 |
Follow-up Comment #5, bug #57321 (project octave):
Consider the following loop:
a = 1;
b = 1;
for k = 1:10
b = b + a;
end
It can be roughly translate to c++ :
double *a = new double (1);
double *b = new double (1);
for (int k = 1; k <=10; k++)
{
double *temp = new int(*b + *a);
*b = *temp;
delete temp;
}
Each plus operation invokes the memory allocator.
The real number of allocations is far more than this. Using Api Monitor in
Windows a loop of 7,000 iterations in Octave results in about 4,800,000
mallocs or about 700 allocations per iteration.
I also attached a test program in c++ that measures the performance of the
"plus" operator. Two classes are defined one of them uses the memory pool and
the other class uses memory allocation. It can be seen that the memory pool
can provide 6X speedup.
I haven't compiled the Octave so I can't say how the memory pool can affect
its performance. But I expect it will provide an improvement.
Thanks for your attention!
(file #48018)
_______________________________________________________
Additional Item Attachment:
File name: test_pool.cpp Size:3 KB
<https://savannah.gnu.org/file/test_pool.cpp?file_id=48018>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?57321>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/