Comments (4)
We are currently working on a native implementation of TextEncoder. So that will be much faster soon.
from hermes.
Hermes is an interpreter optimized for very fast startup and small binary size. You are comparing it against JSC, which is a type specializing JIT. At a steady state, given enough time to warm up, a JIT will always have a perf advantage. So, this is expected.
I extracted the benchmark from your code:
function testConvert1() {
const startTime = Date.now();
const byteArray = new Uint8Array(10000000);
for (let n = 0; n < byteArray.length; n++) {
}
print("ExecutionTime = ", Date.now() - startTime);
}
This code, a tight array loop that does nothing, is particularly advantageous for a JIT. A JIT could legitimately optimize out the entire loop, bringing the time down to 0. By comparison, the JIT will have much harder time optimizing multiple small routines with allocations, etc.
If we modify the code to actually do something, and keep the typed array length in a variable to avoid fetching it all the time, we get this:
function testConvert2() {
const startTime = Date.now();
const byteArray = new Uint8Array(10000000);
let sum = 0;
for (let n = 0, len = byteArray.length; n < len; n++) {
sum += byteArray[n];
}
print(sum, "ExecutionTime = ", Date.now() - startTime);
}
I ran this code with Hermes, v8 and JSC, with their JITs on and off:
- hermes 104 ms
- v8 --jitless 179 ms
- jsc --useJIT=0 116 ms
- v8 10 ms
- jsc 10 ms
As an interpreter, Hermes is currently on par in performance and often has an advantage.
With all that said, we realize that there are situations where more performance is needed, and Hermes is unable to serve them well. That's why we are working on Static Hermes, which will be much faster.
Running the same benchmark with Static Hermes currently takes 14ms, so we are very close and keep improving.
from hermes.
Ok, understood, thx for answer. There's also some other performance differences I've noticed, I posted it in react-native project but they said I should look into library's authors, altho I think issue is with some of the low-level api's.
I was looking at TextEncoder(from 'text-encoding' lib) and cheerio(jQuery) performace, and saw they perform much worse on React Native compared to webview/NodeJS and about as twice worse on Hermes compared to JSC.
TextEncoder in my example(on 100kb input) takes ~170 ms, while webview takes 1-2 ms (both Android and iPhone) and NodeJS takes 14 ms (I suppose it has to do something with WebAPI optimizations).
Another case, cheerio(JQuery) performance -when I try to perform some HTML manipulation via cheerio, I also saw big hit if compared to other platforms:
RN With Hermes(Redmi note 9): 3500 ms
RN JSC(Redmi note 9): 1700 ms
Android Webview(Redmi note 9): 150-200 ms
iOS Webview(iphone XR): 90 ms
NodeJS(Mac mini 2018): 150 ms
from hermes.
I am now trying to workaround the TextEncoder via JSI/Golang and if it goes well then might attempt to do same with cheerio, altho that one might be bulky.
from hermes.
Related Issues (20)
- I hope it was possible for Static Hermes to native AOT compile all the existing NPM modules. HOT 1
- Intl.DateTimeFormat does not support 'Europe/Kyiv' timezone HOT 2
- It would be good for Static Hermes if it could use pure JavaScript code(that has no type annotations) with automatic type guessing like "var" code in Dart, or ":=" in Go. HOT 7
- Using Intl with standalone Hermes app HOT 2
- Support for top level await HOT 1
- iphoneos framework very large size issue (build-apple-framework.sh) HOT 7
- [Debugger] Incorrect scope variable information for variable initialized in for-loop HOT 3
- Race Condition between HadesGC and HermesInternal.getEpilogues() Causes Segfault
- Assertion `IDom && "Reached the top of the tree!"' failed in ./hermes/lib/Optimizer/Scalar/Mem2Reg.cpp HOT 1
- prettier plugin: Infinite loop for malformed graphql relay query
- Closures caputure external variable errors HOT 9
- [Profiler] First sample sometimes has timestamp of zero HOT 1
- The Code Sentry scan reports code vulnerabilities - facebook/hermes HOT 2
- Short-hand methods don't have prototype / construct HOT 8
- Linking static hermes HOT 4
- spread arguments throw "constructor not callable" when `Array` variable declared HOT 1
- `atob` is less forgiving with padding than JSC, Node and browser based implementations HOT 3
- Partial async generator support persent in Hermes isn't spec compliant HOT 2
- Support for Async/Await and Promise with JSI API HOT 2
- Support for import/export at runtime HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hermes.