电脑知识|欧美黑人一区二区三区|软件|欧美黑人一级爽快片淫片高清|系统|欧美黑人狂野猛交老妇|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网

您的位置:首頁技術文章
文章詳情頁

如何加快ORACLE本地OCI的調用速度

瀏覽:7日期:2023-11-17 10:44:09
此文摘自 developers.sun.com 寫的很精采, 我自己試用了一下, 性能果然有所提高 developers.sun.com;;Technical Articles & Tips Cache OCI Calls to Improve Performance of 32-Bit or 64-Bit Oracle Clients By Nagendra Nagarajayya, October 2003;E-mail;;Printable Page;;Downloadend comment tag-->Contents:IntrodUCtion Identifying the Problem The Workaround: Cache oraus.msb in Memory Building cache_oraus.so How to Use cache_oraus.so How the Caching Works6.1;;Interposition of the open() Function Call6.2;;Interposition of the fcntl() Function Call6.3;;Interposition of the lseek(), read(), and close() Function Calls Performance Improvement7.1;;Without LD_PRELOAD and cache_oraus.so7.2;;With LD_PRELOAD and cache_oraus.soCaveat Conclusion Acknowledgments ReferencesA.;;Appendix: Test Programs and WrappersA1.;;READMEA2.;;cache_oraus.cA3.;;test.cA4.;;test.shA5.;;test1.shA6.;;test_v.cA7.;;test_v.shA8.;;c.shA9.;;c64.shA10.;;Cache_open_calls.c1. IntroductionIf you work with Oracle clients that make use of OCI (Oracle Call Interface), you may have noticed that the OCI driver in 8.1.7.x makes thousands of calls to translate messages from the oraus.msb file. This can degrade application performance by 5 percent or more (quite severely in some cases). This problem has been documented by Oracle under bug ID 2142623. The problem can be overcome by caching the oraus.msb file in memory, and translating the file Access and system calls to user calls and memory operations. The caching solution is dynamic, and code changes are not needed. The solution can improve the performance of the Oracle client application. Recently, this solution resulted in bringing down the application runtime from 15 minutes to a few seconds at a major customer – about 100x times performance improvement. The performance benefits can be seen in applications like sqlplus and Oracle clients (C and C++) making use of the OCI driver. Java technology-based applications using JDBC (native driver) should also see similar benefits. 2. Identifying the ProblemAn Oracle client application can be trussed on the Solaris Operating System (OS) to see the calls being made to this file -- 'truss' is a system utility available on the Solaris platform, and it can be used to trace system calls made by an application. A running Oracle client application can be trussed as follows: truss -p [oracle client pid]The truss command will show all the system calls being made by the application. The ones of interest are the open(), fcntl(), lseek(), read(), and close() calls. These calls are made by the OCI driver repeatedly to translate messages. Here is a truss snippet showing the problem calls: open('/oracle/app/oracle/product/8.1.7/rdbms/mesg/oraus.msb', O_RDONLY) = 9fcntl(9, F_SETFD, 0x00000001) = 0lseek(9, 0, SEEK_SET) = 0read(9, '1513 '011303tt'.., 256) = 256lseek(9, 512, SEEK_SET) = 512read(9, '1C88 Y r ~ M'.., 512) = 512lseek(9, 1024, SEEK_SET) = 1024read(9, '18 $ 7 @ J V'.., 512) = 512lseek(9, 39936, SEEK_SET) = 39936read(9, 't0519 >051A'.., 512) = 512close(9)= 0These system calls can be eXPensive. The number of times these system calls are executed depends on the client application and the duration of the application run. 3. The Workaround: Cache oraus.msb in MemoryThe workaround is to cache the contents of the oraus.msb in memory and not make these system calls. This can be done dynamically by using the LD_PRELOAD technique available on the Solaris OE. (For further information, see the References section.) LD_PRELOAD is an environment variable on Solaris that allows shared libraries to be preloaded before an application begins execution. To make use of this technique, we need to build a shared library that will interpose on the open(), fcntl(), lseek(), read(), and close() calls. 4. Building cache_oraus.soThe shared library can be built with the Forte C compiler (now part of the Sun ONE Compiler Collection) using the following switches: 32-bit: cc -G -o cache_oraus.so -fast cache_oraus.c -l dl64-bit: cc -G -o cache_oraus.so -fast -xarch=v9a cache_oraus.c -l dl5. How to Use cache_oraus.soThe following environment variables need to be set to use the caching mechanism: export LD_PRELOAD=./cache_oraus.soexport oraus_msb_file=/ora/app/oracle/product/8.1.7/rdbms/mesg/oraus.msbThis can be set in a shell script used to start the client application. 6. How the Caching WorksThe caching works by interposing the open(), fcntl(), lseek(), read(), and close() calls. The first time the application executes one of these calls, the control is first transferred to the interposed function code. 6.1 Interposition of the open() Function CallWhenever a file is opened, the control is transferred to the interposed open() from cache_oraus.so. The interposed open() checks to see if the file being opened is the oraus.msb (see STEP 3 in the following code example). If so, the file is opened, and memory mapped (STEP 5.1). The descriptor returned by open() is also cached. For all other opens, the control is transferred to the original libc.so (STEP 7). int open(const char *path, int oflag, mode_t mode) { static int(*fptr)() = 0; static char* msb_path;STEP 1 if (fptr == 0) { fptr = (int (*)())dlsym(RTLD_NEXT, 'open'); if (fptr == NULL) { fprintf(stderr, 'dlopen: %s n', dlerror()); return 0; }STEP 1.1 msb_path = (char*)getenv('oraus_msb_file'); }STEP 2 if (! msb_path) { msb_path = '/oracle/app/oracle/product/8.1.7/rdbms/mesg/oraus.msb'; }STEP 3 if (strcmp(path, msb_path) == 0) {STEP 4 if (k_bm_fd == -1) { k_bm_fd = ((*fptr)(path, oflag, mode)); if (k_bm_fd <= 0) { perror(path); exit(1); }STEP 5 fstat(k_bm_fd, &k_bm_stat_buf);STEP 5.1 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 {STEP 6 return k_bm_fd; } }STEP 7 return ((*fptr)(path, oflag, mode));}STEPSDescription1Use dlysym() to get a pointer to the original libc.so open() call, so that we can chain to it.1.1We use an environment variable, oraus_msb_file, to find the location of the oraus.msb file.2If this variable is not set, we use a default path.3We make sure the open call is related to the oraus_msb_file. For all other open calls, we chain to the original open() call.4We make sure this is the first time we are going through this code path as we want to map the file into memory only once. We open the file and cache the returned descriptor in k_bm_fd.5We get some information about the file itself, such as size.5.1The most important step: we map the file into memory.6We have already opened the file, and we return the cache descriptor.7For all other opens, the interpose gives control back to the original libc.so open() call. Table 1: open() Call 6.2 Interposition of the fcntl() Function CallA fcntl() call is made to change the file control parameters. The first time fcntl() is executed to change oraus.msb control parameters, the control is first transferred to the fcntl() in libc.so. The return value is cached, as well as returned back to the Oracle client (STEP 2). The next time fcntl() is executed, if the file descriptor matches the oraus.msb file descriptor, the cached return value is returned (STEP 3). The control is not transferred to fcntl() in libc.so. int fcntl(int fildes, int cmd, int arg) { static int ret; static int(*fptr)() = 0; char* path;STEP 1 if (fptr == 0) { fptr = (int (*)())dlsym(RTLD_NEXT, 'fcntl'); if (fptr == NULL) { fprintf(stderr, 'dlopen: %s n', dlerror()); return 0; } }STEP 2 if (k_fcntl_bm_fd == -1) { if (fildes == k_bm_fd) { ret = ((*fptr)(fildes, cmd, arg)); k_fcntl_bm_fd = k_bm_fd; return ret }STEP 3 } else if (k_fcntl_bm_fd == fildes) { return ret; } STEP 4 return ((*fptr)(fildes, cmd, arg));}STEPSDescription1Use dlysym() to get a pointer to the original libc.so fcntl() call, so that we can chain to it.2We make sure this is the first time we are going through this code path as we want to execute fcntl() only once. We also make a copy of the open descriptor in k_fcntl_bm_fd.3If the fildes is equal to k_fcntl_bm_fd, then we just return the cached return value.4For all other opens, the interpose gives control back to the original libc.so fcntl() call.Table 2: fcntl() Call Back to Top 6.3 Interposition of the lseek(), read(), and close() Function CallsFor the lseek() call, if the file descriptor matches the cached oraus.msb file descriptor, the file offset is stored instead of calling the lseek() in libc.so (STEP L2). On a read() call, if the file descriptor matches the cached oraus.msb file descriptor, the file offset stored from the lseek() is used to index into the memory mapped oraus.msb data. A memcpy() is then executed (STEP R2). So an I/O call is now transformed to a simple memcpy() call. A close() on the cached file descriptor is ignored so that the cached file descriptor can be reused. off_t lseek(int fildes, off_t offset, int whence) { static off_t (*fptr)() = 0;STEP L1 if (fptr == 0) {fptr = (int (*)())dlsym(RTLD_NEXT, 'lseek'); if (fptr == NULL) { fprintf(stderr, 'dlopen: %s n', dlerror()); return 0; } }STEP L2 if (fildes == k_bm_fd) { k_bm_offset = offset; return offset; }STEP L3 return ((*fptr)(fildes, offset, whence));}STEPSDescriptionL1Use dlysym() to get a pointer to the original libc.so lseek() call, so that we can chain to it. L2If the fildes is equal to k_bm_fd, then we keep track of the k_bm_offset so that we access this memory location. L3For all other opens, the interpose gives control back to the original libc.so lseek() call. Table 3: lseek() Call ssize_t read(int fildes, void *buf, size_t nbyte) { static ssize_t (*fptr)() = 0;STEP R1 if (fptr == 0) { fptr = (ssize_t (*)())dlsym(RTLD_NEXT, 'read'); if (fptr == NULL) { fprintf(stderr, 'dlopen: %sn', dlerror()); return (0); } }STEP R2 if (fildes == k_bm_fd) { memcpy(buf, k_bm_buf+k_bm_offset, nbyte); return nbyte; }STEP R3 return ((*fptr)(fildes, buf, nbyte));}STEPSDescriptionR1Use dlysym() to get a pointer to the original libc.so read() call, so that we can chain to it.R2If the fildes is equal to k_bm_fd, then we use the stored k_bm_offset to access the right memory location, and do a memcpy().R3For all other opens, the interpose gives control back to the original libc.so read() call.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));}STEPSDescriptionC1Use dlysym() to get a pointer to the original libc.so close() call, so that we can chain to it.C2If the fildes is equal to k_bm_fd, then we justreturn 0 to signal a successful close, but without closing the file.C3For all other opens, the interpose gives control back to the originallibc.so close() call.Table 5: close() Call Back to Top 7. Performance ImprovementThe 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.soTypeTime in SecondsReal5.633User0.010Sys0.014Table 6: ptime test.sh Back to Top 7.2 With LD_PRELOAD and cache_oraus.soTypeTime in SecondsReal0.462User0.010Sys0.013Table 7: ptime test.sh 8. CaveatThe preceding code is not multithreaded. For Oracle clients that are multithreaded, the write access to the cache variables needs to be mutex protected or synchronized. 9. ConclusionCaching the file oraus.msb in memory improves the performance of Oracle clients. Even though the performance gain observed in the test program is about 1000 percent, the gain when running a really big Oracle client application might not be more than 2 to 15 percent, due to other I/O contentions. This gain can be achieved without any code changes to the client application. 10. AcknowledgmentsI would like to thank Teresa Riege (Sun) and Thomas Yen (Kenan/BP billing platform, CSG Systems) for their contributions and help in testing this utility during the 2002 Kenan/BP study (see related article listed in References). I would also like to thank my colleagues at MDE (IPE) for supporting me during this project. I would like also to thank Ben Humphreys, technical support specialist, Sun, who made the 64-bit modifications to the code. 11. ReferencesNagendra Nagarajayya, S.R. Venkatramanan, 'Fast Sockets, An Interprocess Communication Library to Boost Application Performance' Sun Product Documentation site Oracle MetaLink (for news, problems, and bugs) CSG Kenan/BP Exceeds Billing Needs of Largest Telecom Service Providers in Scalability Test Appendix: Test Programs and WrappersThe Sample Code is being made available by Sun merely as a convenience to you. The Sample Code below is provided 'AS IS.' Sun makes no warranties of any kind whatsoever with respect to the Sample Code. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY WARRANTY OF NON-INFRINGEMENT OR IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE HEREBY DISCLAIMED AND EXCLUDED TO THE EXTENT ALLOWED BY APPLICABLE LAW. IN NO EVENT WILL SUN BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR PUNITIVE DAMAGES HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY ARISING OUT OF THE USE OF OR INABILITY TO USE THE SAMPLE CODE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. A1. README** Oct 02, 03* Nagendra Nagarajayya* MDE/IPE(CSI)* Sun Microsystems, Inc *set LD_PRELOAD within a wrapper to cache_oraus.so, and specifythe path to the oraus.msb file using the ENV variable, 'oraus_msb_file'.If the env is not specified, the following path is used,/oracle/app/oracle/product/8.1.7/rdbms/mesg/oraus.msb.WARNING: The solution presented does not support multi-threaded clients, but should be very easy to do so. BTW, it could work as it is with MT threaded clients, but has not been tested.Example:export LD_PRELOAD=./cache_oraus.soexport oraus_msb_file=/ora/app/oracle/product/8.1.7/rdbms/mesg/oraus.msbNote: cache_open_calls.c is similar to cache_oraus.c but caches only the open calls. It does not memory map the oraus.msb file.Compilation instructions:-------------------------Use the wrapper c.sh to compile cache_oraus.c. c.sh also compiles cache_open_calls.c, and the test programs. Use c64.sh to compile cache_oraus.c for 64 bit support.To test the library:--------------------Use, ptime test.sh, and ptime test1.sh.To verify if the library is reading the contents properly,use test_v.sh, and test_v.cA2. Cache_oraus.c/*Date: April 18, 2002Author: Nagendra NagarajayyaMDE/IPE/CSISun Microsystems, Inc.Date: October 02, 2003 Ben Humphreys Technical Support Specialist Sun Microsystems, Inc. Descr: made changes to source for 64 bit support Description: This caches oraus.msb file in memory and transforms I/O calls to the file to a read access.*//* The Sample Code is being made available by Sun merely as a convenience to you. The Sample Code below is provided 'AS IS.' Sun makes no warranties of any kind whatsoever with respect to the Sample Code. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY WARRANTY OF NON-INFRINGEMENT OR IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE HEREBY DISCLAIMED AND EXCLUDED TO THE EXTENT ALLOWED BY APPLICABLE LAW. IN NO EVENT WILL SUN BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR PUNITIVE DAMAGES HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY ARISING OUT OF THE USE OF OR INABILITY TO USE THE SAMPLE CODE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <dlfcn.h>#include <sys/types.h>#include <sys/stat.h>#include <assert.h>#include <sys/mman.h>#include <sys/int_types.h>static int k_fcntl_bm_fd = -1;static int k_bm_fd = -1;static int k_bm_offset = 0;static char* k_bm_buf ;static struct stat k_bm_stat_buf ;int fcntl(int fildes, int cmd, intptr_t arg) { static int ret; static ssize_t(*fptr)() = 0; char* path; if (fptr == 0) { fptr = (ssize_t (*)())dlsym(RTLD_NXT, 'fcntl'); if (fptr == NULL) { fprintf(stderr, 'dlopen: %s n', dlerror()); return 0; } } if (k_fcntl_bm_fd == -1) { if (fildes == k_bm_fd) { ret = ((*fptr)(fildes, cmd, arg)); k_fcntl_bm_fd = k_bm_fd; return ret } } else if (k_fcntl_bm_fd == fildes) { return ret; } return ((*fptr)(fildes, cmd, arg));}off_t lseek(int fildes, off_t offset, int whence) { static off_t(*fptr)() = 0; if (fptr == 0) {fptr = (off_t (*)())dlsym(RTLD_NEXT, 'lseek'); if (fptr == NULL) { fprintf(stderr, 'dlopen: %s n', dlerror()); return 0; } } if (fildes == k_bm_fd) { k_bm_offset = offset; return offset; }/* fprintf(stderr, 'offset=%d k_bm_offset=%dn', offset, k_bm_offset);*/ return ((*fptr)(fildes, offset, whence));}ssize_t read(int fildes, void *buf, size_t nbyte) { static ssize_t(*fptr)() = 0; if (fptr == 0) { fptr = (ssize_t (*)())dlsym(RTLD_NEXT, 'read'); if (fptr == NULL) { fprintf(stderr, 'dlopen: %sn', dlerror()); return (0); } }/* fprintf(stderr, 'fildes = %d k_bm_fd = %d n', fildes, k_bm_fd);*/ if (fildes == k_bm_fd) { memcpy(buf, k_bm_buf+k_bm_offset, nbyte); return nbyte; } return ((*fptr)(fildes, buf, nbyte));}int open(const char *path, int oflag, mode_t mode) { static char* msb_path;static int(*fptr)() = 0; if (fptr == 0) { fptr = (int (*)())dlsym(RTLD_NEXT, 'open'); if (fptr == NULL) { fprintf(stderr, 'dlopen: %s n', dlerror()); return 0; } msb_path = (char*)getenv('oraus_msb_file'); } if (! msb_path) { msb_path = '/oracle/app/oracle/product/8.1.7/rdbms/mesg/oraus.msb'; } if (strcmp(path, msb_path) == 0) { if (k_bm_fd == -1) { k_bm_fd = ((*fptr)(path, oflag, mode)); if (k_bm_fd <= 0) { perror(path); exit(1); } fstat(k_bm_fd, &k_bm_stat_buf);/* fprintf(stderr, 'open the file %dn',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 %dn',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 %dn',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.cThis 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 %dn', 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.shThis 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/bashexport oraus_msb_file=/ora/app/oracle/product/8.1.7/rdbms/mesg/oraus.msbexport LD_PRELOAD=/usr/lib/cache_oraus.soexport LD_PRELOAD=./cache_oraus.sotime ./testA5. test1.shThis is a wrapper to execute the test program without the caching mechanism. #!/bin/bashtime ./testA6. test_v.cThis program was used to verify that the interposed calls work properly. #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('/ora/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 %dn', 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); } }A7. test_v.shThis is a wrapper for testing test_v.c. #!/bin/bashexport LD_PRELOAD=/usr/lib/cache_oraus.soexport LD_PRELOAD=./cache_oraus.sotime ./test_vA8. c.sh#!/bin/bashPATH=/opt/SUNWspro/bin/:$PATHexport PATH;cc -fast -xarch=v8plusa -xdepend -xvector -xstrconst -xprefetch -G -o cache_open_calls.so cache_open_calls.c -ldlcc -fast -xdepend -xvector -xstrconst -xarch=v8plusa -xprefetch -G -o cache_oraus.so cache_oraus.c -ldlcc -fast -xstrconst -xvector -xdepend -xarch=v8plusa -xprefetch -o test test.c -ldlcc -fast -xstrconst -xvector -xdepend -xarch=v8plusa -xprefetch -o test_v test_v.c -ldl A9. c64.sh#!/bin/bash# Changes to source cache_oraus.c for 64 bit support was made # by Ben Humphreys PATH=/opt/SUNWspro/bin/:$PATHexport PATH;cc -fast -xarch=v9a -xcode=abs64 -xdepend -xvector -xstrconst -xprefetch -G -o cache_open_calls.so cache_open_calls.c -ldlcc -fast -xarch=v9a -xcode=abs64 -xdepend -xvector -xstrconst -xprefetch -G -o cache_oraus.so cache_oraus.c -ldlcc -fast -xarch=v9a -xcode=abs64 -xstrconst -xvector -xdepend -xprefetch -o test test.c -ldlcc -fast -xarch=v9a -xcode=abs64 -xstrconst -xvector -xdepend -xprefetch -o test_v test_v.c -ldl < name=A10> A10. Cache_open_calls.c/* Date: April 18, 02 Author: Nagendra Nagarajayya Description: Caches open, and close calls to oraus.msb file */#include <stdio.h>#include <unistd.h>#include <dlfcn.h>#include <string.h>#include <stdlib.h>static int k_bm_fd = -1;int open(const char *path, int oflag, mode_t mode) { static int (*fptr)() = 0; if (fptr == 0) {fptr = (int (*)())dlsym(RTLD_NEXT, 'open'); if (fptr == NULL) { fprintf(stderr, 'dlopen: %s n', dlerror()); return 0; } } if (strcmp(path, '/oracle/app/oracle/product/8.1.7/rdbms/mesg/oraus.msb') == 0) { if (k_bm_fd == -1) { k_bm_fd = ((*fptr)(path, oflag, mode)); if (k_bm_fd <= 0) { perror(path); exit(1); } /* fstat(k_bm_fd, &k_bm_stat_buf); fprintf(stderr, 'open the file %dn',k_bm_fd);*/ return k_bm_fd; } else { /* fprintf(stderr, 're-open the file %dn',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 %dn',k_bm_fd);*/ return 0; } return ((*fptr)(fildes));}About the AuthorNagendra Nagarajayya has been at Sun for more than 9 years. A Staff Engineer in Market Development Engineering (MDE/IPE), he works with telco ISVs on architecture, performance tuning, sizing and scaling, benchmarking, porting, and so on. His interests include multithreading, concurrency and parallelism, HA, distributed computing, networking, and the Java and Solaris platforms.
標簽: Oracle 數據庫
主站蜘蛛池模板: 济宁工业提升门|济宁电动防火门|济宁快速堆积门-济宁市统一电动门有限公司 | 魔方网-培训咨询服务平台| 打孔器,打孔钳厂家【温州新星德牌五金工具】 | 棕刚玉_白刚玉_铝酸钙-锐石新材料 | 合肥钣金加工-安徽激光切割加工-机箱机柜加工厂家-合肥通快 | hc22_hc22价格_hc22哈氏合金—东锜特殊钢 | 合肥展厅设计-安徽展台设计-合肥展览公司-安徽奥美展览工程有限公司 | 中空玻璃生产线,玻璃加工设备,全自动封胶线,铝条折弯机,双组份打胶机,丁基胶/卧式/立式全自动涂布机,玻璃设备-山东昌盛数控设备有限公司 | ORP控制器_ORP电极价格-上优泰百科 | 便携式谷丙转氨酶检测仪|华图生物科技百科 | 打孔器,打孔钳厂家【温州新星德牌五金工具】 | 清管器,管道清管器,聚氨酯发泡球,清管球 - 承德嘉拓设备 | 食品无尘净化车间,食品罐装净化车间,净化车间配套风淋室-青岛旭恒洁净技术有限公司 | 太原装修公司_山西整装家装设计_太原室内装潢软装_肖邦家居 | 安平县鑫川金属丝网制品有限公司,声屏障,高速声屏障,百叶孔声屏障,大弧形声屏障,凹凸穿孔声屏障,铁路声屏障,顶部弧形声屏障,玻璃钢吸音板 | 精密线材测试仪-电线电缆检测仪-苏州欣硕电子科技有限公司 | 济南网站建设|济南建网站|济南网站建设公司【济南腾飞网络】【荐】 | 暴风影音| 宝宝药浴-产后药浴-药浴加盟-艾裕-专注母婴调养泡浴 | 超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司 | 1000帧高速摄像机|工业高速相机厂家|科天健光电技术 | 工业插头-工业插头插座【厂家】-温州罗曼电气 | 钢丝绳探伤仪-钢丝绳检测仪-钢丝绳探伤设备-洛阳泰斯特探伤技术有限公司 | cnc精密加工_数控机械加工_非标平键定制生产厂家_扬州沃佳机械有限公司 | 蒸汽热收缩机_蒸汽发生器_塑封机_包膜机_封切收缩机_热收缩包装机_真空机_全自动打包机_捆扎机_封箱机-东莞市中堡智能科技有限公司 | 温湿度记录纸_圆盘_横河记录纸|霍尼韦尔记录仪-广州汤米斯机电设备有限公司 | 西安微信朋友圈广告投放_微信朋友圈推广_西安度娘网络科技有限公司 | 桥架-槽式电缆桥架-镀锌桥架-托盘式桥架 - 上海亮族电缆桥架制造有限公司 | 水性漆|墙面漆|木器家具漆|水漆涂料_晨阳水漆官网 | 细沙回收机-尾矿干排脱水筛设备-泥石分离机-建筑垃圾分拣机厂家-青州冠诚重工机械有限公司 | 环氧铁红防锈漆_环氧漆_无溶剂环氧涂料_环氧防腐漆-华川涂料 | 煤矿支护网片_矿用勾花菱形网_缝管式_管缝式锚杆-邯郸市永年区志涛工矿配件有限公司 | 气动|电动调节阀|球阀|蝶阀-自力式调节阀-上海渠工阀门管道工程有限公司 | 对辊式破碎机-对辊制砂机-双辊-双齿辊破碎机-巩义市裕顺机械制造有限公司 | 微妙网,专业的动画师、特效师、CG模型设计师网站! - wmiao.com 超声波电磁流量计-液位计-孔板流量计-料位计-江苏信仪自动化仪表有限公司 | 济南玻璃安装_济南玻璃门_济南感应门_济南玻璃隔断_济南玻璃门维修_济南镜片安装_济南肯德基门_济南高隔间-济南凯轩鹏宇玻璃有限公司 | 高空重型升降平台_高空液压举升平台_高空作业平台_移动式升降机-河南华鹰机械设备有限公司 | 金蝶帐无忧|云代账软件|智能财税软件|会计代账公司专用软件 | 【中联邦】增稠剂_增稠粉_水性增稠剂_涂料增稠剂_工业增稠剂生产厂家 | 紧急切断阀_气动切断阀_不锈钢阀门_截止阀_球阀_蝶阀_闸阀-上海上兆阀门制造有限公司 | 探伤仪,漆膜厚度测试仪,轮胎花纹深度尺厂家-淄博创宇电子 |