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

Perf of dereference is unstable #17

Merged
merged 3 commits into from
Mar 5, 2021
Merged

Perf of dereference is unstable #17

merged 3 commits into from
Mar 5, 2021

Conversation

P0lip
Copy link

@P0lip P0lip commented Feb 10, 2021

@P0lip P0lip added the bug Something isn't working label Feb 10, 2021
@P0lip P0lip added this to the 2021-02-02 milestone Feb 10, 2021
@P0lip P0lip requested review from marbemac and a team February 10, 2021 18:40
@P0lip P0lip self-assigned this Feb 10, 2021
let dereferenced;
let result = {
value: obj,
circular: false
};

if (options.dereference.circular === "ignore" || processedObjects.indexOf(obj) === -1) {

Choose a reason for hiding this comment

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

Wait, so you fixed the performance by removing protection against circular references?

Copy link
Author

Choose a reason for hiding this comment

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

Nope!
It's just a redundant check that didn't seem to have any actual impact on perf.

https://github.com/stoplightio/json-schema-ref-parser/blob/55dee7ed978b734a1fd354e01197236b3eaa106c/lib/dereference.js#L108L126 is what actually made impact. That added check didn't contribute.

For a context this is the change I'm talking about 5c3eece
I just didn't notice options.dereference.circular === "ignore" || processedObjects.indexOf(obj) === -1) changing anything so I reverted to the initial version of this code (prior to the aforementioned commit)

Copy link
Author

Choose a reason for hiding this comment

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

We may potentially just use a bit more conservative change that was implemented here APIDevTools#212
It only swapped arrays with sets, but this already mitigated the perf cliff.

@P0lip
Copy link
Author

P0lip commented Mar 3, 2021

https://github.com/stoplightio/platform-internal/issues/5517 reminded me about this
Since the $ref has mid in it, and masking = dereferenced output, they might be encountering this issue.
This would actually align with what Em said in the linked ticket - the whole process took a bit over a minute in case of the file he dealt with.

@chohmann
Copy link

chohmann commented Mar 3, 2021

@P0lip if https://github.com/stoplightio/platform-internal/issues/5517 is caused by this, can I assign that ticket to you guys?

Copy link

@domagojk domagojk left a comment

Choose a reason for hiding this comment

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

It looks good. If it was a redundant check then can't complain about removing it :)
Just remove a jsdoc comment for processedObjects, but it's approve from me 👍

lib/dereference.js Show resolved Hide resolved
@P0lip P0lip enabled auto-merge (squash) March 5, 2021 13:37
@P0lip P0lip disabled auto-merge March 5, 2021 14:12
@P0lip P0lip merged commit 40b4bdd into master Mar 5, 2021
@P0lip P0lip deleted the slower-dereference branch March 5, 2021 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants