Comments about ABNet Design decisions ...

 
Post new topic   Reply to topic    VRMLWorld.net Forum Index -> ABNet2
View previous topic :: View next topic  
Author Message
Rick
Site Admin


Joined: 08 May 2003
Posts: 106
Location: NC, US

PostPosted: Tue Feb 27, 2007 10:12 pm    Post subject: Comments about ABNet Design decisions ...

Recently on the www-vrml mailing list there has been a
converstation on going about alternative language bindings.

Here was my comment:

Quote:
All this talk about speed. There are so many factors
that determine how long something is really going to take.
You can't just make a blanket statement that one
language is going to be N% faster than another.

For what I'm doing, ABNet multiuser 3d server, I have tried
using a variety of methods for sending TCP/IP data over
the Internet. What I've found is that the overhead of leaving
the VRML/HTML browser thread and marshalling data to java
or C is slower that just making javascript calls in many cases.
Of course it all depends on what you are doing.

Here is a simple test. http://vrmlworld.net/perftest/

It is a simple HTML page that includes my ABNet
ActiveX client, my ABNet Java client and a simple
Javascript function. The page has a bunch of buttons
that time how long each method takes. (To run the test above,
you need the ABNet client installed, a working java in
your browser, and Microsoft Internet Explorer).

I created a loop that executes a simple 'version' function 50K
times in each environment. Each function just returns a string.

This test illustrates how much time it takes actually to pass data
from one language specific context to another when using the
HTML browser.

The emptyloop test how long it takes javascript to loop 50k times .. 20 - 30 ms
The Javascript function on my machine runs in 270 ms
ActiveX function takes 1700 ms
Java function takes 11000ms

The javascript is so fast because it probably doesn't even try
to yield the CPU while you execute it.

The ActiveX is fairly fast but it has to the marshall the data from
the COM object to the browser thread. I'm sure each time that
happens, it gives the OS a chance to yield the CPU to someone
else. At least the ActiveX object is just a DLL and running in the
same process as the browser.

The Java is dog slow, why because it has to marshall the calls
across two processes (iexplore.exe and java.exe) make the call
and return the marshalled data. Lots of context switching, process
yield opportunities and data marshalling going on.

I don't think people take in to account how much time is
spent when you switch from one execution thread to another.
This is especially important in VRML browsers when you
are tracking changes to say something like a proximity sensor.
The more frequent the changes,the quicker you need to get the
changed values do something and return.

This is one of the reasons I do a lot of processing using javascript
in the ABNet custom VRML nodes. I think it reduces the number of
process context switches which increases responsiveness. I load
a chunk of VRML with scripts that "preprocess" events using javascript
in the wrl wolrd before trying to notify the HTML browser. Using this
scheme, I can filter the users movement in VRML without having to
switch context to a java, javascript or C++ activex object.

From my experience, the longer you do what you are doing where
you need to do it, the better off you are. Even if that means using
a script language built into the VRML thread you are in.

Any insightful comments from browser developers would be appreciated.

-rick

----- Original Message -----
From: "Martin Channon"
To: "www-vrml" <www>
Sent: Tuesday, February 27, 2007 6:16 PM
Subject: Re: [www-vrml] Speed. (was alternative languages)


> That's bad news, but news I needed. Thanks.
>
> Joshua Smith wrote:
>
> >>> Bottom line: Properly written, there should be no appreciable
> >>> performance differences between algorithms written in Java vs. C.
> >>
> >>
> >>
> >> How about Java/C vs VRML & Java script?
> >
> >
> >
> > Javascript probably runs about 100x slower than (1% as fast as) Java
> > or C.
> >
> > -Joshua
Back to top
fabricator
Forum Junkie


Joined: 10 Jul 2006
Posts: 49

PostPosted: Fri Aug 03, 2007 7:03 pm    Post subject:

I did find one little problem while calling html a javascript function from within a world.

The task switching seemed to cut off strings over a certain length, in practice 300 characters was the limit with an update rate of 0.1 seconds. In other words long strings had to be broken up and re-assembled in the html javascript.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VRMLWorld.net Forum Index -> ABNet2 All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum