Tuesday, July 11, 2006

Get the Best Performance out of Java in the Database

When you run Java in the database, what are the various execution modes? Are you taking the most efficient approach? In this post I'll touch on the various execution modes for running Java in the Oracle database.

As we all know, the best execution performance for Java is achieved via binary executables obtained through compilation (JIT compilers and/or static compilers). The Oracle Database currently furnishes a static native Java compiler known as NCOMP, which must be explictly invoked ahead of the deployment.

There are currently three execution modes: (i) fully interpret, (ii) NCOMPed System classes, and (iii) fully NCOMPed (or NCOMPed User Classes).

Fully Interpreted (System and User Classes)
In this mode, both system classes and the user classes, run interpreted. During the database installation, the non-compiled Java VM system classes are installed. By default, user classes also run interpreted and most customers stick to the default mode and are happy with the level of performance obtained, mostly because, as explained in previous posts and in my book, the combination of Java and SQL run faster in the database (even fully interpreted). However, this is not the most efficient execution mode.

NCOMPed System Classes and Interpreted User Classes
In this mode, the system classes run natively compiled while user classes run interpreted. The natively compiled system classes (NCOMP libraries) are installed explictly following the default database install, from the companion CD. Without further explcit action, the user classes run interpreted on top of the natively compiled system classes. The overall peformance is greater than the previous mode (i.e., fully interpreted).

Fully NCOMPed (System and User Classes)
In this mode, the system and user classes run natively compiled. User NCOMP requires an explicit action from the developers. It comprises three commands/steps: 'NCOMP', 'STATUSNC', and 'DEPLOYNC'.

NCOMP

This command takes Java bytecodes that have been resolved and verified during the loading phase (loadjava) and can therefore be trusted and expected to execute correctly, then does three things:
  1. gathers class info, generates a script that will drive the NCOMPing process, and produces the list of NEED_NCOMPNG orALREADY_NCOMPED methods
  2. Pauses for the Java-to-C translation: C compilation and linkage of each package involved into platform-specific DLLs
  3. Deployment/installation of the resulting DLL (unless -noDeploy) is specified


ncomp [ options ] class_designation_file
-user -u username/password [@database_url]
[-load]
[-projectDir -d project_directory]
[-force]
[-lightweightDeployment]
[-noDeploy]
[-outputJarFile -o jar_filename]
[-thin]
[-oci -oci8]
[-update]
[-verbose]

STATUSNC

This command checks whether the JAR files, ZIP files, or CLASSES files are NCOMPed or not.
statusnc [ options ] .jar .zip
.classes.
-user /[@database]
[-output -o ]
[-projectDir -d ]
[-thin]
[-oci -oci8]

DEPLOYNC

This command deployd the natively compiled deployment JAR file, to the database.
deploync [options] deployment.jar
-user -u username/password [@database_url]
[-projectDir -d project_directory]
[-thin]
[-oci -oci8]

Conclusions

NCOMP may give an order of magnitude speed up (i.e., 10 times) compared to interpreted execution. But as usual, there is no absolute figure; it all depends on what exactly you are NCOMPing as NCOMP speeds up only Java code, not the embedded SQL.

See more details in the Java Developer's Guide of the Oracle Database documentation nd in my book.

23 comments:

Anonymous said...

I bought your book and hoped it would be straight forward to finally got my java classes ncomp'd. Unfortunately I even failed to get the first example to work. Well, the first part where the code is interpreted works but then ncomping it fails.

I got a bunch of error messages, advising me to add additional grants, i.e.

The PL/SQL to grant this is dbms_java.g
rant_permission( 'SCOTT', 'SYS:oracle.aurora.rdbms.HandlePermission', 'HandleInp
utStream.SYS.java.lang.Object', '' )
ORA-06512: in "SYS.DBMS_JAVA", Zeile 198
ORA-06512: in "SCOTT.JACCELERATOR_GET_CLASS_BITS", Zeile 1

However following the advice does not help at all.

Since it seems that your book is the only one on that subject and also google queries do not return helpfull results, I'm a bit wondering whether non Oracle developers really use ncomping.

Another question, not covered in the book and nowhere else (oracle docs, google,.. ) are prerequistes for ncomping (in addition to the companion cd), e.g. does one need a C compiler (if yes, which one), etc ...

Maybe you could unveil some more of the secrets of Oracle Database Java Programming.

Kuassi Mensah said...

Hi,

Before ncomping, the schema where it runs must be granted javasyspriv
and java_deploy from sqlplus, as follows:

sqlplus sys/install
grant javasyspriv to scott;
grant java_deploy to scott;
exit

Regarding the need for a C compiler, in NCOMP Configuration and PLanning in section 2.6.6, i mention the Settings_os.properties
file which is preconfigured for gcc. Sorry if this was not clear enough.
Let me know how it goes, Kuassi

Anonymous said...

Hi,

thank your for your answer.

I already was aware of these required
role grants. So I'll still stuck with the described error where the reported ncom problem on executing

select jaccelerator_get_class_bits('java/lang/Object', 'SYS'), jaccelerator_get_class_digest('java/lang/Object', 'SYS') from dual

fails (either for ncomp and sqlplus) and the suggested soltution to add the lacking permission SYS:oracle.aurora.rdbms.HandlePermission
does not help.


Regarding the need for a C compiler
for which configuration is mentioned in 2.6.7 in my copy of your book my understanding of that section was that there are some for options available for applying some more fine tuning. So it was not clear at all, that the separate installation of a C compiler is mandatory.
(which I've already fixed now for my test environment but obviously this isn't the problem at the moment).

Do you have any further idea?
Would it be reasonable to post a request to Oracle metalink?

Kuassi Mensah said...

Hi,

Regarding the C compiler, you are right, i should have been more explicit.

Regarding the error message, we have seen similar error messages and most of the time, granting JAVA_DEPLOY fixes the problem.

It seems like you have already gone through all this, so i'd suggest to file a Metalink TAR so that Support and development can look into this.

Thanks, Kuassi

Ayisha said...

Nice and knowledgeable gifts for everyone-
booksshelf
knowledge
books
liberary
kitaben
Books and references
books

Anonymous said...

dbms_java.grant_permission( 'SCOTT', 'SYS:oracle.aurora.rdbms.HandlePermission', 'HandleInp
utStream.SYS.java.lang.Object', '' ) is invalid.
valid is :
dbms_java.grant_permission( 'SCOTT', 'SYS:oracle.aurora.rdbms.HandlePermission', 'HandleInp
utStream.SYS.java.lang.Object', '*' )

Itba 40.000 y otros said...

Hi kuassi,
I have a problem running ncomp. I ncompED my JAR file, but when i see in the database there are some classes that are incompiled. why is that?
The classes are:
MinimizeNcompListAndDumpTC
TransitiveClosureDump
[JAR Filename]_minimalClassLib

I try to compile mannualy with Toad but doesnt compile, and didnt show any code or description in the error.

I couldnt run my program without compiling these classes because i make a validate the connection with this query :
select * from user_objects where status != 'VALID';

Thanks in advance
Juan

Kuassi Mensah said...

Hello,

These classes are used internally by NCOMP itself; you need to exclude these from your query results.

Kuassi

Itba 40.000 y otros said...

thanks a lot,
One more question, it's normal that these classes keep incompiled?

Anonymous said...

情趣用品,情趣用品,情趣用品,情趣用品,情趣,情趣,情趣,情趣,按摩棒,震動按摩棒,微調按摩棒,情趣按摩棒,逼真按摩棒,G點,跳蛋,跳蛋,跳蛋,性感內衣,飛機杯,充氣娃娃,情趣娃娃,角色扮演,性感睡衣,SM,潤滑液,威而柔,香水,精油,芳香精油,自慰套,自慰,性感吊帶襪,吊帶襪,情趣用品加盟AIO交友愛情館,情人歡愉用品,美女視訊,情色交友,視訊交友,辣妹視訊,美女交友,嘟嘟成人網,成人網站,A片,A片下載,免費A片,免費A片下載愛情公寓,情色,舊情人,情色貼圖,情色文學,情色交友,色情聊天室,色情小說,一葉情貼圖片區,情色小說,色情,色情遊戲,情色視訊,情色電影,aio交友愛情館,色情a片,一夜情,辣妹視訊,視訊聊天室,免費視訊聊天,免費視訊,視訊,視訊美女,美女視訊,視訊交友,視訊聊天,免費視訊聊天室,情人視訊網,影音視訊聊天室,視訊交友90739,成人影片,成人交友,美女交友,微風成人,嘟嘟成人網,成人貼圖,成人電影,A片,豆豆聊天室,聊天室,UT聊天室,尋夢園聊天室,男同志聊天室,UT男同志聊天室,聊天室尋夢園,080聊天室,080苗栗人聊天室,6K聊天室,女同志聊天室,小高聊天室,上班族聊天室,080中部人聊天室,同志聊天室,聊天室交友,中部人聊天室,成人聊天室,一夜情聊天室,情色聊天室,寄情築園小遊戲情境坊歡愉用品,情趣用品,成人網站,情人節禮物,情人節,AIO交友愛情館,情色,情色貼圖,情色文學,情色交友,色情聊天室,色情小說,七夕情人節,色情,情色電影,色情網站,辣妹視訊,視訊聊天室,情色視訊,免費視訊聊天,美女視訊,視訊美女,美女交友,美女,情色交友,成人交友,自拍,本土自拍,情人視訊網,視訊交友90739,生日禮物,情色論壇,正妹牆,免費A片下載,AV女優,成人影片,色情A片,成人論壇,情趣,免費成人影片,成人電影,成人影城,愛情公寓,成人影片,保險套,舊情人,微風成人,成人,成人遊戲,成人光碟,色情遊戲,跳蛋,按摩棒,一夜情,男同志聊天室,肛交,口交,性交,援交,免費視訊交友,視訊交友,一葉情貼圖片區,性愛,視訊,視訊聊天,A片,A片下載,免費A片,嘟嘟成人網,寄情築園小遊戲,女同志聊天室,免費視訊聊天室,一夜情聊天室,聊天室

said...

A片,A片,成人網站,成人漫畫,色情,情色網,情色,AV,AV女優,成人影城,成人,色情A片,日本AV,免費成人影片,成人影片,SEX,免費A片,A片下載,免費A片下載,做愛,情色A片,色情影片,H漫,A漫,18成人

a片,色情影片,情色電影,a片,色情,情色網,情色,av,av女優,成人影城,成人,色情a片,日本av,免費成人影片,成人影片,情色a片,sex,免費a片,a片下載,免費a片下載

情趣用品,情趣用品,情趣,情趣,情趣用品,情趣用品,情趣,情趣,情趣用品,情趣用品,情趣,情趣

A片,A片,A片下載,做愛,成人電影,.18成人,日本A片,情色小說,情色電影,成人影城,自拍,情色論壇,成人論壇,情色貼圖,情色,免費A片,成人,成人網站,成人圖片,AV女優,成人光碟,色情,色情影片,免費A片下載,SEX,AV,色情網站,本土自拍,性愛,成人影片,情色文學,成人文章,成人圖片區,成人貼圖

情色,AV女優,UT聊天室,聊天室,A片,視訊聊天室

Anonymous said...

童裝批發
童裝批發
童裝
童裝
酒店喝酒
酒店消費
暑假打工
寒假打工
酒店經紀人
酒店現領
禮服店
酒店小姐
酒店兼職
酒店上班
酒店兼職
禮服店
酒店上班
酒店打工
酒店小姐
酒店經紀
酒店兼差
假日打工
台北酒店經紀
寒暑假打工
專業酒店經紀
酒店藝名
台北酒店
酒店日保
酒店入行
台北禮服店
酒店類型
酒店午場
酒店規定
酒店行政
酒店資訊

Edwin said...

Buy Kamagra
Earn Google
Viagra Cialis
Cheap Kamagra
Cheap Viagra
Cheap Cialis
Make Money on Google
M65 Jacket
M65 Field Jacket
Airline Dog Carrier
Airline Dog Carriers
Viagra Cialis
Earn Google
Airline Dog Carrier
Airline Dog Carriers
Airline Approved Dog Carriers
ED Hardy Wholesale
Copy DVD Software
How to Send Fax
14k Yellow Gold
Redneck Costume
14k Gold Heart
Tandem Baby Stroller

VUONG said...

先物 比較
先物 比較
先物 比較
先物 比較
先物 比較
先物 比較
先物 比較
先物 比較
事業再生
経営計画書
経営改革
経営改善
会社分割
経営コンサルティング
お見合いパーティー 名古屋
お見合いパーティー 名古屋
お見合いパーティー 名古屋
お見合いパーティー 名古屋
お見合いパーティー 名古屋
お見合いパーティー 名古屋
お見合いパーティー 名古屋
お見合いパーティー 名古屋
お見合いパーティー 名古屋
お見合いパーティー 名古屋
浮気調査 浅草
浮気調査 市川
備考調査 追跡調査 東京
不倫調査 離婚調査 東京
浮気調査 素行調査 東京 
ストーカー相談 ストーカー対策 東京
結婚調査 結婚詐欺 東京
信用調査 企業調査 東京
調査料金 東京
身上調査 身元調査 身辺調査 東京
所在調査 東京
夫 妻 浮気 東京

VUONG said...

大規模修繕
大規模修繕
大規模修繕
大規模修繕
大規模修繕
大規模修繕
大規模修繕
大規模修繕
大規模修繕
大規模修繕
英会話 横浜
英語 メール
英語塾
社会人入試
toeic対策
ライムライト
紙箱
会社設立 手続き
派遣 事務
東横 賃貸
田園都市 賃貸
デザイナーズ 賃貸
恵比寿 賃貸
学芸大学 賃貸
目黒 賃貸
中目黒 賃貸
新築 賃貸
ペット可 賃貸
三軒茶屋 賃貸
パチンコ求人
販売管理
債務整理
任意整理
液晶テレビ 激安
先物 比較
先物 比較

Anonymous said...

Kauassi,
We use java stored procedure extensivly in our application. We have two version of functionality one is in interactive mode (web app) and in batch mode. The same code is used in java stored procedure. What we have noticed that Java stored procedure run lot slower that weblogic execution. I am using native compiliation with the help of loadjava command, (loadjava -nativecompile -v -u prod/password@schema /u01/oracle/gmapps/gpsc/int/dbproc.jar)

which helped, still we need performance enhancement. When I am trying to use ncomp I am getting

/u01/oracle/product/11.01.00.06/bin/ncomp: -DJA_HOME=/u01/oracle/product/11.01.00.06/javavm/jahome: not found

But I can traverse to the directory.

Any idea ?

Kuassi Mensah said...

Hi,

I am glad to read that you use Java in the database.
NCOMP does not understand -D; i think you should set ORACLE_HOME and JA_HOME beforehand. As you know the JIT is much more transparent but requires 11g database.

Regarding performance, i assume you have installed the NCOMP libraries for the system classes.
If both the system classes and your application classes are NCOMPed, and you are doing database operations (SQL), Java in the database should be faster; unless your application is very compute-bound.

Kuassi.

janewangleilei said...

You can have a look at it.
jordan shoes
Wow.
newest jordans
jordan 7
Wonderful!
air yeezy
jordan true flight
If you like,you can contact us.
jordan 3
jordan 4
We offer different styles.
jordan 1
jordan 2
Thanks.
jordan 5
jordan ajf shoes
There are cheap shoes to choose
nike footwear
jordan flight 45
Good quality with low price.
air jordan 2010
Air Jordan 2009
Enjoy it!
jumpman
nike trainers

Anonymous said...

過払い返還について
過払い請求まとめ
液晶テレビの選び方
メンズファッション
結婚式:ウエディングドレス

過払い返還:弁護士:相談
結婚:プロフィールビデオ
結婚:キリスト教式
結婚:神前式
結婚:人前式
結婚について
楽しくペットと遊ぶ
ペットと遊べるおもちゃ
ペットと楽しむ
ペットのカメラ撮影
ペットと旅行
ゲーム
ペットグッズ
新宿御苑のランチ
過払い返還:債務整理
情報発信!お得でナウな情報のブログ

Chang bui thi said...

Its really good information, i like your blog post. Thanks for sharing
Signature:
i like play games friv online and play games2girls Download baixar facebook

facebook entrar said...

Mother pretended phone input jack see it muttering something at the side facebook entrar perfil , facebook entrar mi cuenta , facebook entrar login , girl.go.games , facebook entrar , facebook entrar , facebook entrar

thị hậu nguyễn said...

The article you have shared here very awesome. I really like and appreciate your work. I read deeply your article, the points you have mentioned in this article are useful. I must try to follow these points and also share others.
happy wheels
super mario bros
pacman
agario

Giải Trí Tổng Hợp said...

The blog or and best that is extremely useful to keep I can share the ideas. Age Of War 2
Big Farm | Slitherio | Tank Trouble
Of the future as this is really what I was looking for, I am very comfortable and pleased to come here. Thank you very much.
Happy Wheels | Goodgeme Empire | Slither.io