Home » Eclipse Projects » EclipseLink » Eclipselink performance problem
Eclipselink performance problem [message #1499834] |
Fri, 05 December 2014 12:56 |
vishal mestri Messages: 2 Registered: December 2014 |
Junior Member |
|
|
We are planning to migration ejb 2.1 to ejb 3.
Here as Entity bean is present in EJB 3, we used JPA with eclipselink on weblogic.
We compared performance of CMP Entity EJB 2.1 vs JPA Eclipselink entity with L2 Cache i.e. persistence unit. But we found that performance of eclipselink is coming very low.
Following are details:-
1. When we hit first time, eclipselink is taking more than 500 milliseconds to fetch object.
For subsequent hits, performance is very good, as object is cached in persistence unit.
2. We have used following configuration in persistence.xml
<persistence-unit name="TestApp" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>orderPool</jta-data-source>
<class>com.product.ejb.BusinessSKUEntityEJB</class>
<class>com.product.ejb.BusinessSKUEntityPK</class>
<class>com.shipping.ejb.ShippingModesEntityEJB</class>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="eclipselink.target-server" value="WebLogic"/>
<property name="eclipselink.profiler" value="PerformanceMonitor"/>
<property name="toplink.cache.type.default" value="FULL"/>
<property name="toplink.cache.size.default" value="1000"/>
<property name="toplink.cache.shared.default" value="true"/>
<property name="toplink.logging.logger" value="DefaultLogger"/>
<property name="toplink.logging.level" value="INFO"/>
<property name="toplink.logging.timestamp" value="true"/>
<property name="toplink.logging.exceptions" value="true"/>
<property name="eclipselink.cache.type.default" value="FULL"/>
<property name="eclipselink.cache.size.default" value="1000"/>
<property name="eclipselink.cache.shared.default" value="true"/> <property name="eclipselink.logging.logger" value="DefaultLogger"/>
<property name="eclipselink.logging.level" value="INFO"/>
<property name="eclipselink.logging.timestamp" value="true"/>
<property name="eclipselink.logging.exceptions" value="true"/>
<property name="eclipselink.target-database" value="Oracle"/>
<property name="eclipselink.jdbc.cache-statements" value="true"/>
<property name="eclipselink.deploy-on-startup" value="true" />
</properties>
</persistence-unit>
</persistence>
3. We have used following configuration in Entity class
package com.product.ejb;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.Iterator;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.PostActivate;
import javax.ejb.PrePassivate;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.PostLoad;
import javax.persistence.PostPersist;
import javax.persistence.PostRemove;
import javax.persistence.PostUpdate;
import javax.persistence.PrePersist;
import javax.persistence.PreRemove;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import org.eclipse.persistence.annotations.BasicMap;
import org.eclipse.persistence.annotations.Cache;
import org.eclipse.persistence.annotations.CacheType;
import org.eclipse.persistence.annotations.Convert;
import org.eclipse.persistence.annotations.Converter;
import org.eclipse.persistence.annotations.ReadOnly;
import org.eclipse.persistence.config.CacheIsolationType;
/**
* The persistent class for the BUSINESSSKU database table.
*
*/
@Entity
@ReadOnly
@Converter(converterClass=NodeConverter.class,name="longToNode")
@Cacheable
@NamedQueries({
@NamedQuery(name="findByBusinessAndBusinessSKUID",query="SELECT OBJECT(o) FROM BusinessSKUEntityEJB o WHERE ((o.owningbusinessid = ?1) AND (o.businessskuid = ?2))"),
@NamedQuery(name="findByBusinessAndOwnerSKU",query="SELECT OBJECT(o) FROM BusinessSKUEntityEJB o WHERE ((o.owningbusinessid = ?1) AND (o.ownersku = ?2))")
})
@Table(name="BUSINESSSKU")
public class BusinessSKUEntityEJB implements Serializable{
private static final long serialVersionUID = 1L;
public BusinessSKUEntityEJB()
{
System.out.println("-------------BusinessSKUEntityEJB--const");
}
@SuppressWarnings("deprecation")
@BasicMap(fetch=FetchType.EAGER,keyColumn = @Column(name = "ATTRIBUTEID",table="BusinessSKUAttribute"),valueColumn=@Column(name="value",table="BusinessSKUAttribute"))
private Map<String,String> attributes;
@EmbeddedId
private BusinessSKUEntityPK businessSKUEntityPK;
@Column(name="businessskuid",nullable=false, insertable=false, updatable=false)
@Convert("longToNode")
private Node parentGroup;
public BusinessSKUEntityPK getBusinessSKUEntityPK() {
return businessSKUEntityPK;
}
public void setBusinessSKUEntityPK(BusinessSKUEntityPK businessSKUEntityPK) {
this.businessSKUEntityPK = businessSKUEntityPK;
}
private long businessskuid;
private double baseprice;
private String createdby;
private Date createddate;
private String department;
private String description;
private Date instoredate;
private double marginpercentage;
private int markdownlevel;
private double minimumspreadpctg;
private String modifiedby;
private Date modifieddate;
private String ownersku;
private String ownerskudescription;
private long owningbusinessid;
@Column(name="\"PREORDER\"")
private String preorder;
private long skusetid;
private double totalexcessinvforavail;
private double weight;
private double wholesalediscountpctg;
public Map<String, String> getAttributes() {
return attributes;
}
public void setAttributes(Map<String, String> attributes) {
this.attributes = attributes;
}
public Node getParentGroup() {
return parentGroup;
}
public void setParentGroup(Node parentGroup) {
this.parentGroup = parentGroup;
}
public long getBusinessskuid() {
return businessskuid;
}
public void setBusinessskuid(long businessskuid) {
this.businessskuid = businessskuid;
}
public double getBaseprice() {
return baseprice;
}
public void setBaseprice(double baseprice) {
this.baseprice = baseprice;
}
public String getCreatedby() {
return createdby;
}
public void setCreatedby(String createdby) {
this.createdby = createdby;
}
public Date getCreateddate() {
return createddate;
}
public void setCreateddate(Date createddate) {
this.createddate = createddate;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getInstoredate() {
return instoredate;
}
public void setInstoredate(Date instoredate) {
this.instoredate = instoredate;
}
public double getMarginpercentage() {
return marginpercentage;
}
public void setMarginpercentage(double marginpercentage) {
this.marginpercentage = marginpercentage;
}
public int getMarkdownlevel() {
return markdownlevel;
}
public void setMarkdownlevel(int markdownlevel) {
this.markdownlevel = markdownlevel;
}
public double getMinimumspreadpctg() {
return minimumspreadpctg;
}
public void setMinimumspreadpctg(double minimumspreadpctg) {
this.minimumspreadpctg = minimumspreadpctg;
}
public String getModifiedby() {
return modifiedby;
}
public void setModifiedby(String modifiedby) {
this.modifiedby = modifiedby;
}
public Date getModifieddate() {
return modifieddate;
}
public void setModifieddate(Date modifieddate) {
this.modifieddate = modifieddate;
}
public String getOwnersku() {
return ownersku;
}
public void setOwnersku(String ownersku) {
this.ownersku = ownersku;
}
public String getOwnerskudescription() {
return ownerskudescription;
}
public void setOwnerskudescription(String ownerskudescription) {
this.ownerskudescription = ownerskudescription;
}
public long getOwningbusinessid() {
return owningbusinessid;
}
public void setOwningbusinessid(long owningbusinessid) {
this.owningbusinessid = owningbusinessid;
}
public String getPreorder() {
return preorder;
}
public void setPreorder(String preorder) {
this.preorder = preorder;
}
public long getSkusetid() {
return skusetid;
}
public void setSkusetid(long skusetid) {
this.skusetid = skusetid;
}
public double getTotalexcessinvforavail() {
return totalexcessinvforavail;
}
public void setTotalexcessinvforavail(double totalexcessinvforavail) {
this.totalexcessinvforavail = totalexcessinvforavail;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public double getWholesalediscountpctg() {
return wholesalediscountpctg;
}
public void setWholesalediscountpctg(double wholesalediscountpctg) {
this.wholesalediscountpctg = wholesalediscountpctg;
}
@PostLoad
public void postLoad()
{
System.out.println("postLoad="+businessskuid);
}
@PostUpdate
public void postupdate(){
System.out.println("Postupdate="+businessskuid);
}
@PostPersist
public void postPersist(){
System.out.println("PostPersist="+businessskuid);
}
@PostRemove
public void postRemove(){
System.out.println("PostRemove="+businessskuid);
}
@PostActivate
public void postActivate(){
System.out.println("PostActivate="+businessskuid);
}
@PostConstruct
public void postConstruct(){
System.out.println("PostConstruct="+businessskuid);
}
@PreRemove
public void preRemove(){
System.out.println("preRemove="+businessskuid);
}
@PreUpdate
public void PreUpdate(){
System.out.println("PreUpdate="+businessskuid);
}
@PrePersist
public void PrePersist(){
System.out.println("PrePersist="+businessskuid);
}
@PreDestroy
public void PreDestroy(){
System.out.println("PreDestroy="+businessskuid);
}
@PrePassivate
public void PrePassivate(){
System.out.println("PrePassivate="+businessskuid);
}
}
4.We are calling using following code in Stateless session bean.
public BusinessSKUEntityEJB findByPrimaryKey(BusinessSKUEntityPK businessskuentitypk) {
// return (BusinessSKUEntityEJB)em.find("BusinessSKUEntityEJB", businessskuid);
Calendar cal1 = Calendar.getInstance();
System.out.println("1--------------------------------");
EntityManagerFactory emf= Persistence.createEntityManagerFactory("TestApp");
Calendar cal2 = Calendar.getInstance();
System.out.println("2--------------------------------");
EntityManager em=emf.createEntityManager();/**/
//em.setProperty("javax.persistence.cache.storeMode", "BYPASS");
System.out.println("3--------------------------------");
Calendar cal3 = Calendar.getInstance();
BusinessSKUEntityEJB t =em.find(BusinessSKUEntityEJB.class, businessskuentitypk);
//BusinessSKUEntityEJB t = em.getReference(BusinessSKUEntityEJB.class, businessskuentitypk);
System.out.println("4--------------------------------");
Calendar cal4 = Calendar.getInstance();
try{
//System.out.println("Locking mode for"+businessskuentitypk.getBusinessskuid()+">"+em.getLockMode(t));
}
catch(TransactionRequiredException ttt){
System.out.println("TransactionRequiredException**********************");
}catch (IllegalArgumentException e) {
// TODO: handle exception
System.out.println("IllegalArgumentException*************");
}catch(Exception e1){
System.out.println("Exception*****************************");
}
em.close();
Calendar cal5 = Calendar.getInstance();
printTimeDiff("<**>"+businessskuentitypk.getBusinessskuid()+"[EntityCall.java-findByPrimaryKey]creating EMF instance= ",cal1,cal2);
printTimeDiff("<**>"+businessskuentitypk.getBusinessskuid()+"[EntityCall.java-findByPrimaryKey]creating EM instance= ",cal2,cal3);
printTimeDiff("<**>"+businessskuentitypk.getBusinessskuid()+"[EntityCall.java-findByPrimaryKey]call find method = ",cal3,cal4);
printTimeDiff("<**>"+businessskuentitypk.getBusinessskuid()+"[EntityCall.java-findByPrimaryKey]call close method = ",cal4,cal5);
return t;
}
WE enabled performance profiling and monitoring options.
Following are output:-
Performance Profiler for hit to db(i.e. first hit):-
Profile(ReadObjectQuery,
class=com.product.ejb.BusinessSKUEntityEJB,
number of objects=1,
total time=682362792,
local time=678065531,
profiling time=940494,
Timer:SqlPrepare=106761,
Timer:Caching=75742,
Timer:ConnectionManagement=52703,
Timer:StatementExecute=2258549,
Timer:RowFetch=393611,
Timer:ObjectBuilding=674486831,
Timer:DescriptorEvents=23068,
time/object=682362792,
)
}End profile
Profile(ReadObjectQuery,
class=com.product.ejb.BusinessSKUEntityEJB,
number of objects=1,
total time=505841362,
local time=-176521430,
profiling time=3397504,
Timer:Caching=506125239,
time/object=505841362,
)
}End profile
Performance Monitor for all hits:
Performance Monitor:1417778035660
Operation Value (ns)
Counter:CacheHits 9
Counter:CacheMisses 1
Counter:ConnectCalls 2
Counter:DataReadQuery 1
Counter:DataReadQuery:attributes 1
Counter:ReadObjectQuery 10
Counter:ReadObjectQuery:com.product.ejb.BusinessSKUEntityEJB:readObject 10
Counter:ReadObjectQuery:com.product.ejb.BusinessSKUEntityEJB:readObject:CacheHits 9
Counter:ReadObjectQuery:com.product.ejb.BusinessSKUEntityEJB:readObject:CacheMisses 1
Info:CacheSize:BusinessSKUEntityEJB 1
Info:LoginTime Fri Dec 05 16:35:50 IST 2014
Info:SessionName zip:/apps/bea12/user_projects/domains/testDomainPrd/servers/testServer/tmp/_WL_user/test/xn6c84/test.jar!/_TestApp
Timer:Caching 360,964
Timer:ConnectionManagement 8,096,841
Timer:DataReadQuery 7,095,433
Timer:DataReadQuery:attributes 7,090,270
Timer:DataReadQuery:attributes:QueryPreparation 328,627
Timer:DataReadQuery:attributes:RowFetch 235,006
Timer:DataReadQuery:attributes:SqlGeneration 233,104
Timer:DataReadQuery:attributes:SqlPrepare 203,726
Timer:DataReadQuery:attributes:StatementExecute 5,126,831
Timer:DescriptorEvents 93,444
Timer:JPAQuery:findByBusinessAndBusinessSKUID:QueryPreparation 1,515,070
Timer:JPAQuery:findByBusinessAndOwnerSKU:QueryPreparation 1,574,143
Timer:Logging 606,810
Timer:ObjectBuilding 706,280,414
Timer:QueryPreparation 3,955,412
Timer:ReadObjectQuery 716,752,169
Timer:ReadObjectQuery:com.product.ejb.BusinessSKUEntityEJB:readObject 716,780,072
Timer:ReadObjectQuery:com.product.ejb.BusinessSKUEntityEJB:readObject:ObjectBuilding 706,282,538
Timer:ReadObjectQuery:com.product.ejb.BusinessSKUEntityEJB:readObject:QueryPreparation 511,961
Timer:ReadObjectQuery:com.product.ejb.BusinessSKUEntityEJB:readObject:RowFetch 930,333
Timer:ReadObjectQuery:com.product.ejb.BusinessSKUEntityEJB:readObject:SqlGeneration 315,022
Timer:ReadObjectQuery:com.product.ejb.BusinessSKUEntityEJB:readObject:SqlPrepare 715,989
Timer:ReadObjectQuery:com.product.ejb.BusinessSKUEntityEJB:readObject:StatementExecute 3,082,246
Timer:RowFetch 1,155,805
Timer:SqlGeneration 538,472
Timer:SqlPrepare 916,072
Timer:StatementExecute 8,191,977
From above output , it seems that object building is taking more time i.e. around 700 milliseconds.
For same record, CMP Entity ejb 2.1 takes around 150 milliseconds.
Further, we also faced issue of HEAP Memory when we hit for 1000 different type of entities.
Please let us know how to fine tune further.
Regards,
vishal
|
|
| |
Goto Forum:
Current Time: Sat Oct 12 12:58:31 GMT 2024
Powered by FUDForum. Page generated in 0.03949 seconds
|