Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- From: "Robert Klemme" <bob.news@xxxxxxx>
- Date: Wed, 31 Aug 2005 15:40:00 +0200
Chris Uppal wrote:
> Robert Klemme wrote:
>
>>> [me]
>>> You could always write custom array operations in JNI. Otherwise
>>> the answer is no (not without a change to the JVM design, which
>>> isn't going to happen).
>>
>> I'm not sure whether array accesses via JNI actually bypass bounds
>> checks.
>
> It does. The way the JNI interfaces work (for arrays of primitive
> types -- which are the only kind worth considering in this context)
> the API gives you (at its choice) either a pointer to the data (which
> you have to return explicitly) or a pointer to a temporary copy of
> the data (which you also have to return). In either case access to
> the individual elements is at full memory speed. There is no need to
> issue a JNI call for each array access.
Ah, thanks for the heads up.
> Also note that it is very unlikely that the overhead of copying (if
> it happens at all) would matter. Copying is O(n), but unless the
> operation itself were significantly more expensive than O(n) there
> would be no point in optimising it.
Erm, strictly speaking copying becomes relatively cheaper (and thus
neglectible) if the op is worse than O(n), doesn't it? Anyway, even if
the op is O(n) you could neglect copying - from a theoretical perspective
(O(n) = O(2n)). It might be different in practice if arrays are huge (mem
allocation overhead) or if they are small and there are many invocations.
Kind regards
robert
.
- Follow-Ups:
- Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- From: Patricia Shanahan
- Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- References:
- To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- From: Casey Hawthorne
- Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- From: Chris Uppal
- Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- From: Robert Klemme
- Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- From: Chris Uppal
- To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- Prev by Date: Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- Next by Date: Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- Previous by thread: Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- Next by thread: Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- Index(es):
Relevant Pages
|