473,699 Members | 2,202 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 2043
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
3897
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
1332
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 they pick everyone and a couple of those users are logged off, the script delays for up to a...
3
2618
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 interval...
0
1074
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 are shown in a proper way but on some others there are lacks. I mean the very first data are...
4
1572
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
2268
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 change its selected property to true.
18
9815
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 delay before each item is moved. It looks like I have to flush the buffer to get setTimeout to work,...
3
1315
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
1434
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
8705
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8628
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9199
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8899
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7785
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4391
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3075
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.