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

improve package.json parsing performance #18218

Closed
jrieken opened this issue Jan 6, 2017 · 2 comments
Closed

improve package.json parsing performance #18218

jrieken opened this issue Jan 6, 2017 · 2 comments
Assignees
Labels
Milestone

Comments

@jrieken
Copy link
Member

jrieken commented Jan 6, 2017

I have made the below modification to the ExtensionManifestParser and it seems that the general performance of our JSON in comparing to the native JSONparse is OK'ish there are cases in which it is very bad. For instance parsing css/package.json takes 0.3ms using JSON.parse it takes 8ms using our parser. Other larger json files show similar behaviour.

screen shot 2017-01-06 at 11 26 02

let t1 = process.hrtime();
const extensionDescription = json.parse(manifestContents.toString(), errors);
let d = process.hrtime(t1);
let D1 = (d[0] * 1e9 + d[1]) / 1e6;

let t2 = process.hrtime();
JSON.parse(manifestContents.toString());
let d2 = process.hrtime(t2);
let D2 = (d2[0] * 1e9 + d2[1]) / 1e6;

console.log(`PARSE + ${this._absoluteManifestPath} took ${D1}ms, NATIVE ${D2}ms`);
@jrieken
Copy link
Member Author

jrieken commented Jan 6, 2017

Assigning @aeschli to see if there is something low hanging that can be improved and @sandy081 to check if we can get away with stripping comments and using JSON.parse

@sandy081 sandy081 added this to the January 2017 milestone Jan 6, 2017
@aeschli
Copy link
Contributor

aeschli commented Jan 7, 2017

Comments are not valid in package.json. We can use the native json.parser. The only difference is that our implementation is fault tolerant, but IMO that's not important here.
I had a quick look at our parser implementation and also improved it slightly, but it's unlikely that we can match the native implementation.

@aeschli aeschli changed the title json parser performance issues improve package.json parsing performance Jan 7, 2017
@aeschli aeschli closed this as completed in 3a67f92 Jan 7, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants