Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace therubyracer with mini_racer #1961

Merged
merged 4 commits into from Apr 20, 2019
Merged

Replace therubyracer with mini_racer #1961

merged 4 commits into from Apr 20, 2019

Conversation

dsander
Copy link
Collaborator

@dsander dsander commented Apr 9, 2017

Initially this PR was created to improve compatibility on ARM(64) devices. Sadly this did not work out, the newer libv8 version still has issues compiling on arm devices.

For all other users the change is a improvement, mini_racer is a lot faster because the libv8 version is newer.

It also fixes a massive memory leak reported in #2512.

#1959

Might help with #1919

@cantino
Copy link
Member

cantino commented Apr 10, 2017

I haven't been following this closely. Would you mind summarizing the main motivation(s) for moving away from therubyracer?

@0xdevalias
Copy link
Member

From my perspective, my biggest motivation is the alpine issue with therubyracer currently. mini_racer has a smaller bind footprint to libv8, so it can be updated to modern versions more easily. Which may come with performance/etc benefits (i'm not too well versed on this area)

I was thinking if it wasn't too hard to support both, maybe there would be some benefit to that. Originally I was thinking execjs might serve as a higher level wrapper to support that, but as @dsander pointed out in #1959 , due to the functions this wouldn't be possible.

@dsander
Copy link
Collaborator Author

dsander commented Apr 10, 2017

It will definitely be faster rubyracers libv8 version is pretty old (3.16 vs 5.3). I am also hoping for better arm support due to the newer libv8 (#1586).

@0xdevalias
Copy link
Member

0xdevalias commented Apr 10, 2017 via email

@dsander
Copy link
Collaborator Author

dsander commented Apr 10, 2017

@alias1 Not very I suppose, what would be the benefit of that?

@0xdevalias
Copy link
Member

I guess I always think in terms of flexibility/options, rather than rigid decisions. So it would be providing the option of using either therubyracer or mini_racer (and perhaps setting a framework for supporting other options that may be available in that sense). It was the original reason I was thinking execjs would make a good choice.

I'm not really strongly set on it though, if you prefer to go the convention over configuration, 'best choice' approach.

@dsander
Copy link
Collaborator Author

dsander commented Apr 11, 2017

Should have checked that earlier, mini_racer requires GCC 4.8 which is not available on debian wheezy. If we want it we need to either drop support for debian 7, wait until the LTS support ends in may 2018 or indeed support both mini_racer and therubyracer. Yay stability 😞

I think we should only pursue this further if it at least solves the ARM 64biy or alpine issues (ideally both).

@0xdevalias
Copy link
Member

While I haven't directly tested it, i'm at least 90% sure this will work for the alpine issue. From my reading, mini_racer runs well on it. I'm unsure about the ARM issue.

My thought process at the moment would be to create a small wrapper class that holds the appropriate context, and exposes eval and function type methods, as well as a general Exception wrapper, and way of determining the proper array/object type for the underlying library.

If we designed the API properly, it could almost be a source compatible drop-in, at least for our use case.

@cantino
Copy link
Member

cantino commented Apr 12, 2017

Ah, got it. As long as mini_racer works for the JS Agent and on our supported platforms, it seems fine to me. It sucks that the_ruby_racer isn't being well supported.

@dsander
Copy link
Collaborator Author

dsander commented Apr 13, 2017

My hesitation is not due to the small wrapper it would require, but more about the needed gcc version detection (I can't imagine parsing the output of gcc -v is enough to work on every platform). Having two different javascript runtimes on different OS will probably also not reduce the required support 😄 .
For me it comes down to the gain for our users (smaller docker image/supporting ARM 64bit) vs the development/maintenance and support burden for us.

@0xdevalias
Copy link
Member

@cantino There is some work on upgrading therubyracer to v4.5, but from the little look i've had it seems like it may still be slow going.

@dsander Haha, yeah, that's fair.. Just increases the surface area for potential issues I suppose :p

If we want it we need to either drop support for debian 7, wait until the LTS support ends in may 2018 or indeed support both mini_racer and therubyracer.

Do we know much around usage/etc. I guess we wouldn't have stats at all.. (on a sidenote, I wonder if there is some benefit to having a 'send basic stats' option on install.. mostly gathering OS/ruby vers/etc to help when deciding around platforms to continue supporting)

Would dropping support for debian 7 be a major hit to users? Could we add both runtimes as an interim 'fallback' measure until LTS ends in 2018, then move it entirely to mini_racer then? My gut feel is that supporting 2 JS runtimes (with one designated as the 'officially supported', and the other deprecated/only supported for legacy systems) wouldn't be a terrible overhead on the maintenance team, and would probably be less impactful than dropping support for an entire OS on users. Thoughts?

@cantino
Copy link
Member

cantino commented Apr 15, 2017

I do think having stats would be nice. I wouldn't want to just add Google Analytics, though, since people like their privacy. Not sure what the best way to add stats in a privacy-respecting way would be.

@dsander
Copy link
Collaborator Author

dsander commented Apr 15, 2017

Having usage statistics would be great, but I don't know how many users would agree to send them.

Unsure about dropping Debian 7 support, as a user I would be very annoyed if a software dropped support for a OS that is still in LTS.

@dsander
Copy link
Collaborator Author

dsander commented Apr 27, 2017

Scaleway release 64bit ARM servers today and I tested the installation of mini_racer. Sadly it did not went to well:

root@scw-874759:/# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial
root@scw-874759:/# uname -ra
Linux scw-874759 4.9.23-std-1 #1 SMP Mon Apr 24 13:18:14 UTC 2017 aarch64 aarch64 aarch64 GNU/Linux
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/ext/libv8
/usr/local/bin/ruby -r ./siteconf20170427-16707-1sv7jvu.rb extconf.rb
creating Makefile
Error: Command '/usr/bin/python v8/build/linux/sysroot_scripts/install-sysroot.py --running-as-hook' returned non-zero exit status 1 in /home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/vendor
Running: gclient root
Running: gclient config --spec 'solutions = [
  {
    "managed": False,
    "name": "v8",
    "url": "https://chromium.googlesource.com/v8/v8.git",
    "custom_deps": {},
    "deps_file": "DEPS",
    "safesync_url": "",
  },
]
'
Running: gclient sync --with_branch_heads
Traceback (most recent call last):
  File "/home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/vendor/depot_tools/fetch.py", line 353, in <module>
    sys.exit(main())
  File "/home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/vendor/depot_tools/fetch.py", line 348, in main
    return run(options, spec, root)
  File "/home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/vendor/depot_tools/fetch.py", line 342, in run
    return checkout.init()
  File "/home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/vendor/depot_tools/fetch.py", line 142, in init
    self.run_gclient(*sync_cmd)
  File "/home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/vendor/depot_tools/fetch.py", line 76, in run_gclient
    return self.run(cmd_prefix + cmd, **kwargs)
  File "/home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/vendor/depot_tools/fetch.py", line 66, in run
    return subprocess.check_output(cmd, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 574, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '('gclient', 'sync', '--with_branch_heads')' returned non-zero exit status 2
/home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/ext/libv8/builder.rb:109:in `block in setup_build_deps!': unable to fetch v8 source (RuntimeError)
	from /home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/ext/libv8/builder.rb:107:in `chdir'
	from /home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/ext/libv8/builder.rb:107:in `setup_build_deps!'
	from /home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/ext/libv8/builder.rb:63:in `build_libv8!'
	from /home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5/ext/libv8/location.rb:24:in `install!'
	from extconf.rb:7:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /home/huginn/huginn/vendor/bundle/ruby/2.3.0/gems/libv8-5.3.332.38.5 for inspection.
Results logged to /home/huginn/huginn/vendor/bundle/ruby/2.3.0/extensions/aarch64-linux/2.3.0-static/libv8-5.3.332.38.5/gem_make.out

An error occurred while installing libv8 (5.3.332.38.5), and Bundler cannot continue.
Make sure that `gem install libv8 -v '5.3.332.38.5'` succeeds before bundling.

@0xdevalias
Copy link
Member

Hrmm, that sucks :(

@dsander
Copy link
Collaborator Author

dsander commented Jul 20, 2017

The latest version of mini_racer works on arm64 now. I will do some more tests but supporting Huginn on Raspberries (and other arm(64) boards/servers) would be really nice.

@knu
Copy link
Member

knu commented Jul 20, 2017

JFYI, Ubuntu 12.04 LTS finally reached its EOL last April. Yay!

@0xdevalias
Copy link
Member

Switching to mini_racer would probably be the unblock I need to get those alpine docker containers finished off too.

@danihodovic
Copy link

danihodovic commented Oct 20, 2018

What is the status of this PR? It would be great to get a more modern version of JS into Huginn.

@dsander
Copy link
Collaborator Author

dsander commented Oct 22, 2018

We should be able to merge this soon. LTS support for debian 7 ended in may, hopefully everybody upgrades their servers by now 😄

@danihodovic
Copy link

We should be able to merge this soon. LTS support for debian 7 ended in may, hopefully everybody upgrades their servers by now smile

Is there any concrete timeline?

@dsander
Copy link
Collaborator Author

dsander commented Oct 23, 2018

Is there any concrete timeline?

Not really, but any testing of this branch or the huginnbuilder docker images is very welcome.

@danihodovic
Copy link

Not really, but any testing of this branch or the huginnbuilder docker images is very welcome.

I'll run the huginnbuilder branch :)

@danihodovic
Copy link

I've been running huginnbuilder/huginn:pr-1961 for a few days using my personal Huginn and it seems to work fine. The only issue for me is that the latest version of libv8 is 6.7 which supports older Ecmascript and not ES6, but I guess there is not much we can do there.

@dsander
Copy link
Collaborator Author

dsander commented Oct 29, 2018

We also need to drop support for Ruby 2.2 on top of Debian 7 because it's not supported by the latest mini_racer version.

@dsander
Copy link
Collaborator Author

dsander commented Apr 19, 2019

Updated the PR description, I think we should merge this soon (Debian 7 and Ruby 2.2 hit their EOL a long time ago).

@dsander dsander requested a review from knu April 19, 2019 14:53
@@ -374,7 +374,7 @@ GEM
actionmailer (>= 3.2)
letter_opener (~> 1.0)
railties (>= 3.2)
libv8 (3.16.14.19)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we finally dumping this ancient version? So great! 😂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we could even go better than that.. mini_racer supports 7.3.x as of this PR

And this looks like they do (or soon will) support 7.4.x

Though this lib is still 7.3.x

With the latest v8 version currently being 7.7.x

@knu knu merged commit 351470a into huginn:master Apr 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants