473,563 Members | 2,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delays in between UDF invocations

Hi,

I have written a Java UDF for DB2 and registered it using the
following params:

CREATE FUNCTION arsu_bit_value ( varchar(32) for bit data, integer )
RETURNS INTEGER EXTERNAL NAME
'ch.ips.g2.db2. ch.ips.g2.db2.A RSU_BIT_VALUE!a rsu_bit_value'
LANGUAGE java PARAMETER STYLE db2general DETERMINISTIC NOT FENCED NOT
NULL CALL NO SQL NO EXTERNAL ACTION SCRATCHPAD
NO FINAL CALL ALLOW PARALLEL NO DBINFO

Basically the function returns the value (0 or 1) of the specified bit
in a bit array.

Example of usage:

-- returns all arsu rights that have the 254-th bit
-- set to 1 (LIST is varchar(32) for bit data)

select * from arsu_list where ARSU_BIT_VALUE( LIST, 254)=1

The functions itself works fine and is relatively fast (<1ms per
invocation), however, DB2 seems to "insert" approx. 160 ms delays in
between individual function invocations. Does anybody have any
reasonable explanation for this?

Thank you,
Jan Moravec
Nov 12 '05 #1
3 2037
As of v8, all java routines run outside the engine. The context
switching could account for the delay. If you're pre v8, then it'd be
JNI argument creation.

Jan Moravec wrote:
Hi,

I have written a Java UDF for DB2 and registered it using the
following params:

CREATE FUNCTION arsu_bit_value ( varchar(32) for bit data, integer )
RETURNS INTEGER EXTERNAL NAME
'ch.ips.g2.db2. ch.ips.g2.db2.A RSU_BIT_VALUE!a rsu_bit_value'
LANGUAGE java PARAMETER STYLE db2general DETERMINISTIC NOT FENCED NOT
NULL CALL NO SQL NO EXTERNAL ACTION SCRATCHPAD
NO FINAL CALL ALLOW PARALLEL NO DBINFO

Basically the function returns the value (0 or 1) of the specified bit
in a bit array.

Example of usage:

-- returns all arsu rights that have the 254-th bit
-- set to 1 (LIST is varchar(32) for bit data)

select * from arsu_list where ARSU_BIT_VALUE( LIST, 254)=1

The functions itself works fine and is relatively fast (<1ms per
invocation), however, DB2 seems to "insert" approx. 160 ms delays in
between individual function invocations. Does anybody have any
reasonable explanation for this?

Thank you,
Jan Moravec


Nov 12 '05 #2
Thanks for your answer. BTW we are running v7. What difference does it
make if the JVM runs inside or outside of the DB engine?

The JVM is always an external process from the DB engine's perspective
so you always end up with either JNI calls, or some sort of a socket
communication. Correct me if I am wrong, but I cannot see any other
way.

What is actually the diff between v7 and v8 in terms of invocation of
methods in the JVM process?

Thank you,
Jan Moravec
Sean McKeough <mc******@nospa m.ca.ibm.com> wrote in message news:<bp******* ***@hanover.tor olab.ibm.com>.. .
As of v8, all java routines run outside the engine. The context
switching could account for the delay. If you're pre v8, then it'd be
JNI argument creation.

Jan Moravec wrote:
Hi,

I have written a Java UDF for DB2 and registered it using the
following params:

CREATE FUNCTION arsu_bit_value ( varchar(32) for bit data, integer )
RETURNS INTEGER EXTERNAL NAME
'ch.ips.g2.db2. ch.ips.g2.db2.A RSU_BIT_VALUE!a rsu_bit_value'
LANGUAGE java PARAMETER STYLE db2general DETERMINISTIC NOT FENCED NOT
NULL CALL NO SQL NO EXTERNAL ACTION SCRATCHPAD
NO FINAL CALL ALLOW PARALLEL NO DBINFO

Basically the function returns the value (0 or 1) of the specified bit
in a bit array.

Example of usage:

-- returns all arsu rights that have the 254-th bit
-- set to 1 (LIST is varchar(32) for bit data)

select * from arsu_list where ARSU_BIT_VALUE( LIST, 254)=1

The functions itself works fine and is relatively fast (<1ms per
invocation), however, DB2 seems to "insert" approx. 160 ms delays in
between individual function invocations. Does anybody have any
reasonable explanation for this?

Thank you,
Jan Moravec

Nov 12 '05 #3
There is a big difference in whether the JVM runs in the engine or
not...it is not an external process, it is started either directly in
the agent, or in the db2dari process (JNI apis used to start up the JVM
threads). When it runs in the engine (in an agent), you avoid context
switches on the invocation of the UDF.

Unfortunately, in v8 we discovered that running the jvm in the engine
can cause fatal termination of the entire engine (JVM will call abort()
in some situations, blowing away the instance, which is not acceptable),
so we no longer allow for trusted Java routines.

Since you're v7, you have no sql etc in your UDF, so you're looking at
the overhead from JNI calls to populated the routines arguments, and
garbage collection...fo r really short duration routines you'd be better
off going with C. The cost of setting up to run a Java routines will
only be amortized if the actual runtime of the routine is more significant.

Jan Moravec wrote:
Thanks for your answer. BTW we are running v7. What difference does it
make if the JVM runs inside or outside of the DB engine?

The JVM is always an external process from the DB engine's perspective
so you always end up with either JNI calls, or some sort of a socket
communication. Correct me if I am wrong, but I cannot see any other
way.

What is actually the diff between v7 and v8 in terms of invocation of
methods in the JVM process?

Thank you,
Jan Moravec
Sean McKeough <mc******@nospa m.ca.ibm.com> wrote in message news:<bp******* ***@hanover.tor olab.ibm.com>.. .
As of v8, all java routines run outside the engine. The context
switching could account for the delay. If you're pre v8, then it'd be
JNI argument creation.

Jan Moravec wrote:

Hi,

I have written a Java UDF for DB2 and registered it using the
following params:

CREATE FUNCTION arsu_bit_value ( varchar(32) for bit data, integer )
RETURNS INTEGER EXTERNAL NAME
'ch.ips.g2.d b2.ch.ips.g2.db 2.ARSU_BIT_VALU E!arsu_bit_valu e'
LANGUAGE java PARAMETER STYLE db2general DETERMINISTIC NOT FENCED NOT
NULL CALL NO SQL NO EXTERNAL ACTION SCRATCHPAD
NO FINAL CALL ALLOW PARALLEL NO DBINFO

Basically the function returns the value (0 or 1) of the specified bit
in a bit array.

Example of usage:

-- returns all arsu rights that have the 254-th bit
-- set to 1 (LIST is varchar(32) for bit data)

select * from arsu_list where ARSU_BIT_VALUE( LIST, 254)=1

The functions itself works fine and is relatively fast (<1ms per
invocation ), however, DB2 seems to "insert" approx. 160 ms delays in
between individual function invocations. Does anybody have any
reasonable explanation for this?

Thank you,
Jan Moravec


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3875
by: Richard | last post by:
Hi, Can anyone tell me what the difference is between for line in file.readlines( ): and for line in file:
0
1327
by: roisin | last post by:
In a previous post I was advised (thanks for that Mark Schupp) to execute net send commands from a .bat file rather than an ASP page - so I have written a a script in my web page that will dynamically create a .bat according to the options a user chooses (basically picking from a list of users to whom they want to send a message). However, if...
3
2613
by: rajiv04 | last post by:
Hi all I want to have delays while calling the method(which basically displays the information).I am using MSVC++. How can I achieve that? Any clues pls...... I have an idea that in Java we can use sleep() for threads but what abt in c++? In other words I want a method to be called after a particular time interval ..may be few seconds...
0
1070
by: Krzysiek | last post by:
Hi, I have the application (VB6 using RDO) dealing with MSAccess database. This application use/prints reports build on CrystalReport. Report data are fetched from AS400 (via ODBC) and put in MSAccess *.mdb file. In order to build and then print report, application goes for data only to a local db. On some PCs all information on the report...
4
1565
by: Ranald Davidson via AccessMonster.com | last post by:
Pardon my ignorance but is there any easy way to pull information out of a table in Eastern Standard Timen that is currently stored using a different time zone. Any suggestions would be appreciated. Rd -- Message posted via http://www.accessmonster.com
2
2257
by: Rob Long | last post by:
Hi I have an HTML select element in my page and it's multiple property is disabled (one item at a time mode) but I still want to transfer all the items in the select to the server when the form is submitted. I'm using javascript to change the multiple property of the select element to true and then I'm looping through each option to...
18
9800
by: barry | last post by:
I'm having a problem creating a delay before each list item gets moved ( http://www.polisource.com/PublicMisc/list-splitter-timeout-bug.html ). Choose any number of columns, vertical layout, and view as a web page. They'll be a small delay before the entire bunch of list items converts from left-to-right to top-to-bottom order. I expected a...
3
1311
by: eager | last post by:
Hi dear friends What i want to ask about now is about delays in vb.net . i want to write a program which displays different images in to a picture box every 2 secs so if u can send me any function u r very welcome.
14
1417
by: Stodge | last post by:
I'm trying to do the following. I have a Python application that is run: python app1.py --location=c:\test1 What I want to do is save the location parameter, so I can then do (in the same window): python app2.py
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.