[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] [patch #6555] malloc improvement
From: |
Gerben van den Broeke |
Subject: |
[avr-libc-dev] [patch #6555] malloc improvement |
Date: |
Sat, 28 Jun 2008 14:05:51 +0000 |
User-agent: |
Mozilla/5.0 (compatible; Konqueror/3.5; Linux 2.6.23-hardened-r12; X11; i686; en_US) KHTML/3.5.9 (like Gecko) |
URL:
<http://savannah.nongnu.org/patch/?6555>
Summary: malloc improvement
Project: AVR C Runtime Library
Submitted by: gerben
Submitted on: Saturday 06/28/2008 at 16:05
Category: None
Priority: 3 - Low
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
Current implementation:
malloc loops trough all the holes in the freelist, checking if there is a
hole with exactly the right size (len), in which case it takes the hole and
returns it.
While looping it also notes down the size of the smallest hole it has found
that is still big enough (size > len).
If it cannot find a hole with exactly the right size, it will use this noted
hole.
But because it only noted the size of the hole, it loops through all the
holes again until it has found a hole with that size, then uses that hole.
Improvement:
By not only noting down the size of the smallest hole, but also noting its
addrress, the second loop is not necessary anymore.
The cost:
2 more pointers are needed (both the found hole and the hole before it must
be remembered), so it might add 4 pushes at the beginning and 4 pops at the
end of the function.
In the first loop two movw's are needed to note down the hole address, which
are executed everytime a smaller hole is found.
The gain:
The whole second loop can be removed, which saves much program space (whole
malloc becomes about 10% smaller) and even more execution time.
Note: using -Wall gcc produces a warning:
avr-libc-1.6.2/libc/stdlib/malloc.new.c: In function 'malloc':
avr-libc-1.6.2/libc/stdlib/malloc.new.c:68: warning: 'sfp2' may be used
uninitialized in this function
avr-libc-1.6.2/libc/stdlib/malloc.new.c:68: warning: 'sfp1' may be used
uninitialized in this function
If gcc would have been smarter it would see that they are not used
uninitialized.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Saturday 06/28/2008 at 16:05 Name: malloc.diff Size: 3kB By: gerben
<http://savannah.nongnu.org/patch/download.php?file_id=15951>
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/patch/?6555>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-dev] [patch #6555] malloc improvement,
Gerben van den Broeke <=