Code Monkey home page Code Monkey logo

Comments (11)

glassfishrobot avatar glassfishrobot commented on September 23, 2024

Reported by jayashri

from javaserverfaces-spec.

glassfishrobot avatar glassfishrobot commented on September 23, 2024

@edburns said:
The current impl is as fast as it can be given the best efforts of the
RI team and Adam to date.

Where is the bottleneck? It's in
UIComponentBase.getPropertyDescriptor(). This is called whenever
someone accesses a attribute or property on the UIComponent instance.
UIComponentBase.getAttributes().get(). This boils down to a get() on
a WeakHashMap that will return a PropertyDescriptor. This solution
assumes it is safe to have concurrent reads on the WeakHashMap. Is
the a safe assumption?

Is there a faster implementation? If not, can we design it
differently, while preserving backwards compatibility?

We need an automated test that reproduces this bug.

from javaserverfaces-spec.

glassfishrobot avatar glassfishrobot commented on September 23, 2024

@edburns said:
I've heard that this may be faster in JDK 1.4, and I would guess it might be
faster still in JDK 5.0?

from javaserverfaces-spec.

glassfishrobot avatar glassfishrobot commented on September 23, 2024

@edburns said:
This change-bundle fixes an unsafe assumption about the thread-safety of
unmodified WeakHashMap instances for concurrent reads.

SECTION: API Changes

M jsf-api/src/javax/faces/component/UIComponentBase.java

  • make pdMap ivar a Map, not a WeakHashMap

  • make pdMap ivar be vended by Collections.synchronizedMap().

SECTION: RI changes

M
jsf-ri/systest-per-webapp/el-performance/src/java/com/sun/faces/systest/EvaluatorBean.java

  • only wait for between 1 and 100 nanoseconds between get() operations.

SECTION: API Diffs

Index: jsf-api/src/javax/faces/component/UIComponentBase.java

RCS file:
/cvs/javaserverfaces-sources/jsf-api/src/javax/faces/component/UIComponentBase.java,v
retrieving revision 1.101
diff -u -r1.101 UIComponentBase.java
— jsf-api/src/javax/faces/component/UIComponentBase.java 16 Jun 2004
00:06:55 -0000 1.101
+++ jsf-api/src/javax/faces/component/UIComponentBase.java 15 Oct 2004 05:46:30
-0000
@@ -20,6 +20,7 @@
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -75,7 +76,7 @@

  • Reference to the map of PropertyDescriptors for this class

  • in the descriptors Map.
    */

  • private WeakHashMap pdMap = null;

    • private Map pdMap = null;

/**

  • An empty argument list to be passed to reflection methods.

    @@ -84,14 +85,14 @@

public UIComponentBase() {
synchronized(descriptors) {

  • pdMap = (WeakHashMap) descriptors.get(this.getClass());

    • pdMap = (Map) descriptors.get(this.getClass());
      if (pdMap != null) { return; }

    // load the property descriptors for this class.
    PropertyDescriptor pd[] = getPropertyDescriptors();
    if (pd != null) {

  • pdMap = new WeakHashMap(pd.length);

    • pdMap = Collections.synchronizedMap(new HashMap(pd.length));
      for (int i = 0; i < pd.length; i++) { pdMap.put(pd[i].getName(), pd[i]); }

SECTION: RI Diffs

Index:
jsf-ri/systest-per-webapp/el-performance/src/java/com/sun/faces/systest/EvaluatorBean.java

RCS file:
/cvs/javaserverfaces-sources/jsf-ri/systest-per-webapp/el-performance/src/java/com/sun/faces/systest/EvaluatorBean.java,v
retrieving revision 1.3
diff -u -r1.3 EvaluatorBean.java

jsf-ri/systest-per-webapp/el-performance/src/java/com/sun/faces/systest/EvaluatorBean.java
14 Oct 2004 19:53:41 -0000 1.3
+++
jsf-ri/systest-per-webapp/el-performance/src/java/com/sun/faces/systest/EvaluatorBean.java
15 Oct 2004 05:46:34 -0000
@@ -120,7 +120,7 @@
curInput.getAttributes().put("foo", "bar");
runnable = new AttributeGetRunnable(curInput, getReps(), "foo",
random, i,

  • numThreads == 1 ? false: true,
    • true,
      System.out,
      this);

@@ -220,7 +220,7 @@

if (sleepBetweenGets) {
try

{ - Thread.sleep(Math.abs(random.nextLong()) % 10); + Thread.sleep(0L, Math.abs(random.nextInt()) % 100); }

catch (InterruptedException e) {
host.getThreadOutcomes()[index] = e;

from javaserverfaces-spec.

glassfishrobot avatar glassfishrobot commented on September 23, 2024

@edburns said:
Old implementation

30000 reps

1 thread

31:15

2 threads

34:89

3 threads

31:05

5 threads

31:14

10 threads

31:25

New implementation: Collections.synchronizedMap(new HashMap());

1 thread

31:05

2 threads

30:03

3 threads

32:16

5 threads

32:147

10 threads

32:46

20 threads

31:04

40 threads

32:16

100 threads

32:56

from javaserverfaces-spec.

glassfishrobot avatar glassfishrobot commented on September 23, 2024

@edburns said:
fixed in EDR

from javaserverfaces-spec.

glassfishrobot avatar glassfishrobot commented on September 23, 2024

@edburns said:
Prepare to delete "spec" subcomponent.

from javaserverfaces-spec.

glassfishrobot avatar glassfishrobot commented on September 23, 2024

@edburns said:
Move all to 1.2

from javaserverfaces-spec.

glassfishrobot avatar glassfishrobot commented on September 23, 2024

@manfredriem said:
Closing resolved issue out

from javaserverfaces-spec.

glassfishrobot avatar glassfishrobot commented on September 23, 2024

This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-45

from javaserverfaces-spec.

glassfishrobot avatar glassfishrobot commented on September 23, 2024

Marked as fixed on Thursday, March 4th 2010, 6:09:29 am

from javaserverfaces-spec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.