Giter VIP home page Giter VIP logo

Comments (17)

hainm avatar hainm commented on June 10, 2024

Question: Why do we really need to sync coordinates originally?

from nglview.

hainm avatar hainm commented on June 10, 2024

a proposed PR here: https://github.com/arose/nglview/pull/59/files

normal implementation by syncing coordinates

view = nv.show_pytraj()
view

turn cache on

view.caching()

--> fast

want to sync coordinate again?

view.uncaching()

from nglview.

hainm avatar hainm commented on June 10, 2024

potential: let user to choose specific frames to cache. This is good for pytraj and MDAnalysis out-of-core trajectory/universe. User only need to load coordinates from disk to JavaScript once when caching is called.

from nglview.

hainm avatar hainm commented on June 10, 2024

tried with 13008 atoms (DNA + waters). caching is dramatically faster.

from nglview.

hainm avatar hainm commented on June 10, 2024

New issue: sending 30 MB data from Python to JS via Widget.send is really slow, costs me 16 s. ack.

from nglview.

hainm avatar hainm commented on June 10, 2024

so two seperate issue:

  • how to send a GB of data from Python to JS within seconds?
  • how to use binary data?

for trajectory viewer, non-lagging viewing is important (at least for me).

from nglview.

hainm avatar hainm commented on June 10, 2024

timing: sending list and bytes via Widget.send method

print(traj.xyz.shape, traj.xyz.dtype)

xyz = traj.xyz.flatten()

xyz_list = xyz.tolist()

xyz_bytes = xyz.tobytes()

(100, 5293, 3) float64

%%time
view.send(xyz_list)

CPU times: user 10.2 s, sys: 77 ms, total: 10.3 s
Wall time: 10.3 s

%%time
view.send(xyz_bytes)

CPU times: user 1.73 s, sys: 247 ms, total: 1.98 s
Wall time: 1.95 s

sending bytes is 5 times faster than sending list but still slow (1.95 s for 100 frames, 5293 atoms).

from nglview.

hainm avatar hainm commented on June 10, 2024

from my benchmark, sending a dict of base64 data is 100 times faster than sending a Python list.

I am going this way.

from nglview.

kain88-de avatar kain88-de commented on June 10, 2024

Out of curiosity when you send GB of data from python to js is that data copied?

from nglview.

hainm avatar hainm commented on June 10, 2024

Out of curiosity when you send GB of data from python to js is that data copied?

Yes. But this should not be a problem for out-of-core back-end like MDAnalysis. Coordinates are only copied once when 'caching' is called and those are kept in memory (JS) for fast iteration.

But ideally, I just want Python and Javascript can share memory view, just like Python and C/C++.

from nglview.

kain88-de avatar kain88-de commented on June 10, 2024

You could ask on the jupyter mailing list if they know a method to do that.

from nglview.

hainm avatar hainm commented on June 10, 2024
  • bokeh still have an open issue about DataView ans Python/JS stuff. :D
    bokeh/bokeh#2204

So I guess there is not.

from nglview.

arose avatar arose commented on June 10, 2024

But ideally, I just want Python and Javascript can share memory view, just like Python and C/C++.

That is not going to happen, ever! At least not between a browser and Python. The browser is a sandbox for security reasons, so there will be no memory sharing.

from nglview.

hainm avatar hainm commented on June 10, 2024

That is not going to happen, ever! At least not between a browser and Python. The browser is a sandbox for security reasons, so there will be no memory sharing.

yeah, right. So my work here is still useful. =)) #67

from nglview.

hainm avatar hainm commented on June 10, 2024

@kain88-de @dotsdl I just update MDA support for new data transfer protocol in my new PR.

Let me know if the view play is reasonably fast or not.

PR: #67

should check branch: https://github.com/hainm/nglview/tree/on_msg_f32

That branch includes notebook test for MDA too, just run it.

The speed can be still improved (see @arose comment in that PR).

from nglview.

hainm avatar hainm commented on June 10, 2024

note: if using view.caching() the viewer play is much smoother.

from nglview.

hainm avatar hainm commented on June 10, 2024

done. Problem left is sending binary data.

from nglview.

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.