Re: VectorUtil IMPL introspection?

"Uwe Schindler via dev" <[email protected]> Fri, 6 Feb 2026 18:07:55 +0100
Newsgroups gmane.comp.jakarta.lucene.devel
Message-ID <[email protected]>
Hi,

There is no native code involved at all. This just uses the Panama 
Vector or the simple implementation. The IMPL instance is initialized as 
soon as VectorUtil asks for the provider in its static initialization, 
so it is always initialized if VectorUtil is visible. But thats not the 
only place where it is used. Also some codecs and Tests use the provider 
for lookup, but all this code is explicitely whitelisted (with stack 
trace analysis) to prevent any code from accessing internals that's not 
allowed to.

The problem with the logging is that its coming from different 
(internal) places and that's not available to VectorUtil or even the 
provider class. There might be possibilities to hand this through, but 
requires refactoring. If this question goes in the direction of 
supressing the logging instead: Not a good idea, better configure your 
logging correctly!

Uwe

Am 06.02.2026 um 17:02 schrieb Michael Sokolov:
> +1 to that idea. My only Q would be whether the
> initialization/autodetection would have always already happened before
> users would have a chance to call these methods, or whether they would
> indeed trigger that check, or return "unknown" if it hadn't yet
> happened?  not sure when IMPL gets determined. Also, there is a
> further switch that may happen within the native implementation
> depending on the hardware. I think this would typically be done using
> an iFunc (one-time dynamic loading callback ) that determines which
> native impl gets used. It would be nice to expose that too, although
> maybe not a strict requirement.
>
> On Thu, Feb 5, 2026 at 6:33 PM Chris Hostetter <[email protected]> wrote:
>>
>> I know that when the o.a.l.util.VectorUtil gets loaded, there is some JUL
>> log messsages from the underlying VectorizationProvider to help inform
>> people running the application whether they are or are not getting the
>> Panama optimized vectorization support -- and if not why not.
>>
>> What I'm wondering: is there is any downside to having some really simple
>> (public) introspection API that apps could call to report (using their own
>> loging or metrics reporting APIs) what implementation is in use?
>>
>>
>> Maybe something as simple as ...
>>
>> VectorUtil:
>>
>>     public static boolean isImplNativeCodeOptimized() {
>>       return IMPL.isNativeCodeOptimized();
>>     }
>>     public static String getImplDescription() {
>>       return IMPL.getDescription();
>>     }
>>
>> VectorUtilSupport:
>>
>>     default boolean isNativeCodeOptimized() { return false; }
>>     String getDescription();
>>
>> DefaultVectorUtilSupport:
>>
>>     public String getDescription() { return "Default"; }
>>
>> PanamaVectorUtilSupport:
>>
>>     public boolean isNativeCodeOptimized() { return true; }
>>     public String getDescription() {
>>       return String.format(
>>               Locale.ENGLISH,
>>               "Java vector incubator API enabled; uses preferredBitSize=%d%s%s",
>>               PanamaVectorConstants.PREFERRED_VECTOR_BITSIZE,
>>               Constants.HAS_FAST_VECTOR_FMA ? "; FMA enabled" : "",
>>               VectorizationProvider.TESTS_VECTOR_SIZE.isPresent() ? "; testMode enabled" : "")
>>     }
>>
>> PanamaVectorizationProvider:
>>     // change logIncubatorSetup() ...
>>     // call this.vectorUtilSupport.getDescription()
>>
>>
>>
>>
>>
>> -Hoss
>> http://www.lucidworks.com/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
-- 
Uwe Schindler
Achterdiek 19, D-28357 Bremen
https://www.thetaphi.de
eMail: [email protected]