0

I have a pegjs generated parser that is parsing a dust template of 29kb size. I am trying to execute parsing on this template using nodyn, which in turn, is on dynjs, which in turn is on vertx and that is on the JVM.

When parsing executes on node, it executes in a matter of milliseconds (~200 ms). However when I run the parse on the nodyn/dynjs/vertx/jvm stack, I am getting performance of somewhere between 800 ms per character~!

The problematic functions appear to be the charCodeAt function calls as well as substr calls. The generated parser makes copious calls to both methods and each method can take (it's not always consistent) up to 100 ms to execute.

Can anyone explain why that might be the case? and even better, can anyone provide a solution?

Thank you~!

4
  • Are you really saying that a single call to charCodeAt or substr is taking 100ms? If not, please clarify your Question. Commented Jun 15, 2014 at 2:37
  • Yes I actually am saying that. It is kinda crazy. Commented Jun 15, 2014 at 17:15
  • How are you testing that. Could be due to cold start on JVM. Try repeating the test for say 10,000 times and averaging the result. Commented Jun 15, 2014 at 17:46
  • Logging. I thought it might be the jvm warming up as well so I let it run a while before determining the numbers Commented Jun 15, 2014 at 20:03

1 Answer 1

2

Eric, I cannot say exactly why you are seeing these performance issues; there is not enough information here to go on. But I can tell you that there are a lot of layers in your stack, many of which are fairly new and not in a released state. So I would start by trying to narrow down the list of possible culprits.

For starters, unless your project requires the node.js API I would eliminate nodyn from the stack as it is arguably the most immature of the technologies you are working with. No doubt, it does make using various libraries easier. But I'm pretty sure PEG.js doesn't require any of the Node.js API. You could easily replace the entire nodyn/vertx section of the stack with a single JS file that knows how to deal with NPM modules.

Take a look at https://github.com/nodyn/jvm-npm which you can load in your top level .js file and subsequently have access to NPM packages. To be clear, this doesn't pull in any of the node.js API, but if your project is pure JS then that's OK.

load('./jvm-npm.js');
var peg = require('pegjs');

Next, I would ensure that you are using the latest dynjs snapshot which you can find here: https://oss.sonatype.org/content/repositories/snapshots/org/dynjs/dynjs/. You don't mention what version you are using, but there is ongoing development with dynjs dealing specifically with performance issues. There are some known concerns about how strings are currently handled. If you are using 0.2.2 you may find some relief in the 0.3.0-SNAPSHOT version that is currently available and updated with each new commit.

Finally, for a possible fix and more eyeball time from the core dynjs team, create a simple reproducible example, your best bet is to submit it to https://github.com/dynjs/dynjs/issues. We don't typically monitor Stack Overflow since there's not even a 1.0 release yet (although maybe we should start....). We are very active on IRC in #dynjs and #nodyn, so you might also consider spending some time there chatting with the core team about what you are seeing. We're a pretty open bunch and welcome input from our nascent user base!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.