[ 
https://issues.apache.org/jira/browse/TIKA-2520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16489288#comment-16489288
 ] 

ASF GitHub Bot commented on TIKA-2520:
--------------------------------------

mbaechler commented on issue #237: TIKA-2520 optimize OptimaizeLangDetector 
default loadModel()
URL: https://github.com/apache/tika/pull/237#issuecomment-391770468
 
 
   I'm a bit surprise because I did it myself on branch_1x: 
   ```
   [INFO] 
------------------------------------------------------------------------
   [INFO] Reactor Summary:
   [INFO] 
   [INFO] Apache Tika parent ................................. SUCCESS [  1.237 
s]
   [INFO] Apache Tika core ................................... SUCCESS [ 19.513 
s]
   [INFO] Apache Tika parsers ................................ SUCCESS [03:27 
min]
   [INFO] Apache Tika XMP .................................... SUCCESS [  1.712 
s]
   [INFO] Apache Tika serialization .......................... SUCCESS [  1.491 
s]
   [INFO] Apache Tika batch .................................. SUCCESS [02:00 
min]
   [INFO] Apache Tika language detection ..................... SUCCESS [  2.341 
s]
   [INFO] Apache Tika application ............................ SUCCESS [ 55.028 
s]
   [INFO] Apache Tika OSGi bundle ............................ SUCCESS [ 11.241 
s]
   [INFO] Apache Tika translate .............................. SUCCESS [  2.242 
s]
   [INFO] Apache Tika server ................................. SUCCESS [ 21.370 
s]
   [INFO] Apache Tika examples ............................... SUCCESS [ 13.538 
s]
   [INFO] Apache Tika Java-7 Components ...................... SUCCESS [  2.075 
s]
   [INFO] Apache Tika eval ................................... SUCCESS [ 20.426 
s]
   [INFO] Apache Tika Deep Learning (powered by DL4J) ........ SUCCESS [02:33 
min]
   [INFO] Apache Tika Natural Language Processing ............ SUCCESS [ 23.690 
s]
   [INFO] Apache Tika ........................................ SUCCESS [  0.011 
s]
   [INFO] 
------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO] 
------------------------------------------------------------------------
   [INFO] Total time: 10:57 min
   [INFO] Finished at: 2018-05-24T17:36:34+02:00
   [INFO] Final Memory: 169M/1667M
   [INFO] 
------------------------------------------------------------------------
   ```
   Are you using the same branch ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> OptimaizeLangDetector#loadModels() should not be called for every single 
> langdetect HTTP request
> ------------------------------------------------------------------------------------------------
>
>                 Key: TIKA-2520
>                 URL: https://issues.apache.org/jira/browse/TIKA-2520
>             Project: Tika
>          Issue Type: Improvement
>          Components: server
>    Affects Versions: 1.16
>            Reporter: Vincent van Donselaar
>            Priority: Minor
>              Labels: performance
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Tika REST server's `/language` resource invokes the relatively heavy 
> `loadModels` operation for every language detect call:
> {code:title=LanguageResource.java}
> public String detect(final String string) throws IOException {
>       LanguageResult language = new 
> OptimaizeLangDetector().loadModels().detect(string);
>       String detectedLang = language.getLanguage();
>       LOG.info("Detecting language for incoming resource: [{}]", 
> detectedLang);
>       return detectedLang;
> }
> {code}
> This could be optimized by (lazy?) loading the models only once and keep them 
> in memory. I assume the `LanguageDetector` is not thread safe, so I expect 
> this requires an ExecutorService with language detectors.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to