-
Notifications
You must be signed in to change notification settings - Fork 360
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
compute_ctl: Break up main() #7577
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3072 tests run: 2939 passed, 0 failed, 133 skipped (full report)Flaky tests (6)Postgres 16Postgres 15
Postgres 14
Code coverage* (full report)
* collected from Rust tests only The comment gets automatically updated with the latest test results
7f45a29 at 2024-05-07T21:06:51.186Z :recycle: |
tristan957
reviewed
May 1, 2024
This was referenced May 3, 2024
sharnoff
force-pushed
the
sharnoff/compute_ctl-main()-phase-refactor
branch
from
May 4, 2024 01:26
ffe65ef
to
10a0754
Compare
hlinnaka
added a commit
that referenced
this pull request
May 4, 2024
- On a non-pooled start, do not reset the 'start_time' after launching the HTTP service. In a non-pooled start, it's fair to include that in the total startup time. - When setting wait_for_spec_ms and resetting start_time, call Utc::now() only once. It's a waste of cycles to call it twice, but also, it ensures the time between setting wait_for_spec_ms and resetting start_time is included in one or the other time period. These differences should be insignificant in practice, in the microsecond range, but IMHO it seems more logical and readable this way too. Also fix and clarify some of the surrounding comments. (This caught my eye while reviewing PR #7577)
hlinnaka
approved these changes
May 4, 2024
sharnoff
force-pushed
the
sharnoff/compute_ctl-main()-phase-refactor
branch
from
May 4, 2024 16:22
10a0754
to
855679e
Compare
sharnoff
changed the title
compute_ctl: Break up main() into discrete phases
compute_ctl: Break up main()
May 4, 2024
Planning to merge in 24h or so, if no objections (cc @tristan957). |
tristan957
approved these changes
May 7, 2024
A couple lines moved further down in main(), and one case of using Option<&str> instead of Option<&String>.
This commit is intentionally designed to have as small a diff as possible. To that end, the basic idea is that each distinct "chunk" of the previous main() has been wrapped in its own function, with the return values from each function being passed directly into the next. The structure of main() is now visible from its contents, which have a handful of smaller functions. There's a lot of other work that can / should(?) be done beyond this, but I figure that's more opinionated, and this should be a solid start. Co-authored-by: Heikki Linnakangas <heikki@neon.tech>
Part of applying the changes from #7600. This piece *technically* can change the semantics because now the context guard is held before process_cli, but... the difference is likely quite small. Co-authored-by: Heikki Linnakangas <heikki@neon.tech>
sharnoff
force-pushed
the
sharnoff/compute_ctl-main()-phase-refactor
branch
from
May 7, 2024 19:32
855679e
to
7f45a29
Compare
sharnoff
added a commit
that referenced
this pull request
May 7, 2024
A couple lines moved further down in main(), and one case of using Option<&str> instead of Option<&String>.
sharnoff
added a commit
that referenced
this pull request
May 7, 2024
This commit is intentionally designed to have as small a diff as possible. To that end, the basic idea is that each distinct "chunk" of the previous main() has been wrapped in its own function, with the return values from each function being passed directly into the next. The structure of main() is now visible from its contents, which have a handful of smaller functions. There's a lot of other work that can / should(?) be done beyond this, but I figure that's more opinionated, and this should be a solid start. Co-authored-by: Heikki Linnakangas <heikki@neon.tech>
sharnoff
added a commit
that referenced
this pull request
May 7, 2024
Introduced by refactorings from #7577. See an example check-macos-build failure here: https://github.com/neondatabase/neon/actions/runs/8992211409/job/24701531264
5 tasks
sharnoff
added a commit
that referenced
this pull request
May 7, 2024
Introduced by refactorings from #7577. See an example check-macos-build failure here: https://github.com/neondatabase/neon/actions/runs/8992211409/job/24701531264
conradludgate
pushed a commit
that referenced
this pull request
May 8, 2024
- On a non-pooled start, do not reset the 'start_time' after launching the HTTP service. In a non-pooled start, it's fair to include that in the total startup time. - When setting wait_for_spec_ms and resetting start_time, call Utc::now() only once. It's a waste of cycles to call it twice, but also, it ensures the time between setting wait_for_spec_ms and resetting start_time is included in one or the other time period. These differences should be insignificant in practice, in the microsecond range, but IMHO it seems more logical and readable this way too. Also fix and clarify some of the surrounding comments. (This caught my eye while reviewing PR #7577)
conradludgate
pushed a commit
that referenced
this pull request
May 8, 2024
A couple lines moved further down in main(), and one case of using Option<&str> instead of Option<&String>.
conradludgate
pushed a commit
that referenced
this pull request
May 8, 2024
This commit is intentionally designed to have as small a diff as possible. To that end, the basic idea is that each distinct "chunk" of the previous main() has been wrapped in its own function, with the return values from each function being passed directly into the next. The structure of main() is now visible from its contents, which have a handful of smaller functions. There's a lot of other work that can / should(?) be done beyond this, but I figure that's more opinionated, and this should be a solid start. Co-authored-by: Heikki Linnakangas <heikki@neon.tech>
conradludgate
pushed a commit
that referenced
this pull request
May 8, 2024
Part of applying the changes from #7600. This piece *technically* can change the semantics because now the context guard is held before process_cli, but... the difference is likely quite small. Co-authored-by: Heikki Linnakangas <heikki@neon.tech>
conradludgate
pushed a commit
that referenced
this pull request
May 8, 2024
Introduced by refactorings from #7577. See an example check-macos-build failure here: https://github.com/neondatabase/neon/actions/runs/8992211409/job/24701531264
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
compute_ctl's
main()
is "pretty gnarly". This makes changes to control flow quite difficult.I hit this while working on #7434 and had an idea of how it could be improved, thus this PR.
Summary of changes
First commit: Small changes to reduce the diff of the second commit.
Second commit: Breaks up
main()
into a handful of component functions, aligned with distinct sections of the existing control flow. Each new function gets the previous one's return values as its arguments. The new functions destructure their args so the names are all the same.Third commit: Move the tracing startup context guard out of where it was previously used, to make things more simple. Taken from #7600.
Checklist before requesting a review
Checklist before merging