1回复
3年前
同样的代码 服务器比本地慢一个量级的原因
使用easyexcel解析excel文档 发现了这么一个问题:
一个76万行的Excel本地解析只要几分钟 放到阿里云服务器上跑的时候却需要30多分钟 (注: 均指定了同样的内存 -Xms512m -Xmx512m) 用arthas工具排查了下 发现服务器上好像整体的慢 并不是某一个点慢
本地
trace --skipJDKMethod false com.alibaba.excel.read.processor.DefaultAnalysisEventProcessor dealData
`---ts=2020-12-26 10:58:28;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@18b4aac2
`---[0.189268ms] com.alibaba.excel.read.processor.DefaultAnalysisEventProcessor:dealData()
+---[0.004504ms] com.alibaba.excel.context.AnalysisContext:readRowHolder() #84
+---[0.003468ms] com.alibaba.excel.read.metadata.holder.ReadRowHolder:getCellMap() #85
+---[0.003815ms] com.alibaba.excel.read.metadata.holder.ReadRowHolder:setCurrentRowAnalysisResult() #86
+---[0.003296ms] com.alibaba.excel.read.metadata.holder.ReadRowHolder:getRowIndex() #87
+---[0.00394ms] com.alibaba.excel.context.AnalysisContext:readSheetHolder() #88
+---[0.003504ms] com.alibaba.excel.read.metadata.holder.ReadSheetHolder:getHeadRowNumber() #57
+---[0.003797ms] com.alibaba.excel.context.AnalysisContext:currentReadHolder() #97
+---[0.003476ms] com.alibaba.excel.read.metadata.holder.ReadHolder:readListenerList() #57
+---[0.003098ms] java.util.List:iterator() #57
+---[min=0.002437ms,max=0.002762ms,total=0.007653ms,count=3] java.util.Iterator:hasNext() #57
+---[min=0.002698ms,max=0.00272ms,total=0.005418ms,count=2] java.util.Iterator:next() #57
+---[min=0.003489ms,max=0.003817ms,total=0.007306ms,count=2] com.alibaba.excel.read.metadata.holder.ReadRowHolder:getCurrentRowAnalysisResult() #100
+---[min=0.015653ms,max=0.035574ms,total=0.051227ms,count=2] com.alibaba.excel.read.listener.ReadListener:invoke() #57
`---[min=0.003336ms,max=0.003754ms,total=0.00709ms,count=2] com.alibaba.excel.read.listener.ReadListener:hasNext() #108
服务器上
`---ts=2020-12-26 10:59:34;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=org.springframework.boot.loader.LaunchedURLClassLoader@238e0d81
`---[1.167113ms] com.alibaba.excel.read.processor.DefaultAnalysisEventProcessor:dealData()
+---[0.035013ms] com.alibaba.excel.context.AnalysisContext:readRowHolder() #84
+---[0.02558ms] com.alibaba.excel.read.metadata.holder.ReadRowHolder:getCellMap() #85
+---[0.030248ms] com.alibaba.excel.read.metadata.holder.ReadRowHolder:setCurrentRowAnalysisResult() #86
+---[0.025663ms] com.alibaba.excel.read.metadata.holder.ReadRowHolder:getRowIndex() #87
+---[0.037863ms] com.alibaba.excel.context.AnalysisContext:readSheetHolder() #88
+---[0.027672ms] com.alibaba.excel.read.metadata.holder.ReadSheetHolder:getHeadRowNumber() #57
+---[0.031823ms] com.alibaba.excel.context.AnalysisContext:currentReadHolder() #97
+---[0.025251ms] com.alibaba.excel.read.metadata.holder.ReadHolder:readListenerList() #57
+---[0.01679ms] java.util.List:iterator() #57
+---[min=0.012983ms,max=0.013092ms,total=0.039089ms,count=3] java.util.Iterator:hasNext() #57
+---[min=0.01622ms,max=0.016695ms,total=0.032915ms,count=2] java.util.Iterator:next() #57
+---[min=0.028824ms,max=0.033356ms,total=0.06218ms,count=2] com.alibaba.excel.read.metadata.holder.ReadRowHolder:getCurrentRowAnalysisResult() #100
+---[min=0.045947ms,max=0.088069ms,total=0.134016ms,count=2] com.alibaba.excel.read.listener.ReadListener:invoke() #57
`---[min=0.028462ms,max=0.028464ms,total=0.056926ms,count=2] com.alibaba.excel.read.listener.ReadListener:hasNext() #108
可见服务器上每个方法调用都要慢约一个量级 所以弄不清楚什么情况 不知道该怎么优化
3961 阅读