https://issues.apache.org/bugzilla/show_bug.cgi?id=49236

톰캣의 jar안에 META-INF/INDEX.LIST 파일이 존재하는데, 이를 생성하는  톰캣 ant의 <jar index="true"/> 에 대한 이야기이다. 내용을 정리해서 올린다.


톰캣 Committer 중의 하나인 Konstantin Kolinko는 jar indexing이 로딩 속도를 빠르게 빠르게 하기 위해서 jar index 태그를 사용했다고 한다.

Jar 스펙 (http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#JAR Index) 을 참조

  • INDEX.LIST
This file is generated by the new "-i" option of the jar tool, which contains location information for packages defined in an application or extension.  It is part of the JarIndex implementation and used by class loaders to speed up their class loading process.


Konstantin Kolinko는 더이상 속도 개선이 없다고 한다. 사실 jar 자체가 이미 zip 인덱스를(central driectory) 가지고 있기 때문이기 때문이라고 얘기한다.

zip-application-note 자료
http://www.pkware.com/documents/casestudies/APPNOTE.TXT

zip 도식화
http://en.wikipedia.org/wiki/ZIP_%28file_format%29#Technical_information

ZIPformat.jpg

ZipEntry의 getEntry(String) 메소드와 같이 random access 을 하기 전에 이미 java는 jar파일의 central directory를  메모리에 로딩하기 때문에 속도가 빠를 수 밖에 없다.

또한, URLClassLoader에서 로딩할 때마다 index.list 파일을 한 번 더 체크하기 때문에 성능 이슈가 있을 수 있다

index.list 파일은 jar 의 MANIFEST.MF파일의 class-path와 conflict 될 수 있는 소지가 있고, jar 파일의 이름을 변경함으로서, side effect가 생길 수 있다.

그래서 tomcat의 빌드시 jar태그의 index속성을 "false"로 지정한다.
Posted by '김용환'
,