如何加快ORACLE本地OCI的调用速度[4]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 coyichen 的 blog

table 4: read() call

int close(int fildes) {
 static int(*fptr)() = 0;
step c1
 if (fptr == 0) {
  fptr = (int (*)())dlsym(rtld_next, "close");
  if (fptr == null) {
   fprintf(stderr, "dlopen: %s \n", dlerror());
   return 0;
  }
 }
step c2
  if (fildes == k_bm_fd) {
  return 0;
  }
step c3
  return ((*fptr)(fildes));
}
steps description
c1 use dlysym() to get a pointer to the original libc.so close() call, so that we can chain to it.
c2 if the fildes is equal to k_bm_fd, then we justreturn 0 to signal a successful close, but without closing the file.
c3 for all other opens, the interpose gives control back to the originallibc.so close() call.

table 5: close() call

back to top

7. performance improvement

the performance improvement comes from not executing the system calls. the multiple instances of open(),fcntl(),lseek(), read(), and close() to read the oraus.msb messages are transformed to user-level calls. also, the i/o operation becomes a simple memory-to-memory transfer.

to measure the performance gains, a test program mimicking an oracle client's behavior was developed. the test program performs open(),lseek(), read(), and close() calls on the oraus.msb file 50,000 times.

the test program showed a gain of about 1000%. however, in a real oracle client application, this might translate to about a 2 percent-to-15 percent gain in performance.

7.1 without ld_preload and cache_oraus.so

type time in seconds
real 5.633
user 0.010
sys 0.014

table 6: ptime test.sh

back to top

7.2 with ld_preload and cache_oraus.so

type time in seconds
real 0.462
user 0.010
sys 0.013

本文关键:如何加快ORACLE本地OCI的调用速度
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top