rootjs: node.js bindings for root 6 - theo beffart, maximilian

16
1 2016-10-10 Marek Szuba et al. Steinbuch Centre for Computing (SCC) RootJS: Node.js Bindings for ROOT 6 Theo Beffart, Maximilian Früh, Christoph Haas, Sachin Rajgopal, Jonas Schwabe, Christoph Wolff, Marek Szuba KIT – The Research University in the Helmholtz Association www.kit.edu

Upload: phamtu

Post on 11-Jan-2017

224 views

Category:

Documents


2 download

TRANSCRIPT

1 2016-10-10 Marek Szuba et al.

Steinbuch Centre for Computing (SCC)

RootJS: Node.js Bindings for ROOT 6Theo Beffart, Maximilian Früh, Christoph Haas, Sachin Rajgopal,Jonas Schwabe, Christoph Wolff, Marek Szuba

KIT – The Research University in the Helmholtz Association www.kit.edu

Background

2 2016-10-10 Marek Szuba et al.

ROOT — scientific software framework from CERNde facto standard tool in particle physicswritten mainly in C++essentially a library of classesintegrated C++ interpreter based on LLVM (ROOT 6)bindings exist for Python, R, Ruby, …

Node.js — high-performance runtime environment for Web applicationsuser code in JavaScriptinternals in C++ — Google V8 enginenon-blocking, asynchronous I/Opopular in modern large-scale systems

Web applications in high-energy physicsnumerous — e.g. data browsers, quality assurance, …back-end processing with ROOT frequently desired

Project Overview

3 2016-10-10 Marek Szuba et al.

RootJS: Node.js bindings for ROOT 6JavaScript access to all ROOT classesinject, JIT-compile and execute C++ macrosdynamically updated stateasynchronous

Native Node.js module written in C++System requirements:

OS supporting ROOT 6tested under Linux, Mac OS X

Node.js 4–6v4 LTS recommended

Use-case Examples

4 2016-10-10 Marek Szuba et al.

Live event viewerImportant for monitoring, basic QATypically, standalone ROOT applicationLimited portability:

needs ROOT and dependencies installedrequires access to data source

Alternative — modern Web application:back-end processing: ROOT, close to detectorfront-end anywhere in the worldonly require a Web browser

Analytics in Web applicationsTake advantage of ROOT in machine learning,statistical analysis, linear algebra, …Gain access to XRootD, PROOF etc.

Use-case Examples

4 2016-10-10 Marek Szuba et al.

Live event viewerImportant for monitoring, basic QATypically, standalone ROOT applicationLimited portability:

needs ROOT and dependencies installedrequires access to data source

Alternative — modern Web application:back-end processing: ROOT, close to detectorfront-end anywhere in the worldonly require a Web browser

Analytics in Web applicationsTake advantage of ROOT in machine learning,statistical analysis, linear algebra, …Gain access to XRootD, PROOF etc.

Related WorkJavaScript ROOT

5 2016-10-10 Marek Szuba et al.

JSROOTWeb clientreimplementationfeature set limited by design:

ROOT graphicsbasic file inputTHttpServer interface

RootJSstandalone, or Web serverwrapperall features of ROOT 6

Highly complementary!Example: Web application with RootJS back-end and JSROOT front-end.

Related WorkJupyter Notebook

6 2016-10-10 Marek Szuba et al.

ROOT in JupyterWeb client and serversophisticated interactiveinterfacenot meant for scripting/batchlimited access to third-partylibraries

but: Python 2 kernel +PyROOT + …

RootJSstandalone, or Web serverno interactive interface (yet)aimed at scripted/batchprocessingfull access to the Node.jsecosystem

Some overlapDifferent context — interactive vs scriptedJupyter + Javascript kernel + RootJS + …

Related WorkJupyter Notebook

6 2016-10-10 Marek Szuba et al.

ROOT in JupyterWeb client and serversophisticated interactiveinterfacenot meant for scripting/batchlimited access to third-partylibraries

but: Python 2 kernel +PyROOT + …

RootJSstandalone, or Web serverno interactive interface (yet)aimed at scripted/batchprocessingfull access to the Node.jsecosystem

Some overlapDifferent context — interactive vs scriptedJupyter + Javascript kernel + RootJS + …

Design Overview

7 2016-10-10 Marek Szuba et al.

RTTICLING | CINT

Basic architecture requirements:dynamic object creation and encapsulationnon-blocking function calls via callbacks

Fundamental language differencesdifferent type systems (dynamic vs static)a functional languageclassless objects, prototype functions

“Need an adapter”software design patternhelp incompatible interfaces work together

Environment:V8 API — object exposure and callback handlingROOT RTTI interface — class, namespace, global andmember variable information

Fulfilment of Requirements

8 2016-10-10 Marek Szuba et al.

provide async call contextbefore forwarding to RTTI API

initcallbackhandling

function calls object access object creation

forward constructor calls

encapsulate construcedobjects for exposure

recursively seek & expose

classes and namespaces

direct access to C++ objects in memory via corresponding proxyobject

JavaScript object

Proxy object

C++ object

entry point for client

interactions with ROOT

Core Architecture

9 2016-10-10 Marek Szuba et al.

initcallbackhandling

function calls object access object creation

FunctionProxyFactory

+ fromArgs()

FunctionProxy

+ call()

ObjectProxy

+ readValue()

+ writeValue()

ObjectProxyFactory

+ createCapsule()

ObjectProxy

- address

TemplateFactory

+ createTmplt()

Core Architecture

10 2016-10-10 Marek Szuba et al.

CallbackHandler

+ onAccess()

Proxy

- address

ObjectProxy

+ read() / write()

FunctionProxy

+ call()

ObjectProxyFactory

+ createCapsule()

NodeHandler

+ exposeROOT()

PrimitiveProxy

TemplateFactory

+ createTmplt()

FunctionProxyFactory

+ fromArgs()

Non-blocking Execution

11 2016-10-10 Marek Szuba et al.

Killer feature of Node.jsRootJS: can add a callback to any exposed functionAsynchronous workersWorker–V8 message passing using libuv

integrates well with Node.jsno need to actively wait for threadsbased on signals — non-blocking, no waste of CPU time

Installation and Invocation

12 2016-10-10 Marek Szuba et al.

We are on npmjs.com — easy!npm install rootjsRequirements: Node.js, npm, C++ compiler, ROOT 6, libuv headersLoaded the standard Node.js way:var root = require('rootjs');All ROOT variables and classes now accessible through rootNeed more libraries? No problem:root.loadlibrary("libMathCore.so"); // load it...root.ROOT.Math.Pi(); // ...and use it!Callback example:root.TFile.Open("foo.root", function (fin) {

fin.ls();});

Infrastructure

13 2016-10-10 Marek Szuba et al.

Source-code repository: Gitprimary: GitHubmirror: CERN GitLabcurrently: ≈4000 lines of code

Issue tracker: GitHubContinuous integration: CERN Jenkins

integration testscode coverageDoxygen documentationcurrently: 90 tests, 76 % line coverage

14 2016-10-10 Marek Szuba et al.

THANK YOU

https://github.com/rootjs/rootjshttps://www.npmjs.com/package/rootjs