harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Garrett Rooney" <roo...@electricjellyfish.net>
Subject Re: [classlib]Using APR for Harmony's native link to the OS
Date Tue, 04 Jul 2006 15:53:57 GMT
On 7/4/06, Marina Goldburt <marina.v.goldburt@gmail.com> wrote:
> Hi,
>
>
>
> To support the idea mentioned in the letter
> http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200602.mbox/%3C43F06F25.8040304@gmail.com%3E,
>
> I've tried to implement the file I/O  part of the Harmony portlib using APR.
>
> The JIRA issue with the patch is
> http://issues.apache.org/jira/browse/HARMONY-751.
>
>
>
> The main difficulty to implement I/O function using APR was the lack of
> modularity in the classlib native code (the other (not portlib) modules
> relies on the portlib functions returning OS I/O handles (but APR uses its
> own handles)).
>
>
>
> Please, review the patch and comment if the efforts to move OS/platform
> specific code to APR make sense and can be useful.

For what it's worth, speaking as an APR developer, I really don't
think this makes sense the way APR currently works.

In this patch you're basically taking the approach of allocating a new
pool whenever you need to call into an APR function.  This is
inefficient in the normal case (things like where you're doing it to
call stat, then destroying the pool afterwards), since you end up
allocating 8k worth of data to create the pool, only to free it
immediately afterwards.  It's worse in other cases, like in
hyfile_open where you create a new pool to hold the file, but then
proceed to leak it, returning from the function without stashing the
pool anywhere, so you can't ever destroy it, it'll stick around until
apr_terminate is called (probably via atexit, although I haven't
looked at the entire patch so I don't know when it's actually being
called).

Until a version of APR exists that doesn't require the use of memory
pools, this approach is simply not reasonable to take.  If you want to
work on making it possible to use APR without pools, please feel free
to join us over on dev@apr and discuss the issue, I think it's an
interesting task, and I'd love to talk about it.  But until then,
making use of APR in a garbage collected environment like a Java class
library is simply not going  to make sense for anything other than
highly specialized situations where the pool overhead is acceptable
(see the Tomcat JNI based APR connector for example).

-garrett

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message