Skip to content

Report "duplicated mapping key" errors at start of block#327

Merged
puzrin merged 1 commit intonodeca:masterfrom
SmartBear:master
Feb 3, 2017
Merged

Report "duplicated mapping key" errors at start of block#327
puzrin merged 1 commit intonodeca:masterfrom
SmartBear:master

Conversation

@shockey
Copy link
Copy Markdown
Contributor

@shockey shockey commented Feb 3, 2017

Resolves #243.

Here, we're storing the starting line and position of a block in readBlockMapping, then handing that information to storeMappingPair so it can update the state with that information if it encounters a duplicated key error related to that block.

@puzrin
Copy link
Copy Markdown
Member

puzrin commented Feb 3, 2017

I have some comments:

  1. No need to include dist/* to PR
  2. Tests needed (with duplicated nested keys too)
  3. storeMappingPair is called not with different sets of params. Need to check benchmarks before and after changes.

@shockey
Copy link
Copy Markdown
Contributor Author

shockey commented Feb 3, 2017

@puzrin I added tests! 😎

Can you elaborate on what you mean in your third point?

@puzrin
Copy link
Copy Markdown
Member

puzrin commented Feb 3, 2017

Can you elaborate on what you mean in your third point?

JIT can deoptimize functions if they are not monomorphic. Here is good reading http://mrale.ph/.

So, it worth to check, if you change did not slowed down anything. Run ./benchmark/benchmark.js.

If you see that things become bad, try to add , 0, 0 to end of all storeMappingPair calls.

@shockey
Copy link
Copy Markdown
Contributor Author

shockey commented Feb 3, 2017

Hey @puzrin, thanks for clarifying.

I ran the benchmark tests before and after my commits, here's the results: https://www.diffchecker.com/Y3Idvbal

@puzrin
Copy link
Copy Markdown
Member

puzrin commented Feb 3, 2017

Looks similar. Difference can be caused by noise.

Can i ask you do one more thing? Could you change other calls to storeMappingPair(..., 0, 0) and compare benchmarks again? I don't like such change, because it looks dirty, but speed make sense. Make sure to close other programs and run twice to check if difference is real or just a noise.

PS. Please, squash your commits into one, i think this PR is valuable enougth and my fantasies about speed should not delay merge :)

@shockey
Copy link
Copy Markdown
Contributor Author

shockey commented Feb 3, 2017

Yes! I'll change the calls to storeMappingPair(..., null, null) instead, because the logic for falling back to what's in state needs a falsy value to kick in.

Edit: here's the logic I'm taking about

@shockey
Copy link
Copy Markdown
Contributor Author

shockey commented Feb 3, 2017

Here's the benchmarks where the number of arguments is constant across the library:

https://www.diffchecker.com/8UMWNP3m

@shockey
Copy link
Copy Markdown
Contributor Author

shockey commented Feb 3, 2017

Also, GitHub now has a way to squash pull requests when you merge on GitHub. Maybe that will help?

Otherwise, let me know and I can rebase my branch 😎

@puzrin
Copy link
Copy Markdown
Member

puzrin commented Feb 3, 2017

Here's the benchmarks where the number of arguments is constant

Equal number of arguments is not enougth. Those should be of the same type in all calls, and typeof null !== typeof 0.

As alternative, i'd suggest to pass (..., -1, -1) and change condition to (if >= 0)

@puzrin
Copy link
Copy Markdown
Member

puzrin commented Feb 3, 2017

You can just squash commits and i'll merge result as is. It's ok for me. I can test benchmarks myself to save your time.

@puzrin
Copy link
Copy Markdown
Member

puzrin commented Feb 3, 2017

Otherwise, let me know and I can rebase my branch

I tried to use github's squash somewhere and don't like garbaged comments it does. So, prefer manual rebase. Please, do it, if not difficult :)

@shockey
Copy link
Copy Markdown
Contributor Author

shockey commented Feb 3, 2017

Done 🎉

@shockey
Copy link
Copy Markdown
Contributor Author

shockey commented Feb 3, 2017

Do you mind doing an npm publish once this gets merged? We'd love to start using this fix ASAP

@puzrin
Copy link
Copy Markdown
Member

puzrin commented Feb 3, 2017

LOL. Rebased commit message contains lines i wished to avoid :). I mean second one and below (github adds the same on squash). Could you remove those and leave only first one?

Do you mind doing an npm publish once this gets merged? We'd love to start using this fix ASAP

If that's not deadly critical, i'd like to take a pause for 2 days (not more).

@shockey
Copy link
Copy Markdown
Contributor Author

shockey commented Feb 3, 2017

^ There's a one-line commit message 👍

@puzrin puzrin merged commit 686fa0b into nodeca:master Feb 3, 2017
@puzrin
Copy link
Copy Markdown
Member

puzrin commented Feb 7, 2017

Published. Thanks for PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants