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

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

本文简介:选择自 coyichen 的 blog

uf); /* fprintf(stderr, "open the file %d\n",k_bm_fd); */ k_bm_buf = (char*)mmap((caddr_t) 0, k_bm_stat_buf.st_size, (prot_read), map_shared, k_bm_fd, 0); assert(k_bm_buf != map_failed); return k_bm_fd; } else { /* fprintf(stderr, "re-open the file %d\n",k_bm_fd); */ return k_bm_fd; } } return ((*fptr)(path, oflag, mode)); } int close(int fildes) { static int(*fptr)() = 0; if (fptr == 0) { fptr = (int (*)())dlsym(rtld_next, "close"); if (fptr == null) { fprintf(stderr, "dlopen: %s \n", dlerror()); return 0; } } if (fildes == k_bm_fd) { /* fprintf(stderr, "close the file %d\n",k_bm_fd); */ return 0; } return ((*fptr)(fildes)); } see readme file for details on how to compile this program, and the environment needed to execute the oracle client program. appendixes a3-a6 explain a little more about the test programs.

a3. test.c

this test program reads the oraus.msb file 50,000 times to mimic oracle client application behavior.

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
int fd = 0;
int fd1 = 0;
char buf[1024];
char buf1[1024];
int x1 = 0;
int x2 = 0;
int x3 = 0;
int x4 = 0;
int x5 = 0;
int main() {
 int i;
 int r=-1;
 for (i=0; i<50000; i++) {
  fd = open("/ora/app/oracle/product/8.1.7/rdbms/mesg/oraus.msb", o_rdonly);
/*  fd1 = open("/oracle/app/oracle/product/8.1.7/rdbms/mesg/oraus.msb_1", o_rdonly);
*/
/*  fprintf(stderr, "fd = %d fd1 = %d \n", fd, fd1);
*/
  r = fcntl(fd, f_setfd); 
  lseek(fd, 0, seek_set);
  read(fd, &buf, 256);
/*
  r = fcntl(fd1, f_setfd); 
  lseek(fd1, 0, seek_set);
  read(fd1, &buf1, 256);
  x1 = memcmp(&buf1, &buf, 256);
  if (x1 != 0 ) {
   fprintf(stderr, "x1 did not mach %d\n", x1);
  }
*/
  lseek(fd, 512, seek_set);
  read(fd, &buf, 512);
/*
  lseek(fd1, 512, seek_set);
  read(fd1, &buf1, 512);
  x2 = memcmp(&buf1, &buf, 512);
  if (x2 != 0 ) {
   fprintf(stderr, "x2 did not mach %d \n", x2);
  }
*/
  lseek(fd, 1024, seek_set);
  read(fd, &buf, 512);
/*
  lseek(fd1, 1024, seek_set);
  read(fd1, &buf1, 512);
  x3 = memcmp(&buf1, &buf, 512);
  if (x3 != 0 ) {
   fprintf(stderr, "x3 did not mach \n");
  }
*/
  lseek(fd, 39936, seek_set);
  read(fd, &buf, 512);
/*
  lseek(fd1, 39936, seek_set);
  read(fd1, &buf1, 512);
  x4 = memcmp(&buf1, &buf, 512);
  if (x4 != 0 ) {
   fprintf(stderr, "x4 did not mach \n");
  }
*/
  close(fd);         
/*
  close(fd1);
*/
 }
 
}

a4. test.sh

this is a wrapper to execute the test program to show the performance gains of caching the contents of oraus.msb in memory. the ld_preload and oraus_msb_file environment variables point to cache_oraus.so and the oraus.msb file.

#!/bin/bash
export oraus_msb_file=/ora/app/oracle/product/8.1.7/rdbms/mesg/oraus.msb
export ld_preload=/usr/lib/cache_oraus.so
export ld_preload=./cache_oraus.so
time ./test

a5. test1.sh

this is a wrapper to execute the test program without the caching mechanism.

#!/bin/bash
time ./test

a6. test_v.c

this program was used to verify that the interposed calls work properly.

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

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

go top