-
Notifications
You must be signed in to change notification settings - Fork 224
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
Refactored assembly to use in-memory model instead of IO model #464
Conversation
@fnqista Thanks for this contribution. Looking forward to the perf improvements. |
When the computer is fast, like in my home computer which was upgraded recently, the difference between the old and new implementation is not that pronounced: System: AMD Ryzen 5900X 12c/24t with NVME Gen4 drive (7000 MB/sec read)
However in my work computer, I have pre-tested before and something that takes 15 minutes in the old implementation only takes 29 seconds now. I will gather evidence when I am back at work after the Easter. |
Here's a result from assembling a fresh Play app on my old mac laptop
|
Implemented review comments: - Fixed "getPackageName" API call that fails in JDK8, used "getPackage.getName" instead - Nixed scalafmt (need a future PR) - Changed unactionable user logging/timers to DEBUG - Removed the 2.0.0 features from the README (instead, need to include it later on as part of the RELEASE NOTES) - Updated README to show an example config of `ThisBuild / repeatableBuild` - Updated README to clarify that jar entries need to be built in a specific 'order' for a consistent hash Other fixes: - Removed scalactic dependency - Nixed extra spacing, inline some vals - Renamed some vals - Removed extra manifest checking - Nixed errant comment in custom merge strategy test - `transferAndClose(is, os)` changed to `transfer(is, os)` since the former doesn't close the os anyway, instead we rely on the wrapping `Using` - Changed `AssemblyOption.repeatableBuild` default to `true` in contraband (it should be fine as is since it will be set to `true` by the Plugin, but changed anyway to show the intent that it was meant to be defaulted to `true`)
@eed3si9n Release notes draft: |
@eed3si9n The method signature of
This is exposed to the user because they can create custom merge strategies. Shall we use contraband for these to at least guarantee some level of backward compatibility? |
Change the implementation of MergeStrategy for user convenience, as suggested by Eugene Yokota Namespaced built-in merge strategies from custom user-provided ones Rename of class files now reported as an error. Shade rules should be used instead Updated plug-in auto imports/created implicit for String -> Path for the convenience of creating a custom merge strategy Updated cache logic so renames are only processed if the cache is invalid Other minor code and test updates #418
@eed3si9n
val first: MergeStrategy = MergeStrategy("First") { conflicts =>
Right(Vector(JarEntry(conflicts.head.target, conflicts.head.stream)))
}
ThisBuild / assemblyMergeStrategy := {
...
case _ => CustomMergeStrategy("First") { conflicts =>
Right(Vector(JarEntry(conflicts.head.target, conflicts.head.stream)))
}
|
Update case class member types from `java.nio.file.Path` to `String`, to communicate that it doesn't accept any kind of `Path`s (absolute or URI-based), but just plain relative `Path`s #418
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@eed3si9n
I have prepared some fixes but I am still testing them, hopefully I can make a new push within a couple of days. EDIT: Clarifying point no. 3 about custom renames being OK - If we fix no. 2 (rename before caching), then custom renames will happen before the cache. |
Rename not reported due to `notifyThreshold` set to `2`, now set to `1` Prevent users from corrupting the `CustomMergeStrategy.rename` by restricting what they can do. The function now passes only a single `Dependency` and returns a `String` for the renamed path Fix caching bug - rename should be done before preparing the cache inputs, since renaming can cause another match on the second pass to rebuild the jar Fix caching bug - custom strategies other than rename, should always invalidate the cache because we cannot predict their output Others: Log shade result if on debug
Fixes committed for the above...hopefully the last one. EDIT: Also updated draft release notes: https://gist.github.com/fnqista/56fb6c5957302ba4af32c6c2b7dcb7c8 |
@eed3si9n Can you review the pending changes and then create an RC1 candidate when you have time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the test passes I am good here.
These two custom `MergeStrategy`s are no longer used: * `MergeLog4j2PluginCachesStrategy` : introduced with #161 and made obsolete with #682 . Note that, should you still need something like this elsewhere, https://github.com/idio/sbt-assembly-log4j2 also provides an implementation (but maybe better to just use logback?). * `MergeMimeTypesStrategy` : introduced with #292 and made obsolete with #412 Both classes extend `sbtassembly.MergeStrategy`, which was possible up until sbt/sbt-assembly#464 - see sbt/sbt-assembly#464 (comment) - where that type became a _sealed_ trait that could not be extended. While the existing build for this project specified an old version of `sbt-assembly`, it appears that the Scala Steward process brings in a newer version (>=v2.0.0) of `sbt-assembly`, that has the change introduced with sbt/sbt-assembly#464 . Consequently, our Scala Steward job for this repo is currently failing: https://github.com/guardian/scala-steward-public-repos/actions/runs/4513026623/jobs/7947284010#step:6:932 ...with errors like: ``` /home/runner/scala-steward/workspace/repos/guardian/mobile-n10n/project/MergeLog4j2PluginCachesStrategy.scala:10:47: illegal inheritance from sealed trait MergeStrategy class MergeLog4j2PluginCachesStrategy extends MergeStrategy { ``` Upgrading `mobile-n10n` to use the latest version of `sbt-assembly` makes this problem apparent with just a regular build (as opposed to the special Scala Steward build), and the easiest fix to the problem is just to remove the superfluous custom `MergeStrategy`s - Delete The Obsolete!
The advantage of this code is streaming IO, with minimal reliance on disk speed. References to files and jar entries are stored as () => InputStream. Unzip to disk is gone, which is slow on some systems/hard drives.
Everything retained:
The following were new: