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

Use '>>' instead of '> >' to close nested templates. #420

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bangerth
Copy link
Contributor

The latter form had been necessary before C++11, but has been allowed since C++11.

@codecov
Copy link

codecov bot commented Apr 26, 2022

Codecov Report

Merging #420 (2bd136a) into main (4d33def) will not change coverage.
The diff coverage is 95.91%.

❗ Current head 2bd136a differs from pull request most recent head 6762c91. Consider uploading reports for the commit 6762c91 to get more accurate results

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #420   +/-   ##
=======================================
  Coverage   99.50%   99.50%           
=======================================
  Files          86       86           
  Lines        5038     5038           
=======================================
  Hits         5013     5013           
  Misses         25       25           
Impacted Files Coverage Δ
source/types/segment.cc 97.29% <ø> (ø)
...features/subducting_plate_models/grains/uniform.cc 97.61% <50.00%> (ø)
source/parameters.cc 99.65% <94.11%> (ø)
app/main.cc 99.26% <100.00%> (ø)
...eatures/continental_plate_models/grains/uniform.cc 100.00% <100.00%> (ø)
source/features/fault.cc 99.63% <100.00%> (ø)
source/features/fault_models/grains/uniform.cc 100.00% <100.00%> (ø)
source/features/interface.cc 97.82% <100.00%> (ø)
...rce/features/mantle_layer_models/grains/uniform.cc 100.00% <100.00%> (ø)
...ce/features/oceanic_plate_models/grains/uniform.cc 100.00% <100.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d33def...6762c91. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Apr 26, 2022

Benchmark Main Feature Difference (99.9% CI)
Slab interpolation simple none 1.250 ± 0.042 (s=355) 1.253 ± 0.044 (s=367) -0.7% .. +1.0%
Slab interpolation curved simple none 1.186 ± 0.004 (s=384) 1.187 ± 0.004 (s=377) -0.0% .. +0.1%
Spherical slab interpolation simple none 1.636 ± 0.005 (s=283) 1.635 ± 0.004 (s=270) -0.1% .. +0.1%
Slab interpolation simple curved CMS 1.278 ± 0.006 (s=349) 1.278 ± 0.005 (s=357) -0.1% .. +0.1%
Spherical slab interpolation simple CMS 2.019 ± 0.021 (s=214) 2.021 ± 0.022 (s=234) -0.2% .. +0.4%
Spherical fault interpolation simple none 1.908 ± 0.066 (s=238) 1.918 ± 0.069 (s=235) -0.5% .. +1.6%
Cartesian min max surface 3.534 ± 0.039 (s=131) 3.545 ± 0.022 (s=126) -0.0% .. +0.7%
Spherical min max surface 9.559 ± 0.043 (s=52) 9.568 ± 0.037 (s=45) -0.2% .. +0.4%

Copy link
Member

@MFraters MFraters left a comment

Choose a reason for hiding this comment

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

Yes, that look better, thanks!

There are a few places which had double > >, so could you change those as well (I am assuming you did a find and replace)? Also, please indent.

@bangerth
Copy link
Contributor Author

So done!

std::vector<Point<2> >
Parameters::get_vector(const std::string &name)
std::vector<Point<2>>
Parameters::get_vector(const std::string &name)
Copy link
Member

Choose a reason for hiding this comment

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

What is going on here? Is this caused by astyle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we have these places in ASPECT as well. astyle thinks that the >> is a right-shift operator and indents accordingly. That's because astyle is a pre-C++11 tool.

I'm working on a patch for ASPECT to make astyle work with this more gracefully, but for the moment you'd have to live with this.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, my main goal with the current styling is to remain in line with aspect, so if geodynamics/aspect#4562 is merged, I will be happy to merge this as well.

Would it not be easier to just update to Astyle 3.1, since that supports c++11 (http://astyle.sourceforge.net/news.html), although I didn't test whether it does this correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We tried this out a while ago and it led to many other changes. I think that using astyle 3.1 would probably be the right choice, but it means that everyone who is working on ASPECT or WorldBuilder would have to update their local version of astyle to continue working. It's a hassle. It might be interesting to know how extensive the changes would be, and whether that would lead to benefits worth the pain.

Copy link
Member

Choose a reason for hiding this comment

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

We tried this out a while ago and it led to many other changes.

Do you remember if it was just different or if there was stuff which you disagreed with and would require a lot of tweaking?

I think that using astyle 3.1 would probably be the right choice, but it means that everyone who is working on ASPECT or WorldBuilder would have to update their local version of astyle to continue working.

I personally do not really see this as a major issue. You already have to download a manual zip for every install, now you need a different one, once per machine if you develop on that machine. So it is something all developers already know how to do. It may make it even easier since 3.1 is the latest version since 2018, this is the one which is in all package managers. So it would actually make installation much easier (until 3.2 or 4 comes out of course, but their update schedule doesn't seems to be very high frequency).

I think we discussed that after the next aspect release we may do another major version increase. That would be a good moment to do such a switch if we would want to.

I can maybe try tonight to use astyle 3.1 for both the world builder and aspect and make a pull request out of it, so we can discuss the differences (that should be 10 minutes work I think). Would that be useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't recall that there were changes in indentation I actually disagreed with. We tried this with deal.II first, but in the end decided that it was just too much to ask everyone to upgrade for a relatively small benefit. Of course, there is a much larger developer base for deal.II than for ASPECT or WorldBuilder, and consequently the number of people who would have been impacted is also much larger.

One of the major issues is that when you make such a switch, every pending patch becomes invalid because if you merge it, the combined version no longer satisfies the indentation check in the CI. So you can't merge any patches that originated from before the switch. That, too, is very painful if you're on a project like deal.II that merges ~10 patches per day, many of which are rooted in a commit that predates the switch.

I think it would be much easier to do this for ASPECT than for deal.II, but it still comes with substantial pain in view of the fact that we have ~85 pending patches.

Copy link
Member

Choose a reason for hiding this comment

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

hmm, I don't see why any patch would immediately become invalid, unless the differences between the different astyle versions are affecting a very large percentage of the line numbers, since otherwise it is just a patch as any which may or may not have some merge conflict which needs to be resolved. Am I missing something here or are the difference that big?

I can see a problem if deal.ii aspect and world builder are not using the same version of astyle though, for the people who are developing more than one of those three, because you would have to point to the right astyle for each project. But if I understand correctly, deal.ii is now use clang, so that leaves aspect and the gwb to make their own decision. Like I said before, the gwb will follow what aspect does, but since I was interested in what the difference was, I made pull request #421, and the amount of line changes for the gwb doesn't seem that big. That may be different for aspect of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Think about this case:

  • Commit A uses astyle 2.04
  • You build a branch B on commit A where you implement a new feature. It uses astyle 2.04 for indentation, and you need to use 2.04 because otherwise your branch would contain a lot of unrelated changes.
  • The project switches over to astyle 3.1. It commits patches that change the entire code base over to 3.1.
  • Because this changes essentially the entire code base, your branch can no longer be merged easily because there are merge conflicts all over the place.

There is a variation where the switch from astyle 2.04 to 3.1 does not change nearly everything:

  • Your patch then still applies without running into merge conflicts.
  • So it gets merged. But there are parts of your code base that were developed with astyle 2.04 rather than 3.1, and so the indentation of the merged code does not conform to the style the project wants.
  • This means that after the merge, the main branch no longer passes the indentation check. As a consequence, everyone who then takes main, changes a couple of lines somewhere, and then creates a pull request, will then be tripped up by the CI check testing the indentation: The indentation check fails, but not because of changes in the actual PR, but in the code that was merged previously.

I hope you see that that creates issues. None that aren't insurmountable, but it's not easy to deal with this in practice if indentation is one of the CI checks.

Copy link
Member

Choose a reason for hiding this comment

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

Think about this case:

* Commit A uses astyle 2.04

* You build a branch B on commit A where you implement a new feature. It uses astyle 2.04 for indentation, and you need to use 2.04 because otherwise your branch would contain a _lot_ of unrelated changes.

* The project switches over to astyle 3.1. It commits patches that change the entire code base over to 3.1.

* Because this changes essentially the entire code base, your branch can no longer be merged easily because there are merge conflicts all over the place.

Yes, I agree that if the indentation change would change nearly every line, it would be a significant issue. You would definitely need to rebase and you will get a lot of merge conflicts. Although this would only be for source code related pull request, any documentation pull requests or adding/changing of tests pull request would not be affected.

There is a variation where the switch from astyle 2.04 to 3.1 does not change nearly everything:

* Your patch then still applies without running into merge conflicts.

* So it gets merged. But there are parts of your code base that were developed with astyle 2.04 rather than 3.1, and so the indentation of the merged code does _not_ conform to the style the project wants.

* This means that after the merge, the `main` branch no longer passes the indentation check. As a consequence, everyone who then takes `main`, changes a couple of lines somewhere, and then creates a pull request, will then be tripped up by the CI check testing the indentation: The indentation check fails, but not because of changes in the actual PR, but in the code that was merged previously.

At the moment you change to 3.1, your tester also changes to 3.1. A rebase to the newest master is unlikely to give merge conflicts in this case. The rebased code then is run against the 3.1 tester and either passes or fails (prompting the the user to switch to astyle 3.1). I can also see many kinds of pull request which won't even need to be rebased. For example, like in the above case, documentation or adding/changing tests pull request, or pull request which just changes something small in unaffected lines.

Furthermore, github actually checks every time main changes whether each pull request can be merged without conflicts. The thing the testers use is (as far as I know) a merged version with the current main. So if there are no merge conflicts, just restarting all testers once before merging the pull request should show all potential issues (that is, the indent tester will fail and prompt users to indent their code correctly). This will most likely already happen because users add commits, the tester will be rerun.

I hope you see that that creates issues. None that aren't insurmountable, but it's not easy to deal with this in practice if indentation is one of the CI checks.

Yes, I agree that there will be issues, and I am probably a bit too optimistic due to how smooth (as far as I know) the change from master to main went, which in my mind is a much more challenging change, but in my mind the worst thing which can happen is that we merge something which is not properly indented according to astyle 3.1. For the world builder we will know when that happens in about 30s after the merge and for aspect in about 3 minutes after the merge.

I just want to say that I am not advocating to do this now, but right when we start with the next major release of aspect may be a good time. The world builder currently has only 13 open pull request, so I am sure that can be managed at any point :)

On the topic of this pull request, I saw in geodynamics/aspect#4562 that you said that you have a patch which cleans this up. Would it make sense to add that to this pull request as well before merging, or did I misunderstand that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you'd have to rebase every pending patch. (I don't know whether the CI uses the test scripts from the version the patch is based on, or from main. I think it is the former, but the effect is the same: all patches have to be rebased.) For deal.II, at any given time, I would assume that there are 2-300 patches that are either already submitted and pending, or are in current development. It's a major disruption to rebase all of these, at least if a change of astyle/clang-format version touches a lot of lines.

I'd be curious how many lines in ASPECT change if one upgrades astyle? deal.II no longer uses astyle, so the pain in proposing the change for ASPECT would be lower.

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