[
https://issues.apache.org/jira/browse/LUCENE-10129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17421485#comment-17421485
]
Robert Muir commented on LUCENE-10129:
--------------------------------------
There is already a fast Object[] one, which is already being used. This is why
i didn't touch the long[][]:
{code}
/** Returns the shallow size in bytes of the Object[] object. */
// Use this method instead of #shallowSizeOf(Object) to avoid costly
reflection
public static long shallowSizeOf(Object[] arr) {
return alignObjectSize(
(long) NUM_BYTES_ARRAY_HEADER + (long) NUM_BYTES_OBJECT_REF *
arr.length);
}
{code}
> Add RamUsageEstimator shallowSizeOf(long[]) overload that just calls
> sizeOf(long[])?
> ------------------------------------------------------------------------------------
>
> Key: LUCENE-10129
> URL: https://issues.apache.org/jira/browse/LUCENE-10129
> Project: Lucene - Core
> Issue Type: Task
> Reporter: Robert Muir
> Priority: Major
>
> See LUCENE-10128 for an example. The problem is there is only a
> {{sizeOf(long[])}}, so if the programmer uses {{shallowSizeOf}} instead of
> {{sizeOf}} then it falls back to {{shallowSizeOf(Object)}} which does a bunch
> of reflection.
> This is pretty crazy because it can create performance traps. Should we just
> add a {{shallowSizeOf(long[])}} that calls {{sizeOf(long[])}}, so that things
> are fast? (same for other primitive arrays). It would solve the problem
> easily I think.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]