Home » Eclipse Projects » Remote Application Platform (RAP) » New JSON protocol doubled the traffic on GC/draw2d painting
New JSON protocol doubled the traffic on GC/draw2d painting [message #879208] |
Wed, 30 May 2012 18:56 |
Xihui Chen Messages: 35 Registered: June 2011 |
Member |
|
|
For example, the new JSON code for drawing a label is:
{
"meta": {
"requestCounter": 7421
},
"operations": [ [ "call", "gc55", "init", {
"height": 1036,
"font": [ [ "Verdana", "Lucida Sans", "Arial", "Helvetica", "sans-serif" ], 14, false, false ],
"width": 1586,
"fillStyle": [ 240, 240, 240, 255 ],
"strokeStyle": [ 74, 74, 74, 255 ]
} ], [ "call", "gc55", "draw", {
"operations": [ [ "beginPath" ], [ "rect", 0.0, 0.0, 1586.0, 1036.0 ], [ "fill" ], [ "beginPath" ], [ "rect", 0.0, 0.0, 1586.0, 1036.0 ], [ "fill" ], [ "fillStyle", [ 183, 239, 251, 255 ] ], [ "beginPath" ], [ "rect", 339.0, 727.0, 198.0, 35.0 ], [ "fill" ], [ "strokeStyle", [ 0, 0, 0, 255 ] ], [ "strokeText", "4.775 a.u.", false, true, true, 341.0, 735.0 ], [ "strokeStyle", [ 255, 0, 0, 255 ] ], [ "lineWidth", 2 ], [ "beginPath" ], [ "rect", 340.0, 728.0, 196.0, 33.0 ], [ "stroke" ] ]
} ], [ "call", "w1", "measureStrings", {
"strings": [ [ -746581837, "4.775 a.u.", [ "Verdana", "Lucida Sans", "Arial", "Helvetica", "sans-serif" ], 14, false, false, -1, false ] ]
} ] ]
}
The old protocol is:
var req = org.eclipse.swt.Request.getInstance();req.setRequestCounter( "30" );var wm = org.eclipse.swt.WidgetManager.getInstance();var w = wm.findWidgetById( "w34" );var gc = w.getGC();gc.init( 1444, 1003, "12px Verdana, 'Lucida Sans', Arial, Helvetica, sans-serif", "#ffffff", "#4a4a4a" );gc.drawRectangle( 0, 0, 1444, 1003, true );gc.setProperty( "background", "#90ee90" );gc.drawRectangle( 20, 32, 116, 20, true );gc.setProperty( "foreground", "#000000" );gc.setProperty( "font", "10px Verdana" );gc.drawText( "79,261.000 a.u.", 37, 36, false );gc.setProperty( "foreground", "#ff8000" );gc.setProperty( "lineWidth", 2 );gc.drawRectangle( 21, 33, 114, 18, false );
The new JSON protocol has 977 characters and old protocol has 666 characters. It looks like the new protocol transferred more information than old protocol. And it unnecessarily format integer to 123.0. I'm not sure if it is due to the upgrade on draw2d/GEF or simply because of JSON format. Is that possible to simplify the JSON format?
[Updated on: Wed, 30 May 2012 18:57] Report message to a moderator
|
|
| |
Re: New JSON protocol doubled the traffic on draw2d painting [message #879622 is a reply to message #879459] |
Thu, 31 May 2012 14:33 |
Xihui Chen Messages: 35 Registered: June 2011 |
Member |
|
|
Hi Tim,
Thank you for explaining that! Yes, the example I posted here is 150%, but for complicated draw2D widgets as in attached screenshot, it is about 200%. Its traffic is around 650KB/S on RAP 1.4.1 and 1.3MB/S on RAP 1.5M7. I also attached the message details. With http compression, the text message can be compressed to 6:1, so the traffic could not be a big problem. If the new protocol is more efficient for client to parse, it may get a better performance overall. I didn't mean to criticize the new protocol. I know it has lots of advantages. I just hope it can be improved to have a shorter length. For example, removing all white spaces could save about 1/5 length.
Thanks,
Xihui
[Updated on: Thu, 31 May 2012 18:39] Report message to a moderator
|
|
|
Re: New JSON protocol doubled the traffic on draw2d painting [message #880297 is a reply to message #879622] |
Fri, 01 June 2012 19:45 |
|
Hi Xihui,
I'm totally stunned by what you're doing with the *experimental* GEF
component. Looking at your example, this rendering involves 15,686 (!)
GC operations. You're not only drawing charts, you also draw your
toolbar and buttons, don't you?
We have always pointed out that a high performance Draw2D for RAP is
possible, but it requires a different implementation that bypasses the
SWT API and directly passes vector data to the client GC. This is not a
simple task, it will probably involve months of work.
The current GEF component in the RAP Incubator is not designed for this
ammount of data. If it works for you, you're lucky, but the problem with
your approach is not the protocol. It's the amount of GC operations
needed to draw these charts.
Regards, Ralf
--
Ralf Sternberg
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
| |
Goto Forum:
Current Time: Wed Apr 17 20:19:01 GMT 2024
Powered by FUDForum. Page generated in 0.03049 seconds
|