Does anyone know the usage of nspr_use_zone_allocator

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Does anyone know the usage of nspr_use_zone_allocator

Eagle.Lu
Hi,experts,

Who knows the usage of nspr_use_zone_allocator. In
http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/src/malloc/prmem.c#186
PR_InitZones() tries to load symbol "nspr_use_zone_allocator" which is
not defined   anywhere. This will chose Mozilla to load many shared
libraries which will increase Mozilla startup time.

I think this option is not necessary. Can anyone tell me what is it
used for?

Thanks

Brian

_______________________________________________
Mozilla-nspr mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-nspr
Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know the usage of nspr_use_zone_allocator

Justin Wood (Callek)
I am by far no expert, but from what I can dig up, it seems to be
"nspr_use_zone_allocator" is something you can define in a dll/main
program to "do yourself" the stuff in:
http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/src/malloc/prmem.c#195

If you want to make the load-time fast (with current NSPR) as-in,
without ever loading the other run-time-dependancies, define that
[external symbol], with nothing more than a return of a true value.

I would personally suggest to allow this "feature" of NSPR to be an
optionally turned off compile option, (on by default).

WTC if I made any gross errors, please correct me. (please do comment if
I am entirely correct as well)

Disclaimer: This is far from my personal expertise, and I barely have
even touched much of the subject, so do not use my words as complete
fact, only conjecture. ;-)

~Justin Wood (Callek)

[hidden email] wrote:

> Hi,experts,
>
> Who knows the usage of nspr_use_zone_allocator. In
> http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/src/malloc/prmem.c#186
> PR_InitZones() tries to load symbol "nspr_use_zone_allocator" which is
> not defined   anywhere. This will chose Mozilla to load many shared
> libraries which will increase Mozilla startup time.
>
> I think this option is not necessary. Can anyone tell me what is it
> used for?
>
> Thanks
>
> Brian
>
_______________________________________________
Mozilla-nspr mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-nspr
Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know the usage of nspr_use_zone_allocator

Wan-Teh Chang
Justin Wood (Callek) wrote:
> I am by far no expert, but from what I can dig up, it seems to be
> "nspr_use_zone_allocator" is something you can define in a dll/main
> program to "do yourself" the stuff in:
> http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/src/malloc/prmem.c#195

Justin, you are half right.

nspr_use_zone_allocator is indeed a global variable that you
can define in a dll/main program.  If it is defined and has
the value PR_TRUE, NSPR will use the zone allocator, i.e., the stuff in
http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/src/malloc/prmem.c#195.
On the other hand, if it is not defined or has the value PR_FALSE,
NSPR will simply use the regular malloc, calloc, and free in libc.

> If you want to make the load-time fast (with current NSPR) as-in,
> without ever loading the other run-time-dependancies, define that
> [external symbol], with nothing more than a return of a true value.

Brian reported that it is the act of checking that symbol that
causes Mozilla to load many shared libraries.  So whether the
symbol is defined or not doesn't matter to the load time.

But I don't understand why the checking of that symbol causes
Mozilla to load many shared libraries.  This is how the checking
is defined on Solaris:
http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/src/malloc/prmem.c#125

125 pr_FindSymbolInProg(const char *name)
126 {
127     void *h;
128     void *sym;
129
130     h = dlopen(0, RTLD_LAZY);
131     if (h == NULL)
132         return NULL;
133     sym = dlsym(h, name);
134     (void)dlclose(h);
135     return sym;
136 }

It calls dlopen with the magic pathname 0.  That shouldn't
cause Mozilla to load anything new.

zone allocator is an alternate memory allocator.  By default
NSPR uses libc's malloc, calloc, and free. You can tell NSPR
to use the zone allocator by defining the nspr_use_zone_allocator
global variable in your program or setting the
NSPR_USE_ZONE_ALLOCATOR environment variable.

Wan-Teh

_______________________________________________
Mozilla-nspr mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-nspr