473,729 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to reduce Zero Initialised region.

Hi ,
I work on an ARM processor based embedded system. Code is mainly in
C language. The project has a huge source base. We are supposed to
optimise it. Most datastructures are declared as static and which
directly go into the Zero Initialised region. We need to cut the size
of this ZI region by at least 30%.
The one way i see of doing this is by removing these static arrays
and passing a pointer to the data structure whenever required. but
since these global arrays are used through out the code. A re-write
seems inevitable!

two questions I had.
1. Am I right in doing this(passing pointer instead of making the data
structure static) ?
2. Is there any alternative to this ?
Thanks in Advance,
Ajai.

Jan 31 '07 #1
37 2331
Ajai Jose wrote:
two questions I had.
1. Am I right in doing this(passing pointer instead of making the data
structure static) ?
Yes. Better design, IMO.
2. Is there any alternative to this ?
Hard work yields better rewards.
Jan 31 '07 #2
Ajai Jose a écrit :
Hi ,
I work on an ARM processor based embedded system. Code is mainly in
C language. The project has a huge source base. We are supposed to
optimise it. Most datastructures are declared as static and which
directly go into the Zero Initialised region. We need to cut the size
of this ZI region by at least 30%.
The one way i see of doing this is by removing these static arrays
and passing a pointer to the data structure whenever required. but
since these global arrays are used through out the code. A re-write
seems inevitable!

two questions I had.
1. Am I right in doing this(passing pointer instead of making the data
structure static) ?
2. Is there any alternative to this ?
Thanks in Advance,
Ajai.
Why do you think that this is the problem?

Did you measure the program's performance to see where the
hot spots are? What data leads you to your conclusion that
the static data is the problem?

If you pass pointers around it can be a better design but it will
be slightly slower, since global data needs nothing to be passed, it is
always there.

Before doing anything MEASURE FIRST!

jacob
Jan 31 '07 #3
jacob navia wrote:
Why do you think that this is the problem?

Did you measure the program's performance to see where the
hot spots are? What data leads you to your conclusion that
the static data is the problem?

If you pass pointers around it can be a better design but it will
be slightly slower, since global data needs nothing to be passed, it is
always there.
He did mention he was on an embedded system. This could be a space rather than
speed issue.
Jan 31 '07 #4
1. Am I right in doing this (passing pointer instead of making the data structure static) ?

That will make the executable larger. How much increase can be
tolerated?

2. Is there any alternative to this ?
In my experience people use UINT32s everywhere because they don't want
to look old fashioned. I suggest studying the values assigned to
datums in these structures. Maybe a UINT16 would work equally well.
But don't go around sticking UINT8s in the middle of a data structure.
-Samuel S

Jan 31 '07 #5
On Jan 31, 4:29 pm, Christopher Layne <cla...@com.ano dizedwrote:
jacob navia wrote:
Why do you think that this is the problem?
Did you measure the program's performance to see where the
hot spots are? What data leads you to your conclusion that
the static data is the problem?
If you pass pointers around it can be a better design but it will
be slightly slower, since global data needs nothing to be passed, it is
always there.

He did mention he was on an embedded system. This could be a space rather than
speed issue.
Yes Chrisopher is rgt. The problem we have is real estate we do not
have enough RAM and performance is not an issue.

Thanks,
Ajai.

Jan 31 '07 #6
On Jan 31, 4:48 pm, "Samuel Stearley" <nya...@gmail.c omwrote:
1. Am I right in doing this (passing pointer instead of making the data structure static) ?

That will make the executable larger. How much increase can be
tolerated?

I mean passing an extra parameter to a function might increase code
size(text segment). Some additional code for sending the parameter
during function prolog. that is all the penalty right ?
but it will free some space of the ZI region when it comes to big
arrays.
>
2. Is there any alternative to this ?

In my experience people use UINT32s everywhere because they don't want
to look old fashioned. I suggest studying the values assigned to
datums in these structures. Maybe a UINT16 would work equally well.
But don't go around sticking UINT8s in the middle of a data structure.

-Samuel S
I understand what you are pointing at but I am particularly looking at
some huge global arrays which eat into the ZI region in a big way.
Small structures I have seen that the original developer has done a
good job.

Thx,
Ajai.
Jan 31 '07 #7
I mean passing an extra parameter to a function might increase code
size(text segment). Some additional code for sending the parameter
during function prolog. that is all the penalty right ?
but it will free some space of the ZI region when it comes to big
arrays.
Where else would the large array of structures be stored? In the
stack frame of caller so many levels up? How large is you stack?

Jan 31 '07 #8
Ajai Jose wrote:
Hi ,
I work on an ARM processor based embedded system. Code is mainly in
C language. The project has a huge source base. We are supposed to
optimise it. Most datastructures are declared as static and which
directly go into the Zero Initialised region. We need to cut the size
of this ZI region by at least 30%.
The one way i see of doing this is by removing these static arrays
and passing a pointer to the data structure whenever required. but
since these global arrays are used through out the code. A re-write
seems inevitable!

two questions I had.
1. Am I right in doing this(passing pointer instead of making the data
structure static) ?
Yes. Or maybe No. We don't know enough about the
constraints and circumstances of your situation to be able
to say with certainty.
2. Is there any alternative to this ?
You might consider a sort of intermediate strategy: Make
the pointer(s) global and static, and initialize them to
point to dynamically-zeroed memory when the program starts.
That is, if the program as it stands now has

int BigArray[LARGE]; /* static and zeroed */

you might change it to

int *BigArray; /* only the pointer is static */
...
void initialize(void ) {
BigArray = calloc(LARGE, sizeof *BigArray);
if (BigArray == NULL)
die_horribly();
}

.... and arrange to call initialize() before BigArray is needed
elsewhere in the code.

--
Eric Sosman
es*****@acm-dot-org.invalid

Jan 31 '07 #9
Ajai Jose wrote:
On Jan 31, 4:48 pm, "Samuel Stearley" <nya...@gmail.c omwrote:
>>>1. Am I right in doing this (passing pointer instead of making the data structure static) ?

That will make the executable larger. How much increase can be
tolerated?

I mean passing an extra parameter to a function might increase code
size(text segment). Some additional code for sending the parameter
during function prolog. that is all the penalty right ?
but it will free some space of the ZI region when it comes to big
arrays.
Why do you want to reduce the size of only zero-initialized RAM?

I assume that code and data are in separate memory spaces. Usually,
though, the zero-initialized static data area, data area allocated to
automatic variables (normally on a stack), and the heap all share the
same physical memory, which is divided according to the program usage
(although there are cases in which some memory is battery-backed, which
other is not).

You can reduce RAM requirements by replacing local static variables with
automatic variables if the value does not need to be carried from one
invocation to another. That allows the memory to be shared among
several functions that execute at different times. There is no need to
pass pointers if there is no data involved.

--
Thad
Jan 31 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6328
by: Margaret MacDonald | last post by:
Probably it's something dumb that I'm doing/not doing, but echo doesn't seem to want to echo a literal zero when the value of some var is zero. E.g.: $foo = 0 ; echo 'foo is ' . $foo ; yields: foo is
181
8854
by: Tom Anderson | last post by:
Comrades, During our current discussion of the fate of functional constructs in python, someone brought up Guido's bull on the matter: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 He says he's going to dispose of map, filter, reduce and lambda. He's going to give us product, any and all, though, which is nice of him.
1
1476
by: John Smith | last post by:
I have a two dimentional char array. Before filling it using strtok(), I reset its elements to '\0' using two nested for loops. The code works as I hope it would but I wonder whether I really need to reset the array. The program would run faster if I don't need to reset. ------------------------------------------ int Array(void) .................
3
2399
by: Ali Sahin | last post by:
Hi there, I'd like to transform a XML-File to PDF. The XML-File ist build like followed: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml-stylesheet type="text/xsl" href="D:\app\jboss-3.2.5\server\default\deploy\xifs.war\WEB-INF\classes\de\xifs\resource\xml\de\xifs\resource\xml\dunningaccountreport_de.xsl"?> <!DOCTYPE entities >
14
52471
by: rocketman768 | last post by:
Man, that title should be in a poem, but anyways...So, I have this program, and it has an array of 40 million elements. The problem is that I have a for loop that continually is doing stuff to this array, and for each iteration, I have to zero out the array. This is how I am currently doing it: // Zero out the lnscores for( count=0; count < chunksize; count++ ) lnscores = 0; Is there no quicker way to do this? I know there must be...
3
2938
by: mark | last post by:
I have a table of UK companies whose records I want to filter using a map of postcode regions. For the benfit of people outside the UK, our postcodes are a pain to work with because they are not a standard length, and the part which identifies the region isn't a standard length either. The first letters of the postcode denotes a general region, and then sub-regions are denoted by the following numbers and letters.
1
3293
by: replyrpatil | last post by:
What I am trying to do: I need to print a compact access report (font 6 size) created using RTF2 program developed by Stephen Lebans to generate a TIF image of custom size (5.5 in x 2.0 in) Problem Recreation : Download attached RAR file (http://download.yousendit.com/627919383AFAA7E3 ) Steps 1) Install RTF2 program created by Lebans 2) Install ZAN Image Printer (Virtual Printer) 3) Create Custom Paper Size ----...
10
2436
by: werasm | last post by:
Hi all, I recently just stumbled upon this code. According to what I see in the standard it should be fine, but I've always done the initialization explicitly myself: //.h //... struct X {
2
1990
by: JenavaS | last post by:
Hi all, I have a query: SELECT Data.Region, Data.Dept, Data.Year, Data.Month, Data.Week, Data.Elapsed, Data. AS WpComp, Data. AS CpComp, IIf(=53 And ="JAN,WK4",/2,) AS AdjLyComp, round((-IIf(=53 And ="JAN,WK4",/2,))/IIf(=53 And ="JAN,WK4",/2,),6) AS WpVarLy, round((-IIf(=53 And ="JAN,WK4",/2,))/IIf(=53 And ="JAN,WK4",/2,),6) AS CpVarLy FROM ((Data INNER JOIN Years ON Data.Year=Years.Year) INNER JOIN LyWk ON (Data.Week=LyWk.TyWk) AND...
0
8913
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.