仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 613|回复: 8
打印 上一主题 下一主题

[学习教程] MYSQL网页设计怎样加速ORACLE当地OCI的挪用速率

[复制链接]
再见西城 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:40:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
曾经的功能列表可能会迅速变得过时了。而且,有些功能对有的应用程序非常重要,但是对别的应用程序则不一定。oracle|速率
此文摘自developers.sun.com写的很杰出,我本人试用了一下,功能公然有所进步developers.sun.com

TechnicalArticles&TipsCacheOCICallstoImprovePerformanceof32-Bitor64-BitOracleClients
ByNagendraNagarajayya,October2003E-mailPrintablePageDownloadendcommenttag-->Contents:IntroductionIdentifyingtheProblemTheWorkaround:Cacheoraus.msbinMemoryBuildingcache_oraus.soHowtoUsecache_oraus.soHowtheCachingWorks
6.1Interpositionoftheopen()FunctionCall
6.2Interpositionofthefcntl()FunctionCall
6.3Interpositionofthelseek(),read(),andclose()FunctionCallsPerformanceImprovement
7.1WithoutLD_PRELOADandcache_oraus.so
7.2WithLD_PRELOADandcache_oraus.so
CaveatConclusionAcknowledgmentsReferences
A.Appendix:TestProgramsandWrappers
A1.README
A2.cache_oraus.c
A3.test.c
A4.test.sh
A5.test1.sh
A6.test_v.c
A7.test_v.sh
A8.c.sh
A9.c64.sh
A10.Cache_open_calls.c
1.Introduction
IfyouworkwithOracleclientsthatmakeuseofOCI(OracleCallInterface),youmayhavenoticedthattheOCIdriverin8.1.7.xmakesthousandsofcallstotranslatemessagesfromtheoraus.msbfile.Thiscandegradeapplicationperformanceby5percentormore(quiteseverelyinsomecases).ThisproblemhasbeendocumentedbyOracleunderbugID2142623.

Theproblemcanbeovercomebycachingtheoraus.msbfileinmemory,andtranslatingthefileaccessandsystemcallstousercallsandmemoryoperations.Thecachingsolutionisdynamic,andcodechangesarenotneeded.ThesolutioncanimprovetheperformanceoftheOracleclientapplication.Recently,thissolutionresultedinbringingdowntheapplicationruntimefrom15minutestoafewsecondsatamajorcustomer–about100xtimesperformanceimprovement.

TheperformancebenefitscanbeseeninapplicationslikesqlplusandOracleclients(CandC++)makinguseoftheOCIdriver.Javatechnology-basedapplicationsusingJDBC(nativedriver)shouldalsoseesimilarbenefits.
2.IdentifyingtheProblem
AnOracleclientapplicationcanbetrussedontheSolarisOperatingSystem(OS)toseethecallsbeingmadetothisfile--"truss"isasystemutilityavailableontheSolarisplatform,anditcanbeusedtotracesystemcallsmadebyanapplication.ArunningOracleclientapplicationcanbetrussedasfollows:

truss-p[oracleclientpid]

Thetrusscommandwillshowallthesystemcallsbeingmadebytheapplication.Theonesofinterestaretheopen(),fcntl(),lseek(),read(),andclose()calls.ThesecallsaremadebytheOCIdriverrepeatedlytotranslatemessages.Hereisatrusssnippetshowingtheproblemcalls:

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"011303                "..,256)=256lseek(9,512,SEEK_SET)=512read(9,"1C88Yr~M"..,512)=512lseek(9,1024,SEEK_SET)=1024read(9,"18$7@JV"..,512)=512lseek(9,39936,SEEK_SET)=39936read(9,"        0519>051A"..,512)=512close(9)=0

Thesesystemcallscanbeexpensive.Thenumberoftimesthesesystemcallsareexecuteddependsontheclientapplicationandthedurationoftheapplicationrun.
3.TheWorkaround:Cacheoraus.msbinMemory
Theworkaroundistocachethecontentsoftheoraus.msbinmemoryandnotmakethesesystemcalls.ThiscanbedonedynamicallybyusingtheLD_PRELOADtechniqueavailableontheSolarisOE.(Forfurtherinformation,seetheReferencessection.)LD_PRELOADisanenvironmentvariableonSolaristhatallowssharedlibrariestobepreloadedbeforeanapplicationbeginsexecution.Tomakeuseofthistechnique,weneedtobuildasharedlibrarythatwillinterposeontheopen(),fcntl(),lseek(),read(),andclose()calls.
4.Buildingcache_oraus.so
ThesharedlibrarycanbebuiltwiththeForteCcompiler(nowpartoftheSunONECompilerCollection)usingthefollowingswitches:

32-bit:

cc-G-ocache_oraus.so-fastcache_oraus.c-ldl

64-bit:

cc-G-ocache_oraus.so-fast-xarch=v9acache_oraus.c-ldl
5.HowtoUsecache_oraus.so
Thefollowingenvironmentvariablesneedtobesettousethecachingmechanism:

exportLD_PRELOAD=./cache_oraus.soexportoraus_msb_file=/ora/app/oracle/product/8.1.7/rdbms/mesg/oraus.msb

Thiscanbesetinashellscriptusedtostarttheclientapplication.
6.HowtheCachingWorks
Thecachingworksbyinterposingtheopen(),fcntl(),lseek(),read(),andclose()calls.Thefirsttimetheapplicationexecutesoneofthesecalls,thecontrolisfirsttransferredtotheinterposedfunctioncode.
6.1Interpositionoftheopen()FunctionCall
Wheneverafileisopened,thecontrolistransferredtotheinterposedopen()fromcache_oraus.so.Theinterposedopen()checkstoseeifthefilebeingopenedistheoraus.msb(seeSTEP3inthefollowingcodeexample).Ifso,thefileisopened,andmemorymapped(STEP5.1).Thedescriptorreturnedbyopen()isalsocached.Forallotheropens,thecontrolistransferredtotheoriginallibc.so(STEP7).

intopen(constchar*path,intoflag,mode_tmode){staticint(*fptr)()=0;staticchar*msb_path;STEP1if(fptr==0){fptr=(int(*)())dlsym(RTLD_NEXT,"open");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return0;}STEP1.1msb_path=(char*)getenv("oraus_msb_file");}STEP2if(!msb_path){msb_path="/oracle/app/oracle/product/8.1.7/rdbms/mesg/oraus.msb";}STEP3if(strcmp(path,msb_path)==0){STEP4if(k_bm_fd==-1){k_bm_fd=((*fptr)(path,oflag,mode));if(k_bm_fd<=0){perror(path);exit(1);}STEP5fstat(k_bm_fd,&k_bm_stat_buf);STEP5.1k_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);returnk_bm_fd;}else{STEP6returnk_bm_fd;}}STEP7return((*fptr)(path,oflag,mode));}
STEPSDescription1Usedlysym()togetapointertotheoriginallibc.soopen()call,sothatwecanchaintoit.1.1Weuseanenvironmentvariable,oraus_msb_file,tofindthelocationoftheoraus.msbfile.2Ifthisvariableisnotset,weuseadefaultpath.3Wemakesuretheopencallisrelatedtotheoraus_msb_file.Forallotheropencalls,wechaintotheoriginalopen()call.4Wemakesurethisisthefirsttimewearegoingthroughthiscodepathaswewanttomapthefileintomemoryonlyonce.Weopenthefileandcachethereturneddescriptorink_bm_fd.5Wegetsomeinformationaboutthefileitself,suchassize.5.1Themostimportantstep:wemapthefileintomemory.6Wehavealreadyopenedthefile,andwereturnthecachedescriptor.7Forallotheropens,theinterposegivescontrolbacktotheoriginallibc.soopen()call.
Table1:open()Call
6.2Interpositionofthefcntl()FunctionCall
Afcntl()callismadetochangethefilecontrolparameters.Thefirsttimefcntl()isexecutedtochangeoraus.msbcontrolparameters,thecontrolisfirsttransferredtothefcntl()inlibc.so.Thereturnvalueiscached,aswellasreturnedbacktotheOracleclient(STEP2).Thenexttimefcntl()isexecuted,ifthefiledescriptormatchestheoraus.msbfiledescriptor,thecachedreturnvalueisreturned(STEP3).Thecontrolisnottransferredtofcntl()inlibc.so.

intfcntl(intfildes,intcmd,intarg){staticintret;staticint(*fptr)()=0;char*path;STEP1if(fptr==0){fptr=(int(*)())dlsym(RTLD_NEXT,"fcntl");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return0;}}STEP2if(k_fcntl_bm_fd==-1){if(fildes==k_bm_fd){ret=((*fptr)(fildes,cmd,arg));k_fcntl_bm_fd=k_bm_fd;returnret;;}STEP3}elseif(k_fcntl_bm_fd==fildes){returnret;}STEP4return((*fptr)(fildes,cmd,arg));}
STEPSDescription1Usedlysym()togetapointertotheoriginallibc.sofcntl()call,sothatwecanchaintoit.2Wemakesurethisisthefirsttimewearegoingthroughthiscodepathaswewanttoexecutefcntl()onlyonce.Wealsomakeacopyoftheopendescriptorink_fcntl_bm_fd.3Ifthefildesisequaltok_fcntl_bm_fd,thenwejustreturnthecachedreturnvalue.4Forallotheropens,theinterposegivescontrolbacktotheoriginallibc.sofcntl()call.
Table2:fcntl()Call

BacktoTop
6.3Interpositionofthelseek(),read(),andclose()FunctionCalls
Forthelseek()call,ifthefiledescriptormatchesthecachedoraus.msbfiledescriptor,thefileoffsetisstoredinsteadofcallingthelseek()inlibc.so(STEPL2).Onaread()call,ifthefiledescriptormatchesthecachedoraus.msbfiledescriptor,thefileoffsetstoredfromthelseek()isusedtoindexintothememorymappedoraus.msbdata.Amemcpy()isthenexecuted(STEPR2).SoanI/Ocallisnowtransformedtoasimplememcpy()call.Aclose()onthecachedfiledescriptorisignoredsothatthecachedfiledescriptorcanbereused.

off_tlseek(intfildes,off_toffset,intwhence){staticoff_t(*fptr)()=0;
STEPL1
if(fptr==0){fptr=(int(*)())dlsym(RTLD_NEXT,"lseek");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return0;}}
STEPL2
if(fildes==k_bm_fd){k_bm_offset=offset;returnoffset;}
STEPL3
return((*fptr)(fildes,offset,whence));}
STEPSDescriptionL1Usedlysym()togetapointertotheoriginallibc.solseek()call,sothatwecanchaintoit.L2Ifthefildesisequaltok_bm_fd,thenwekeeptrackofthek_bm_offsetsothatweaccessthismemorylocation.L3Forallotheropens,theinterposegivescontrolbacktotheoriginallibc.solseek()call.
Table3:lseek()Call

ssize_tread(intfildes,void*buf,size_tnbyte){statiCSSize_t(*fptr)()=0;
STEPR1
if(fptr==0){fptr=(ssize_t(*)())dlsym(RTLD_NEXT,"read");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return(0);}}
STEPR2
if(fildes==k_bm_fd){memcpy(buf,k_bm_buf+k_bm_offset,nbyte);returnnbyte;}
STEPR3
return((*fptr)(fildes,buf,nbyte));}
STEPSDescriptionR1Usedlysym()togetapointertotheoriginallibc.soread()call,sothatwecanchaintoit.R2Ifthefildesisequaltok_bm_fd,thenweusethestoredk_bm_offsettoaccesstherightmemorylocation,anddoamemcpy().R3Forallotheropens,theinterposegivescontrolbacktotheoriginallibc.soread()call.
Table4:read()Call

intclose(intfildes){staticint(*fptr)()=0;
STEPC1
if(fptr==0){fptr=(int(*)())dlsym(RTLD_NEXT,"close");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return0;}}
STEPC2
if(fildes==k_bm_fd){return0;}
STEPC3
return((*fptr)(fildes));}
STEPSDescriptionC1Usedlysym()togetapointertotheoriginallibc.soclose()call,sothatwecanchaintoit.C2Ifthefildesisequaltok_bm_fd,thenwejustreturn0tosignalasuccessfulclose,butwithoutclosingthefile.C3Forallotheropens,theinterposegivescontrolbacktotheoriginallibc.soclose()call.
Table5:close()Call

BacktoTop
7.PerformanceImprovement
Theperformanceimprovementcomesfromnotexecutingthesystemcalls.Themultipleinstancesofopen(),fcntl(),lseek(),read(),andclose()toreadtheoraus.msbmessagesaretransformedtouser-levelcalls.Also,theI/Ooperationbecomesasimplememory-to-memorytransfer.

Tomeasuretheperformancegains,atestprogrammimickinganOracleclientsbehaviorwasdeveloped.Thetestprogramperformsopen(),lseek(),read(),andclose()callsontheoraus.msbfile50,000times.

Thetestprogramshowedagainofabout1000%.However,inarealOracleclientapplication,thismighttranslatetoabouta2percent-to-15percentgaininperformance.
7.1WithoutLD_PRELOADandcache_oraus.soTypeTimeinSecondsReal5.633User0.010Sys0.014
Table6:ptimetest.sh

BacktoTop
7.2WithLD_PRELOADandcache_oraus.soTypeTimeinSecondsReal0.462User0.010Sys0.013
Table7:ptimetest.sh
8.Caveat
Theprecedingcodeisnotmultithreaded.ForOracleclientsthataremultithreaded,thewriteaccesstothecachevariablesneedstobemutexprotectedorsynchronized.
9.Conclusion
Cachingthefileoraus.msbinmemoryimprovestheperformanceofOracleclients.Eventhoughtheperformancegainobservedinthetestprogramisabout1000percent,thegainwhenrunningareallybigOracleclientapplicationmightnotbemorethan2to15percent,duetootherI/Ocontentions.Thisgaincanbeachievedwithoutanycodechangestotheclientapplication.
10.Acknowledgments
IwouldliketothankTeresaRiege(Sun)andThomasYen(Kenan/BPbillingplatform,CSGSystems)fortheircontributionsandhelpintestingthisutilityduringthe2002Kenan/BPstudy(seerelatedarticlelistedinReferences).IwouldalsoliketothankmycolleaguesatMDE(IPE)forsupportingmeduringthisproject.

IwouldlikealsotothankBenHumphreys,technicalsupportspecialist,Sun,whomadethe64-bitmodificationstothecode.
11.ReferencesNagendraNagarajayya,S.R.Venkatramanan,"FastSockets,AnInterprocessCommunicationLibrarytoBoostApplicationPerformance"SunProductDocumentationsiteOracleMetaLink(fornews,problems,andbugs)CSGKenan/BPExceedsBillingNeedsofLargestTelecomServiceProvidersinScalabilityTestAppendix:TestProgramsandWrappers
TheSampleCodeisbeingmadeavailablebySunmerelyasaconveniencetoyou.TheSampleCodebelowisprovided"ASIS."SunmakesnowarrantiesofanykindwhatsoeverwithrespecttotheSampleCode.

ALLEXPRESSORIMPLIEDCONDITIONS,REPRESENTATIONSANDWARRANTIES,INCLUDINGANYWARRANTYOFNON-INFRINGEMENTORIMPLIEDWARRANTYOFMERCHANTABILITYORFITNESSFORAPARTICULARPURPOSE,AREHEREBYDISCLAIMEDANDEXCLUDEDTOTHEEXTENTALLOWEDBYAPPLICABLELAW.INNOEVENTWILLSUNBELIABLEFORANYLOSTREVENUE,PROFITORDATA,ORFORDIRECT,SPECIAL,INDIRECT,CONSEQUENTIAL,INCIDENTAL,ORPUNITIVEDAMAGESHOWEVERCAUSEDANDREGARDLESSOFTHETHEORYOFLIABILITYARISINGOUTOFTHEUSEOFORINABILITYTOUSETHESAMPLECODE,EVENIFSUNHASBEENADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGES.
A1.README
**Oct02,03*NagendraNagarajayya*MDE/IPE(CSI)*SunMicrosystems,Inc*setLD_PRELOADwithinawrappertocache_oraus.so,andspecifythepathtotheoraus.msbfileusingtheENVvariable,"oraus_msb_file".Iftheenvisnotspecified,thefollowingpathisused,/oracle/app/oracle/product/8.1.7/rdbms/mesg/oraus.msb.WARNING:Thesolutionpresenteddoesnotsupportmulti-threadedclients,butshouldbeveryeasytodoso.BTW,itcouldworkasitiswithMTthreadedclients,buthasnotbeentested.Example:exportLD_PRELOAD=./cache_oraus.soexportoraus_msb_file=/ora/app/oracle/product/8.1.7/rdbms/mesg/oraus.msbNote:cache_open_calls.cissimilartocache_oraus.cbutcachesonlytheopencalls.Itdoesnotmemorymaptheoraus.msbfile.Compilationinstructions:-------------------------Usethewrapperc.shtocompilecache_oraus.c.c.shalsocompilescache_open_calls.c,andthetestprograms.Usec64.shtocompilecache_oraus.cfor64bitsupport.Totestthelibrary:--------------------Use,ptimetest.sh,andptimetest1.sh.Toverifyifthelibraryisreadingthecontentsproperly,usetest_v.sh,andtest_v.c
A2.Cache_oraus.c
/*Date:April18,2002Author:NagendraNagarajayyaMDE/IPE/CSISunMicrosystems,Inc.Date:October02,2003BenHumphreysTechnicalSupportSpecialistSunMicrosystems,Inc.Descr:madechangestosourcefor64bitsupportDescription:Thiscachesoraus.msbfileinmemoryandtransformsI/Ocallstothefiletoareadaccess.*//*TheSampleCodeisbeingmadeavailablebySunmerelyasaconveniencetoyou.TheSampleCodebelowisprovided"ASIS."SunmakesnowarrantiesofanykindwhatsoeverwithrespecttotheSampleCode.ALLEXPRESSORIMPLIEDCONDITIONS,REPRESENTATIONSANDWARRANTIES,INCLUDINGANYWARRANTYOFNON-INFRINGEMENTORIMPLIEDWARRANTYOFMERCHANTABILITYORFITNESSFORAPARTICULARPURPOSE,AREHEREBYDISCLAIMEDANDEXCLUDEDTOTHEEXTENTALLOWEDBYAPPLICABLELAW.INNOEVENTWILLSUNBELIABLEFORANYLOSTREVENUE,PROFITORDATA,ORFORDIRECT,SPECIAL,INDIRECT,CONSEQUENTIAL,INCIDENTAL,ORPUNITIVEDAMAGESHOWEVERCAUSEDANDREGARDLESSOFTHETHEORYOFLIABILITYARISINGOUTOFTHEUSEOFORINABILITYTOUSETHESAMPLECODE,EVENIFSUNHASBEENADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGES.*/#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>staticintk_fcntl_bm_fd=-1;staticintk_bm_fd=-1;staticintk_bm_offset=0;staticchar*k_bm_buf;staticstructstatk_bm_stat_buf;intfcntl(intfildes,intcmd,intptr_targ){staticintret;staticssize_t(*fptr)()=0;char*path;if(fptr==0){fptr=(ssize_t(*)())dlsym(RTLD_NXT,"fcntl");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return0;}}if(k_fcntl_bm_fd==-1){if(fildes==k_bm_fd){ret=((*fptr)(fildes,cmd,arg));k_fcntl_bm_fd=k_bm_fd;returnret;;}}elseif(k_fcntl_bm_fd==fildes){returnret;}return((*fptr)(fildes,cmd,arg));}off_tlseek(intfildes,off_toffset,intwhence){staticoff_t(*fptr)()=0;if(fptr==0){fptr=(off_t(*)())dlsym(RTLD_NEXT,"lseek");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return0;}}if(fildes==k_bm_fd){k_bm_offset=offset;returnoffset;}/*fprintf(stderr,"offset=%dk_bm_offset=%d
",offset,k_bm_offset);*/return((*fptr)(fildes,offset,whence));}ssize_tread(intfildes,void*buf,size_tnbyte){staticssize_t(*fptr)()=0;if(fptr==0){fptr=(ssize_t(*)())dlsym(RTLD_NEXT,"read");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return(0);}}/*fprintf(stderr,"fildes=%dk_bm_fd=%d
",fildes,k_bm_fd);*/if(fildes==k_bm_fd){memcpy(buf,k_bm_buf+k_bm_offset,nbyte);returnnbyte;}return((*fptr)(fildes,buf,nbyte));}intopen(constchar*path,intoflag,mode_tmode){staticchar*msb_path;staticint(*fptr)()=0;if(fptr==0){fptr=(int(*)())dlsym(RTLD_NEXT,"open");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return0;}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,"openthefile%d
",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);returnk_bm_fd;}else{/*fprintf(stderr,"re-openthefile%d
",k_bm_fd);*/returnk_bm_fd;}}return((*fptr)(path,oflag,mode));}intclose(intfildes){staticint(*fptr)()=0;if(fptr==0){fptr=(int(*)())dlsym(RTLD_NEXT,"close");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return0;}}if(fildes==k_bm_fd){/*fprintf(stderr,"closethefile%d
",k_bm_fd);*/return0;}return((*fptr)(fildes));}SeeREADMEfilefordetailsonhowtocompilethisprogram,andtheenvironmentneededtoexecutetheOracleclientprogram.AppendixesA3-A6explainalittlemoreaboutthetestprograms.
A3.test.c
Thistestprogramreadstheoraus.msbfile50,000timestomimicOracleclientapplicationbehavior.

#include<stdio.h>#include<unistd.h>#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>#include<string.h>intfd=0;intfd1=0;charbuf[1024];charbuf1[1024];intx1=0;intx2=0;intx3=0;intx4=0;intx5=0;intmain(){inti;intr=-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=%dfd1=%d
",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,"x1didnotmach%d
",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,"x2didnotmach%d
",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,"x3didnotmach
");}*/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,"x4didnotmach
");}*/close(fd);/*close(fd1);*/}}
A4.test.sh
Thisisawrappertoexecutethetestprogramtoshowtheperformancegainsofcachingthecontentsoforaus.msbinmemory.TheLD_PRELOADandoraus_msb_fileenvironmentvariablespointtocache_oraus.soandtheoraus.msbfile.

#!/bin/bashexportoraus_msb_file=/ora/app/oracle/product/8.1.7/rdbms/mesg/oraus.msbexportLD_PRELOAD=/usr/lib/cache_oraus.soexportLD_PRELOAD=./cache_oraus.sotime./test
A5.test1.sh
Thisisawrappertoexecutethetestprogramwithoutthecachingmechanism.

#!/bin/bashtime./test
A6.test_v.c
Thisprogramwasusedtoverifythattheinterposedcallsworkproperly.

#include<stdio.h>#include<unistd.h>#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>#include<string.h>intfd=0;intfd1=0;charbuf[1024];charbuf1[1024];intx1=0;intx2=0;intx3=0;intx4=0;intx5=0;intmain(){inti;intr=-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=%dfd1=%d
",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,"x1didnotmach%d
",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,"x2didnotmach%d
",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,"x3didnotmach
");}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,"x4didnotmach
");}close(fd);close(fd1);}}
A7.test_v.sh
Thisisawrapperfortestingtest_v.c.

#!/bin/bashexportLD_PRELOAD=/usr/lib/cache_oraus.soexportLD_PRELOAD=./cache_oraus.sotime./test_v
A8.c.sh
#!/bin/bashPATH=/opt/SUNWspro/bin/:$PATHexportPATH;cc-fast-xarch=v8plusa-xdepend-xvector-xstrconst-xprefetch-G-ocache_open_calls.socache_open_calls.c-ldlcc-fast-xdepend-xvector-xstrconst-xarch=v8plusa-xprefetch-G-ocache_oraus.socache_oraus.c-ldlcc-fast-xstrconst-xvector-xdepend-xarch=v8plusa-xprefetch-otesttest.c-ldlcc-fast-xstrconst-xvector-xdepend-xarch=v8plusa-xprefetch-otest_vtest_v.c-ldl
A9.c64.sh
#!/bin/bash#Changestosourcecache_oraus.cfor64bitsupportwasmade#byBenHumphreysPATH=/opt/SUNWspro/bin/:$PATHexportPATH;cc-fast-xarch=v9a-xcode=abs64-xdepend-xvector-xstrconst-xprefetch-G-ocache_open_calls.socache_open_calls.c-ldlcc-fast-xarch=v9a-xcode=abs64-xdepend-xvector-xstrconst-xprefetch-G-ocache_oraus.socache_oraus.c-ldlcc-fast-xarch=v9a-xcode=abs64-xstrconst-xvector-xdepend-xprefetch-otesttest.c-ldlcc-fast-xarch=v9a-xcode=abs64-xstrconst-xvector-xdepend-xprefetch-otest_vtest_v.c-ldl
<name=A10>A10.Cache_open_calls.c
/*Date:April18,02Author:NagendraNagarajayyaDescription:Cachesopen,andclosecallstooraus.msbfile*/#include<stdio.h>#include<unistd.h>#include<dlfcn.h>#include<string.h>#include<stdlib.h>staticintk_bm_fd=-1;intopen(constchar*path,intoflag,mode_tmode){staticint(*fptr)()=0;if(fptr==0){fptr=(int(*)())dlsym(RTLD_NEXT,"open");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return0;}}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,"openthefile%d
",k_bm_fd);*/returnk_bm_fd;}else{/*fprintf(stderr,"re-openthefile%d
",k_bm_fd);*/returnk_bm_fd;}}return((*fptr)(path,oflag,mode));}intclose(intfildes){staticint(*fptr)()=0;if(fptr==0){fptr=(int(*)())dlsym(RTLD_NEXT,"close");if(fptr==NULL){fprintf(stderr,"dlopen:%s
",dlerror());return0;}}if(fildes==k_bm_fd){/*fprintf(stderr,"closethefile%d
",k_bm_fd);*/return0;}return((*fptr)(fildes));}
AbouttheAuthor
NagendraNagarajayyahasbeenatSunformorethan9years.AStaffEngineerinMarketDevelopmentEngineering(MDE/IPE),heworkswithtelcoISVsonarchitecture,performancetuning,sizingandscaling,benchmarking,porting,andsoon.Hisinterestsincludemultithreading,concurrencyandparallelism,HA,distributedcomputing,networking,andtheJavaandSolarisplatforms.

MySQL的低成本来自于其简单性吗?它的普及性是由于其低成本吗?其实,在MySQL的最“好”与最“不好”的功能之间没有明显的分界线,但它们组合在一起就形成了一副让我们欣赏的作品。
老尸 该用户已被删除
沙发
发表于 2015-1-19 21:08:01 | 只看该作者
其中最有名的应该是row_number了。这个终于解决了用临时表生成序列号的历史,而且SQLServer2005的row_number比Oracle的更先进。因为它把Orderby集成到了一起,不用像Oracle那样还要用子查询进行封装。
蒙在股里 该用户已被删除
板凳
发表于 2015-1-25 20:49:43 | 只看该作者
比如日志传送、比如集群。。。
飘飘悠悠 该用户已被删除
地板
发表于 2015-2-3 23:33:22 | 只看该作者
多加的系统视图和实时系统信息这些东西对DBA挑优非常有帮助,但是感觉粒度还是不太细。
精灵巫婆 该用户已被删除
5#
发表于 2015-2-9 06:40:26 | 只看该作者
不过话说回来了,绝大多数的性能优化准则与对sqlserver存储的结构理解息息相关
愤怒的大鸟 该用户已被删除
6#
发表于 2015-2-27 03:59:42 | 只看该作者
微软对CLR作了大篇幅的宣传,这是因为数据库产品终于融入.net体系中。最开始我们也是狂喜,感觉对象数据库的一些概念可以实现了。
admin 该用户已被删除
7#
发表于 2015-3-8 19:33:24 | 只看该作者
以前的DTS轻盈简单。但是现在的SSIS虽然功能强大了很多,但是总是让人感觉太麻烦。看看论坛中询问SSIS的贴子就知道。做的功能太强大了,往往会有很多用户不会用了
只想知道 该用户已被删除
8#
发表于 2015-3-16 12:53:38 | 只看该作者
而写到本地,我又考虑到效率问题.大家来讨论讨论吧,分数不打紧,就给10分,十全十美,没啥对错,各抒己见,但是要有说服力的哦~
再现理想 该用户已被删除
9#
发表于 2015-3-22 23:08:24 | 只看该作者
所以你总能得到相应的升级版本,来满足你的需求。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-11-15 03:36

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表