Skip to content

Comments

Stop eagerly generating error message for mismatch arguments#8216

Closed
Geod24 wants to merge 2 commits intodlang:stablefrom
Geod24:partially-revert-15613
Closed

Stop eagerly generating error message for mismatch arguments#8216
Geod24 wants to merge 2 commits intodlang:stablefrom
Geod24:partially-revert-15613

Conversation

@Geod24
Copy link
Member

@Geod24 Geod24 commented May 4, 2018

This mostly reverts commit 15b1b503440caab6ba8d2879b80d3946d4d5ac23.

The aforementioned commit eagerly allocated the error message during call resolution,
resulting in a lot of garbage being generated for no reason.
Said garbage was never freed, and freeing it seemingly has no effect,
maybe because of DMD's memory allocation pattern.

Testing here since the testsuite doesn't pass on my machine ¯_(ツ)_/¯
Also, targeting stable because I expect large project to suffer from this a lot.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @Geod24! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "stable + dmd#8216"

@Geod24 Geod24 requested a review from wilzbach May 4, 2018 15:56
@wilzbach
Copy link
Contributor

wilzbach commented May 4, 2018

Testing here since the testsuite doesn't pass on my machine ¯_(ツ)_/¯

Interesting. What error do you get?
Maybe the stack traces without line numbers? (e.g. dlang/druntime#2172)

@Geod24 Geod24 force-pushed the partially-revert-15613 branch 2 times, most recently from bbc7ae3 to 27b747c Compare May 5, 2018 10:12
This mostly reverts commit 15b1b50.

The aforementioned commit eagerly allocated the error message during call resolution,
resulting in a lot of garbage being generated for no reason.
Said garbage was never freed, and freeing it seemingly has no effect,
maybe because of DMD's memory allocation pattern.
@Geod24 Geod24 force-pushed the partially-revert-15613 branch from 27b747c to a44c4fa Compare May 5, 2018 10:41
@Geod24
Copy link
Member Author

Geod24 commented May 5, 2018

It's green :)

@ntrel
Copy link
Contributor

ntrel commented May 6, 2018

This pull degrades error messages significantly. What memory usage do you get with my fix? #7554 (comment)

If my fix is not sufficient, the proper solution would be to usefree and find out why dmd doesn't free memory properly (it could have an alternative strategy that works better withfree, enabled with a new compiler switch for intensive projects). This would greatly help a wider scope of projects besides yours.

@Geod24
Copy link
Member Author

Geod24 commented May 7, 2018

This pull degrades error messages significantly.

But the test suite is passing. Which means the original pull request was significantly lacking tests. I haven't had a chance to test the fix you proposed yet, but I'm definitely not found of this approach.

@JinShil
Copy link
Contributor

JinShil commented May 7, 2018

@ntrel Can you please submit a PR with your suggestion and sufficient coverage?

Copy link
Contributor

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

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

Let's get this into stable as the performance regressions seems is critical.
@ntrel please feel free to submit a follow-up with more test cases. I will open a PR to merge this to master too.


// disambiguate when toChars() is the same
auto at = arg.type.toChars();
bool qual = !arg.type.equals(par.type) && strcmp(at, par.type.toChars()) == 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

"strcmp must die."
(I am aware that this is moved existing code)

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what you're quoting. What should it be replaced with?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what you're quoting.

Walter from DConf and the mailing list.

What should it be replaced with?

== (with D's strings), though that might be a bit difficult to achieve here as still many places lack the ability to use d strings.

@Geod24 Geod24 requested review from dnadlinger and ibuclaw as code owners May 8, 2018 01:11
@wilzbach
Copy link
Contributor

wilzbach commented May 8, 2018

(update the C++ headers)

@wilzbach wilzbach added the Review:stable-priority A regression fix to stable that should receive higher priority label May 8, 2018
@ntrel
Copy link
Contributor

ntrel commented May 8, 2018

@wilzbach This pull mucks up my pull here (which I forgot hadn't been merged). That pull is completely incompatible with just returning a parameter index.

@ntrel
Copy link
Contributor

ntrel commented May 8, 2018

@JinShil I've now submitted #8232. If I have time I might try to improve the test suite.

@Geod24:

I haven't had a chance to test the fix you proposed yet, but I'm definitely not found of this approach

My pull fixes the only case where an error could be allocated and not used. Returning an error string is necessary, otherwise we would have to combine and return various other data besides just a parameter index.

if (failIndex < fargs.dim && failIndex < tf.parameters.dim)
{
auto arg = (*fargs)[failIndex];
auto par = (*tf.parameters)[failIndex];
Copy link
Contributor

Choose a reason for hiding this comment

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

failIndex is the argument index, not parameter, so for typesafe variadics with more than one argument, no supplemental error will be shown. (This could be worked around perhaps). I'll send a PR to test this.

@ntrel
Copy link
Contributor

ntrel commented May 10, 2018

This pull degrades error messages significantly

The only problem I've found is with typesafe variadics - PR for a test against this branch: Geod24#2

@ntrel
Copy link
Contributor

ntrel commented May 19, 2018

BTW #8232 has now been merged. I've also made #8263 (against master for now) which removes 2 temporary allocations and adds the missing typesafe variadic test I mentioned.

@RazvanN7
Copy link
Contributor

Now that @ntrel 's PRs have been merged. Is this needed anymore?

@Geod24
Copy link
Member Author

Geod24 commented May 28, 2018

Now that @ntrel 's PRs have been merged. Is this needed anymore?

Nope

@Geod24 Geod24 closed this May 28, 2018
@Geod24 Geod24 deleted the partially-revert-15613 branch June 26, 2018 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:stable-priority A regression fix to stable that should receive higher priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants