Speeding up Apache Pivot For embedded Application

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Speeding up Apache Pivot For embedded Application

Ripgiblet
Hi All,

SUMMARY:
Is there anyway to make sun.awt.GlobalCursorManager$NativeUpdater.run()
more efficient?

DETAILS:
I am using apache pivot in an embedded application, and currently it is
running a little bit sluggish. Misses some mouse clicks etc...
After running VisualVM it seems that a lot of processor (62%) of the program
is used in:
sun.awt.GlobalCursorManager$NativeUpdater.run()
I assume this is what reads in the Mouse movements etc.
I am running VisualVM on windows, but application on linux:/ (Will profile
on linux after I get running well under windows...)
Any ideas on how to make this more efficient?

Regards,
Mark.
-----Original Message-----
From: Roger Whitcomb [mailto:[hidden email]]
Sent: Tuesday, 25 March 2014 7:18 AM
To: [hidden email]
Subject: RE: Unserialize an object in class constructor

Right.

-----Original Message-----
From: Ilya Zimnovich [mailto:[hidden email]]
Sent: Monday, March 24, 2014 12:42 PM
To: [hidden email]
Subject: Re: Unserialize an object in class constructor

Hi Roger,

So you mean I can put some child control of the FinanceWindow class into a
FinanceWindow.bxml file, then create this child control using
BXMLSerializer's readObject method and attach it to a FinanceWindow instance
in the constructor, right? As far as I understand the FinanceWindow.bxml
file can contain only one root element. Something like BoxPane or TablePane.
This way it will be possible to just do a "new FinanceWindow" in the
Application derived object.

Why do I want to do it? Well, I would like to properly decompose my
application, just like it is done in wxWidgets or QT C++ frameworks I used
to work with. Below is how it is done in wxWidgets (C++):

class TestWnd_Base : public wxFrame
{
protected:
    wxTextCtrl* A;
    wxButton* B;

public:
    TestWnd::TestWnd()
    {
        wxXmlResource::Get()->LoadObject(this, NULL, "TestWnd", "wxFrame");
        A = XRCCTRL(*this, "A", wxTextCtrl);
        B = XRCCTRL(*this, "B", wxButton);
    }
};

Well, don't forget the Android Activities:

public class SetWallpaperActivity extends FragmentActivity {
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        // Inflate XML layout
        setContentView(R.layout.set_wallpaper_activity);
    }
}

I sure that it is the Window object itself who should take the
responsibility to create the children objects and to load its localization
resources. The other windows and panels should also load their localization
resources and create their children from bxml file.
Of course I do understand that it's a matter of ones taste!

Best Regards,
Ilya A. Zimnovich

On 24.03.2014 21:42, Roger Whitcomb wrote:
> Hi Ilya,
> Well, the answer is yes, but ....  If your FinanceWindow.bxml has
the top-level object as a FinanceWindow, then if in the FinanceWindow
constructor you load that bxml file, you will get into an infinite
recursion.  But, if your FinanceWindow.bxml has just the content of your
window and you create the top-level Window object some other way (i.e. just
do a "new FinanceWindow" in the startup code as you have it), then you could
just read the contents of the window and set the window's child from the
BXML file (which is NOT what you have in your code), then that should work.
> I'm curious why you want to do this?  It is pretty much the same
code either way, but if you let the BXMLSerializer create all the objects
(including the top-level window) it is a tiny bit less work in your code.
Or is there a design pattern you're trying to achieve?

>
> HTH,
> ~Roger
>
> -----Original Message-----
> From: Ilya Zimnovich [mailto:[hidden email]]
> Sent: Monday, March 24, 2014 9:26 AM
> To: [hidden email]
> Subject: Unserialize an object in class constructor
>
> Dear Apache Pivot experts,
>
> All the Apache Pivot examples unserialize an objects with BXMLSerializer's
readObject method:
>
> ....
>     public void startup(Display display, Map<String, String> properties)
throws Exception
>     {
>         String language = properties.get("language");
>         Locale locale = (language == null) ? Locale.getDefault() : new
Locale(language);

>         Resources resources = new
> Resources(FinanceWindow.class.getName(), locale);
>        
>         BXMLSerializer bxmlSerializer = new BXMLSerializer();
>         window =
> (FinanceWindow)bxmlSerializer.readObject(getClass().getResource("Finan
> ceWindow.bxml"),
> resources);
>         window.open(display);
>     }
> ....
>
> Is there a way to unserialize the object in its constructor? I mean
something like the below:
>
> ....
>     public void startup(Display display, Map<String, String> properties)
throws Exception

>     {
>         window = new FinanceWindow();
>         window.open(display);
>     }
> ....
>
> public class FinanceWindow extends Frame implements Bindable { ....
>
>     public FinanceWindow()
>     {
>         BXMLSerializer bxmlSerializer = new BXMLSerializer();
>
>         // Load localized resources and unserialize the object
>         String language = properties.get("language");
>         Locale locale = (language == null) ? Locale.getDefault() : new
Locale(language);

>         Resources resources = new Resources(getClass().getName(),
> locale);
>
>         bxmlSerializer.readObjectXXXX(this, "FinanceWindow.bxml");
>
> ....
>
>
> Best Regards,
> Ilya A. Zimnovich
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Speeding up Apache Pivot For embedded Application

Sandro Martini
Hi Mark,

> Is there anyway to make sun.awt.GlobalCursorManager$NativeUpdater.run() more efficient?
No (sorry), this class is bundled in rt.jar (the main jar for the
JRE), so unless you provide a patched JRE I don't think it's possible
(assuming from a legal point of view it's doable, by the license). And
we don't use it directly of course ...
Note that probably this class interacts with Threads, native (OS
specific) functions and Window Managers and other complex stuff, so
anyway it would be an hard task. Its source is not in the usual
src.zip (in root of JDK).

Here an online version of that class (taken from OpenJDK-7):
http://www.docjar.com/html/api/sun/awt/GlobalCursorManager.java.html


Just for curiosity: did you tried with Oracle JDK or Open JDK ? Could
you try to swap ?


Bye,
Sandro
Reply | Threaded
Open this post in threaded view
|

RE: Speeding up Apache Pivot For embedded Application

Ripgiblet
Hi All,

SUMMARY:
I spent today working on making it more efficient, and it is substantially
faster now. Thanks for the feedback.

DETAILS:
I am using OpenJDK on the linux platform and Oracle on the windows one;]

I increased the memory of the JAVA processes using memory command line
options (It think they are...-Xms and Xmx or something...)
I also stopped processes from updating anything in the GUI, since it seems
to force a lot of other GUI items to invalidate.

Application is much faster now, and almost the same speed as my previous
JAVA application and has a fair more complex GUI...
I will continue to work on it, I think I use far too many
FazetTableView's(about 9...), so I may need to go through that code and look
for some efficiencies I can add..

PS-Thanks for the feedback, is probably ok for now;]
Regards,
Mark.
-----Original Message-----
From: Sandro Martini [mailto:[hidden email]]
Sent: Wednesday, 26 March 2014 7:15 PM
To: Users - Apache Pivot
Subject: Re: Speeding up Apache Pivot For embedded Application

Hi Mark,

> Is there anyway to make sun.awt.GlobalCursorManager$NativeUpdater.run()
more efficient?
No (sorry), this class is bundled in rt.jar (the main jar for the JRE), so
unless you provide a patched JRE I don't think it's possible (assuming from
a legal point of view it's doable, by the license). And we don't use it
directly of course ...
Note that probably this class interacts with Threads, native (OS
specific) functions and Window Managers and other complex stuff, so anyway
it would be an hard task. Its source is not in the usual src.zip (in root of
JDK).

Here an online version of that class (taken from OpenJDK-7):
http://www.docjar.com/html/api/sun/awt/GlobalCursorManager.java.html


Just for curiosity: did you tried with Oracle JDK or Open JDK ? Could you
try to swap ?


Bye,
Sandro

Reply | Threaded
Open this post in threaded view
|

RE: Speeding up Apache Pivot For embedded Application

Sandro Martini

Hi Mark,
this is a good news :-) , I'm really happy for you.

If you can,  could you post your use case for Pivot (for an embedded app) ? Could become another user story for Pivot applications in our wiki.

Last, what does it mean "stopped processes from updating anything in the GUI" (in your code) ?
If you have some hint please tell, it  could be useful even to others.

Thanks for sharing with us your real-world experience with Pivot. 

Bye,
Sandro

Il 27/mar/2014 18:34 "Mark R. Chambers" <[hidden email]> ha scritto:
Hi All,

SUMMARY:
I spent today working on making it more efficient, and it is substantially
faster now. Thanks for the feedback.

DETAILS:
I am using OpenJDK on the linux platform and Oracle on the windows one;]

I increased the memory of the JAVA processes using memory command line
options (It think they are...-Xms and Xmx or something...)
I also stopped processes from updating anything in the GUI, since it seems
to force a lot of other GUI items to invalidate.

Application is much faster now, and almost the same speed as my previous
JAVA application and has a fair more complex GUI...
I will continue to work on it, I think I use far too many
FazetTableView's(about 9...), so I may need to go through that code and look
for some efficiencies I can add..

PS-Thanks for the feedback, is probably ok for now;]
Regards,
Mark.
-----Original Message-----
From: Sandro Martini [mailto:[hidden email]]
Sent: Wednesday, 26 March 2014 7:15 PM
To: Users - Apache Pivot
Subject: Re: Speeding up Apache Pivot For embedded Application

Hi Mark,

> Is there anyway to make sun.awt.GlobalCursorManager$NativeUpdater.run()
more efficient?
No (sorry), this class is bundled in rt.jar (the main jar for the JRE), so
unless you provide a patched JRE I don't think it's possible (assuming from
a legal point of view it's doable, by the license). And we don't use it
directly of course ...
Note that probably this class interacts with Threads, native (OS
specific) functions and Window Managers and other complex stuff, so anyway
it would be an hard task. Its source is not in the usual src.zip (in root of
JDK).

Here an online version of that class (taken from OpenJDK-7):
http://www.docjar.com/html/api/sun/awt/GlobalCursorManager.java.html


Just for curiosity: did you tried with Oracle JDK or Open JDK ? Could you
try to swap ?


Bye,
Sandro

Reply | Threaded
Open this post in threaded view
|

RE: Speeding up Apache Pivot For embedded Application

Ripgiblet

Hi Sandro,

 

 

All update methods are surrounded by change tests:

Basically I have status buttons on the screen that I regularly update to show the status of equipment, so I only update them if they have changed…

And the same with label updates… so for example:

if(!mTRNGUIWindow.mDispenserStatusLabel[vPump].getText().equalsIgnoreCase(vStatus)) {

            ApplicationContext.queueCallback(new TaskSetLabelText(mTRNGUIWindow.mDispenserStatusLabel[vPump], vStatus));

}

 

/** */

    private class TaskSetLabelText implements Runnable

    {

        Label mLabel;

        String mText;

        public TaskSetLabelText(Label vLabel,String vText)

        {

            mLabel = vLabel;

            mText = vText;

        }

 

        public void run ()

        {

            mLabel.setText(mText);

            mLabel.setTextKey(mText);

        }

    }

 

Nothing too tricky, I just don’t update things unless they have actually changed;]

Regards,

Mark.

 

From: Sandro Martini [mailto:[hidden email]]
Sent: Friday, 28 March 2014 1:20 AM
To: Users - Apache Pivot
Subject: RE: Speeding up Apache Pivot For embedded Application

 

Hi Mark,
this is a good news :-) , I'm really happy for you.

If you can,  could you post your use case for Pivot (for an embedded app) ? Could become another user story for Pivot applications in our wiki.

Last, what does it mean "stopped processes from updating anything in the GUI" (in your code) ?
If you have some hint please tell, it  could be useful even to others.

Thanks for sharing with us your real-world experience with Pivot. 

Bye,
Sandro

Il 27/mar/2014 18:34 "Mark R. Chambers" <[hidden email]> ha scritto:

Hi All,

SUMMARY:
I spent today working on making it more efficient, and it is substantially
faster now. Thanks for the feedback.

DETAILS:
I am using OpenJDK on the linux platform and Oracle on the windows one;]

I increased the memory of the JAVA processes using memory command line
options (It think they are...-Xms and Xmx or something...)
I also stopped processes from updating anything in the GUI, since it seems
to force a lot of other GUI items to invalidate.

Application is much faster now, and almost the same speed as my previous
JAVA application and has a fair more complex GUI...
I will continue to work on it, I think I use far too many
FazetTableView's(about 9...), so I may need to go through that code and look
for some efficiencies I can add..

PS-Thanks for the feedback, is probably ok for now;]
Regards,
Mark.
-----Original Message-----
From: Sandro Martini [mailto:[hidden email]]
Sent: Wednesday, 26 March 2014 7:15 PM
To: Users - Apache Pivot
Subject: Re: Speeding up Apache Pivot For embedded Application

Hi Mark,

> Is there anyway to make sun.awt.GlobalCursorManager$NativeUpdater.run()
more efficient?
No (sorry), this class is bundled in rt.jar (the main jar for the JRE), so
unless you provide a patched JRE I don't think it's possible (assuming from
a legal point of view it's doable, by the license). And we don't use it
directly of course ...
Note that probably this class interacts with Threads, native (OS
specific) functions and Window Managers and other complex stuff, so anyway
it would be an hard task. Its source is not in the usual src.zip (in root of
JDK).

Here an online version of that class (taken from OpenJDK-7):
http://www.docjar.com/html/api/sun/awt/GlobalCursorManager.java.html


Just for curiosity: did you tried with Oracle JDK or Open JDK ? Could you
try to swap ?


Bye,
Sandro

Reply | Threaded
Open this post in threaded view
|

Re: Speeding up Apache Pivot For embedded Application

Sandro Martini
Hi Mark,
good to know :-) ...

Thanks again for the info.

Bye,
Sandro


2014-03-28 6:15 GMT+01:00 Mark R. Chambers <[hidden email]>:

> Hi Sandro,
>
>
>
>
>
> All update methods are surrounded by change tests:
>
> Basically I have status buttons on the screen that I regularly update to
> show the status of equipment, so I only update them if they have changed...
>
> And the same with label updates... so for example:
>
> if(!mTRNGUIWindow.mDispenserStatusLabel[vPump].getText().equalsIgnoreCase(vStatus))
> {
>
>             ApplicationContext.queueCallback(new
> TaskSetLabelText(mTRNGUIWindow.mDispenserStatusLabel[vPump], vStatus));
>
> }
>
>
>
> /** */
>
>     private class TaskSetLabelText implements Runnable
>
>     {
>
>         Label mLabel;
>
>         String mText;
>
>         public TaskSetLabelText(Label vLabel,String vText)
>
>         {
>
>             mLabel = vLabel;
>
>             mText = vText;
>
>         }
>
>
>
>         public void run ()
>
>         {
>
>             mLabel.setText(mText);
>
>             mLabel.setTextKey(mText);
>
>         }
>
>     }
>
>
>
> Nothing too tricky, I just don't update things unless they have actually
> changed;]
>
> Regards,
>
> Mark.
>
>
>
> From: Sandro Martini [mailto:[hidden email]]
> Sent: Friday, 28 March 2014 1:20 AM
>
>
> To: Users - Apache Pivot
> Subject: RE: Speeding up Apache Pivot For embedded Application
>
>
>
> Hi Mark,
> this is a good news :-) , I'm really happy for you.
>
> If you can,  could you post your use case for Pivot (for an embedded app) ?
> Could become another user story for Pivot applications in our wiki.
>
> Last, what does it mean "stopped processes from updating anything in the
> GUI" (in your code) ?
> If you have some hint please tell, it  could be useful even to others.
>
> Thanks for sharing with us your real-world experience with Pivot.
>
> Bye,
> Sandro
>
> Il 27/mar/2014 18:34 "Mark R. Chambers" <[hidden email]> ha scritto:
>
> Hi All,
>
> SUMMARY:
> I spent today working on making it more efficient, and it is substantially
> faster now. Thanks for the feedback.
>
> DETAILS:
> I am using OpenJDK on the linux platform and Oracle on the windows one;]
>
> I increased the memory of the JAVA processes using memory command line
> options (It think they are...-Xms and Xmx or something...)
> I also stopped processes from updating anything in the GUI, since it seems
> to force a lot of other GUI items to invalidate.
>
> Application is much faster now, and almost the same speed as my previous
> JAVA application and has a fair more complex GUI...
> I will continue to work on it, I think I use far too many
> FazetTableView's(about 9...), so I may need to go through that code and look
> for some efficiencies I can add..
>
> PS-Thanks for the feedback, is probably ok for now;]
> Regards,
> Mark.
> -----Original Message-----
> From: Sandro Martini [mailto:[hidden email]]
> Sent: Wednesday, 26 March 2014 7:15 PM
> To: Users - Apache Pivot
> Subject: Re: Speeding up Apache Pivot For embedded Application
>
> Hi Mark,
>
>> Is there anyway to make sun.awt.GlobalCursorManager$NativeUpdater.run()
> more efficient?
> No (sorry), this class is bundled in rt.jar (the main jar for the JRE), so
> unless you provide a patched JRE I don't think it's possible (assuming from
> a legal point of view it's doable, by the license). And we don't use it
> directly of course ...
> Note that probably this class interacts with Threads, native (OS
> specific) functions and Window Managers and other complex stuff, so anyway
> it would be an hard task. Its source is not in the usual src.zip (in root of
> JDK).
>
> Here an online version of that class (taken from OpenJDK-7):
> http://www.docjar.com/html/api/sun/awt/GlobalCursorManager.java.html
>
>
> Just for curiosity: did you tried with Oracle JDK or Open JDK ? Could you
> try to swap ?
>
>
> Bye,
> Sandro