alfio-event / alf.io

alf.io - The open source ticket reservation system for conferences, trade shows, workshops, meetups
https://alf.io
GNU General Public License v3.0
1.39k stars 346 forks source link

Replace Nashorn #956

Closed cbellone closed 3 years ago

cbellone commented 4 years ago

Introduction

Alf.io has an Extension engine, which allows organizers to hook additional logic to defined events, and therefore integrate the ticket selling process to their existing infrastructure. One example of this is the integration with a CRM tool: upon confirmation of a reservation, the organizers want to insert/update the contact data of their attendees, in order to send them mailing lists and so on.

At the moment Alf.io uses the Nashorn engine to do this, so extensions must be written in JavaScript. Pros:

Cons:

We are evaluating the Rhino (https://github.com/mozilla/rhino) javascript engine as a possible replacement.

As a condition for letting an arbitrary user implement his own scripts, we need to ensure that:

  1. they can call only an “allow-list” of methods
  2. execution time must be bounded
  3. The task consists of evaluating and implementing the sandboxed environment.

Subtasks

Evaluate current availability of a java embeddable Javascript engine.

Proposals:

Evaluate alternative replacement

As another option, evaluate the possibility to define a small subset of an existing language, implement the parser and runtime (e.g. like micropython, where they have re-implemented the python language and runtime for their specific requirements).

General Criteria for the evaluation

Proposed initial steps

Graal

mejrima commented 4 years ago

Graal:

Rhino:

syjer commented 4 years ago

for the footprint:

I think the simplest way to evaluate it, is to create a new empty project that include rhino or graaljs with the main that execute a simple script and generate a "fat jar": https://www.baeldung.com/gradle-fat-jar .

This will create a single archive file which include all the dependencies.

mejrima commented 4 years ago

Footprint Rhino: 1.6 MB Footprint Graal: 24.2 MB It is a very big difference.. I hope I did it correctly

syjer commented 4 years ago

I think it's correct :).

Some time ago (~1 year) I did a quick check (by following the biggest dependencies on https://repo1.maven.org/maven2/org/graalvm/js/js/20.2.0/ ) and I was around 20-30mb, so thank you for confirming my impression :+1: