chakra-core / chakra-core/ChakraCore

Date object is slow

Open
#3,760 5 comments 0 reactions 0 assignees View on GitHub
Node Performance
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

`new Date()` or `new Date( some args here! )` ... are slow.

Regardless from the source, we convert the `Date` to local. -> https://github.com/Microsoft/ChakraCore/blob/release/1.7/lib/Runtime/Library/JavascriptDate.cpp#L231

...and then UTC etc..

Besides, each time we create a string, we go an find out the DST string for the data. We keep DST related value without much reason.

This Branch : https://github.com/obastemur/ChakraCore/tree/fast_date makes `Date` object new instance creation 4 times faster and some memory improvements. Usage of prototype methods are similarly fast (i.e. calling `getDay` etc)

However, it's a quick hack and needs `Windows` side implementation for PlatformAgnostic and some stabilization work.

I did this, in order to measure the effect of `Date` object on AcmeAIR. Well, although it is 4 times faster with this hack.. no gain on AcmeAIR end. Hence, I will left this as a TODO item with the guide branch sitting on my repo.

If `Date` shows up any heat signature on any place, kindly consider this issue and my branch as a kick start. I may also turn back to this though.

Contributor guide

Open the contributing guide

Research direction

Start with lib/Runtime/Library/JavascriptDate.cpp and compare the fast_date branch, focusing on Date construction, local/UTC conversion, and DST-related string work. Review the PlatformAgnostic and Windows implementation needs described in the issue. Done means the optimization is stabilized, implemented for Windows, and its performance and memory effects are measured against the existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript
Domain
compilers, operating-systems, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.