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

Separating tools dependencies from main dependencies #4895

Merged
merged 6 commits into from
Jul 6, 2022
Merged

Conversation

Groxx
Copy link
Contributor

@Groxx Groxx commented Jul 6, 2022

Adding gowrap in #4879 pulled in an additional 30MB of dependency source files, which is
pretty ridiculous. It's happening because, while gowrap uses a tools-tagged tools.go,
it's in the same module as everything else, so its dependencies are pulled in too, because
Go has no way to tell that it's not needed by callers (it needs to consider ALL tags).

We're doing the same thing. Granted, we're an application and not a library, but it still
seems kinda unnecessary. And it forces quite a large number of upgrades we may not want to
force (yet).

So this moves tools.go to a new package, sets up a new go.{mod,sum} just for it, and adds
a bit of automation to prevent it from drifting too far from the main module.
With this, go mod tidy in the top level does not consider tools-dependencies any more,
so we actually remove some, and do not add tons more or force upgrades to pull in gowrap/etc
in the future.


internal/tools is just because it needs to be in a separate package, and "tools" was taken.
plus nobody should ever import it, so it should be a clear "dependency dead-end".

Groxx added 2 commits July 5, 2022 22:57
Adding gowrap in uber#4879 pulled in an additional *30MB* of dependencies, which is
pretty ridiculous.  It's happening because, while gowrap uses a tools-tagged `tools.go`,
it's in the same module as everything else, so its dependencies are pulled in too, because
Go has no way to tell that it's not needed by callers (it needs to consider ALL tags).

We're doing the same thing.  Granted, we're an application and not a library, but it still
seems kinda unnecessary.  And it forces upgrades we may not want to force (yet).

So this moves tools.go to a new package, sets up a new go.mod file just for it, and adds
a bit of automation to prevent it from drifting too far from the main module.
With this, `go mod tidy` in the top level does not consider tools-dependencies any more,
so we actually *remove* some, and do not add tons more for gowrap/etc in the future.

---

internal/tools is just because it needs to be in a separate package, and "tools" was taken.
plus nobody should ever import it, so it should be a clear "dependency dead-end".
@coveralls
Copy link

coveralls commented Jul 6, 2022

Pull Request Test Coverage Report for Build 0181d202-4a5b-44cd-9939-9c2e378c1da3

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 153 unchanged lines in 19 files lost coverage.
  • Overall coverage decreased (-0.07%) to 57.674%

Files with Coverage Reduction New Missed Lines %
common/membership/hashring.go 2 83.54%
common/task/fifoTaskScheduler.go 2 84.54%
common/task/weightedRoundRobinTaskScheduler.go 2 89.64%
service/history/execution/mutable_state_util.go 2 36.14%
service/history/task/transfer_standby_task_executor.go 2 87.61%
common/persistence/nosql/nosqlplugin/cassandra/workflow.go 3 56.69%
common/persistence/statsComputer.go 3 93.57%
service/history/task/fetcher.go 3 91.79%
common/persistence/serialization/parser.go 4 62.41%
common/persistence/serialization/thrift_decoder.go 4 53.06%
Totals Coverage Status
Change from base Build 0181d1fc-8c5e-487c-a5c2-7beed77dcf9b: -0.07%
Covered Lines: 83595
Relevant Lines: 144945

💛 - Coveralls

Makefile Outdated
@@ -110,7 +111,19 @@ LINT_SRC := $(filter-out %_test.go ./.gen/%, $(ALL_SRC))
# downloads and builds a go-gettable tool, versioned by go.mod, and installs
# it into the build folder, named the same as the last portion of the URL.
define go_build_tool
@echo "building $(or $(2), $(notdir $(1))) from $(1)..."
@echo "building $(or $(2), $(notdir $(1))) from internal/tools/go.mod..."
@go build -mod=readonly -modfile=internal/tools/go.mod -o $(BIN)/$(or $(2), $(notdir $(1))) $(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this fail your @ rule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if merged without updating it, yes.
stacked PRs are not a thing github supports though, so I have to either include its changes in this PR, or wait for it to merge first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated!

Copy link
Contributor

@davidporter-id-au davidporter-id-au left a comment

Choose a reason for hiding this comment

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

nice!

internal/tools/tools.go Outdated Show resolved Hide resolved
import (
"reflect"

"github.com/apache/thrift/lib/go/thrift"
Copy link
Contributor Author

@Groxx Groxx Jul 6, 2022

Choose a reason for hiding this comment

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

surprisingly, this is the only import of apache/thrift in the server. the rest of the use comes from importing the client.

might be worth exploring that, to see if we can get rid of it entirely.... but perhaps not. either way, this file was totally unused, and it moved a problematic dependency to only-indirect, so I figured I'd include it.

Groxx added 2 commits July 6, 2022 00:31
fixed conflict in makefile around @ -> $Q
@Groxx Groxx merged commit ed2beb2 into uber:master Jul 6, 2022
@Groxx Groxx deleted the tools branch July 6, 2022 06:33
Groxx added a commit to Groxx/cadence that referenced this pull request Jul 21, 2022
Adding gowrap in uber#4879 pulled in an additional *30MB* of dependencies, which is
pretty ridiculous.  It's happening because, while gowrap uses a tools-tagged `tools.go`,
it's in the same module as everything else, so its dependencies are pulled in too, because
Go has no way to tell that it's not needed by callers (it needs to consider ALL tags).

We're doing the same thing.  Granted, we're an application and not a library, but it still
seems kinda unnecessary.  And it forces upgrades we may not want to force (yet).

So this moves tools.go to a new package, sets up a new go.mod file just for it, and adds
a bit of automation to prevent it from drifting too far from the main module.
With this, `go mod tidy` in the top level does not consider tools-dependencies any more,
so we actually *remove* some, and do not add tons more for gowrap/etc in the future.

---

internal/tools is just because it needs to be in a separate package, and "tools" was taken.
plus nobody should ever import it, so it should be a clear "dependency dead-end" for tools.
Groxx added a commit to Groxx/cadence that referenced this pull request Jul 21, 2022
Adding gowrap in uber#4879 pulled in an additional *30MB* of dependencies, which is
pretty ridiculous.  It's happening because, while gowrap uses a tools-tagged `tools.go`,
it's in the same module as everything else, so its dependencies are pulled in too, because
Go has no way to tell that it's not needed by callers (it needs to consider ALL tags).

We're doing the same thing.  Granted, we're an application and not a library, but it still
seems kinda unnecessary.  And it forces upgrades we may not want to force (yet).

So this moves tools.go to a new package, sets up a new go.mod file just for it, and adds
a bit of automation to prevent it from drifting too far from the main module.
With this, `go mod tidy` in the top level does not consider tools-dependencies any more,
so we actually *remove* some, and do not add tons more for gowrap/etc in the future.

---

internal/tools is just because it needs to be in a separate package, and "tools" was taken.
plus nobody should ever import it, so it should be a clear "dependency dead-end" for tools.
Groxx added a commit that referenced this pull request Jul 21, 2022
Adding gowrap in #4879 pulled in an additional *30MB* of dependencies, which is
pretty ridiculous.  It's happening because, while gowrap uses a tools-tagged `tools.go`,
it's in the same module as everything else, so its dependencies are pulled in too, because
Go has no way to tell that it's not needed by callers (it needs to consider ALL tags).

We're doing the same thing.  Granted, we're an application and not a library, but it still
seems kinda unnecessary.  And it forces upgrades we may not want to force (yet).

So this moves tools.go to a new package, sets up a new go.mod file just for it, and adds
a bit of automation to prevent it from drifting too far from the main module.
With this, `go mod tidy` in the top level does not consider tools-dependencies any more,
so we actually *remove* some, and do not add tons more for gowrap/etc in the future.

---

internal/tools is just because it needs to be in a separate package, and "tools" was taken.
plus nobody should ever import it, so it should be a clear "dependency dead-end" for tools.
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.

3 participants