Uwe Schindler created LUCENE-10342:
--------------------------------------

             Summary: Add (very limited) java.util.logging to Lucene Core
                 Key: LUCENE-10342
                 URL: https://issues.apache.org/jira/browse/LUCENE-10342
             Project: Lucene - Core
          Issue Type: New Feature
          Components: core/other
            Reporter: Uwe Schindler
            Assignee: Uwe Schindler


At the moment we have some parts in Lucene where we check for features of the 
JDK and use them, only if available:
- We only use MMapDirectory, if we can unmap, so sun.misc.Unsafe must be 
available
- To correctly calculate heap space requirements of data structures for caching 
and other types of buffers, we try to calculate the heap size of objects. To do 
this correctly we need some information like the size of ordinal object 
pointers. If they are 32 bits on 64 bit platforms, the memory usage of Object[] 
arrays (and HashSet/HashMaps) dramatically reduce size by factor of 2.

As those checks require "optional" modules in the java module system, which may 
not even be available by default as they are unsupported, we do the check 
dynamically.

With the Java module system the problems start, that a user of Lucene may need 
to add those modules to the module descriptor of the application. If he misses 
that or for some other reason it does not work (like feature is not available), 
we silently disable MMapDirectory or for memory usage we may be off by an 
factor of 2.

My suggestion is now to enable java.util.logging in Lucene's core (maybe also 
in other modules, too - luke is already) and report such warnings using 
java.util.logging. Any downstream code will see the logging then depending on 
the used logging system (log4j, slf4j with correct wrapper module).

I know this suggestion may cause a bit a flame war because of disagreement 
about pros and cons about if logging is needed, so I'd like to limit this to 
warnings+. We won't ever emit info/debug/trace. To make sure we only log "warn" 
and "error"/"severe" events, I will add a forbiddenapis rule to deny all other 
loglevels.

As a side effect I will also add an IndexWriter log stream implementation for 
java.util.logging to make it easy to log infostream events during indexing.

I will provide a PR adding 2 warnings and the InfoStream implementation.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to