Skip to content

use a separate message for show_goto_functions() for the console #3165

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

Merged
merged 6 commits into from
Oct 17, 2018

Conversation

kroening
Copy link
Member

@kroening kroening commented Oct 14, 2018

Rationale: the messages are output into a string buffer, which does not
scale well in case there are many functions. Output can be delayed
substantially.

  • Each commit message has a non-empty body, explaining why the change was made.
  • My contribution is formatted in line with CODING_STANDARD.md.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Code duplication isn't great, and with the further changes in this PR we actually have two bits of code that generate almost, but not exactly the same output anymore.

}
else
{
goto_functions.output(ns, msg.status());
msg.status() << messaget::eom;
auto &out = msg.status();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this just makes the code harder to read, but if it is used then it should be used consistently below.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, fixed

{
if(fun.second.body_available())
{
out << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it's a good idea to have code duplication - couldn't this also be fixed within goto_functionst::output? Else, that method should be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

It can't be fixed without changing the signature -- contemplating to remove.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Removing might be the best solution. Code that is almost duplicated is the prone to cause trouble.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@tautschnig tautschnig assigned kroening and unassigned tautschnig Oct 14, 2018
@tautschnig
Copy link
Collaborator

As side note: it might be time to factor out a number of commits into PRs of their own. Both discussion and CI failure will likely just hold up a number of commits that are 1) very useful for follow-up work and 2) are easy to merge.

@kroening
Copy link
Member Author

#3166 !

@kroening kroening force-pushed the goto_functions_message branch from 955959c to 73558e5 Compare October 14, 2018 20:35
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

This PR failed Diffblue compatibility checks (cbmc commit: 73558e5).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/87894799
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

Rationale: the messages are output into a string buffer, which does not
scale well in case there are many functions.  Output can be delayed
substantially.
@kroening kroening force-pushed the goto_functions_message branch from 73558e5 to ae313b1 Compare October 15, 2018 14:30
@kroening kroening force-pushed the goto_functions_message branch from ae313b1 to e6c46fa Compare October 15, 2018 14:37
@kroening kroening assigned tautschnig and unassigned kroening Oct 15, 2018
Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Some more debate plus the note that an overly long line breaks CI.

{
out << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n";
msg.status() << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n";

const symbolt &symbol = ns.lookup(fun.first);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this line be removed as it is now redundant?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean because of the colouring?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, because of the refactoring in "consolidate the two variants of show-goto-functions".

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry, the line was unclear -- yes, redundant, yes, removed

@@ -51,9 +53,19 @@ void show_goto_functions(

case ui_message_handlert::uit::PLAIN:
{
// sort alphabetically
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this only done in the PLAIN output? It might make the most sense for that case, but then at least the commit message should be clear about that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, will sort all

{
const symbolt &symbol = ns.lookup(fun.first);
const symbolt &symbol = ns.lookup(f_id);
const auto &fun = *goto_functions.function_map.find(f_id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We've had all sorts of debates about performance and sorting: in keeping with this, shouldn't this lookup be avoided by using a vector that includes n iterator, and using a custom comparison operator?

Copy link
Member Author

Choose a reason for hiding this comment

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

Now in a separate function where this can be tweaked further if need be.

@tautschnig tautschnig assigned kroening and unassigned tautschnig Oct 16, 2018
@kroening kroening force-pushed the goto_functions_message branch from e6c46fa to 71eb7b2 Compare October 16, 2018 12:58
@kroening kroening assigned tautschnig and unassigned kroening Oct 16, 2018

const auto sorted = goto_functions.sorted();

for(const auto function_entry : sorted)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor note: here (and also in the XML case) this should likely be a const auto &. It's just an iterator so not terribly expensive to copy, but it's being done in the PLAIN case and would thus at bare minimum ensure consistency.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd be tempted to remove the & in the PLAIN case. References to iterators are unusual; copying them is very common.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have no strong opinion either way, just consistency is what I'd call for.

@tautschnig tautschnig removed their assignment Oct 16, 2018
@kroening kroening force-pushed the goto_functions_message branch 4 times, most recently from 21d5d8d to a484b8b Compare October 16, 2018 16:30
@kroening kroening force-pushed the goto_functions_message branch from a484b8b to 4fcde9a Compare October 16, 2018 17:26
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

Passed Diffblue compatibility checks (cbmc commit: 4fcde9a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88158804

@kroening kroening merged commit 8321a10 into develop Oct 17, 2018
@kroening kroening deleted the goto_functions_message branch October 17, 2018 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants