feat: Implement Copy-On-Write (CoW) behavior for Logger struct#297
Merged
weissi merged 21 commits intoapple:mainfrom May 30, 2024
Merged
feat: Implement Copy-On-Write (CoW) behavior for Logger struct#297weissi merged 21 commits intoapple:mainfrom
weissi merged 21 commits intoapple:mainfrom
Conversation
ayushi2103
commented
May 9, 2024
Contributor
Author
|
In which file should I add the unit test? |
FranzBusch
reviewed
May 9, 2024
Member
|
@swift-server-bot test this please |
weissi
reviewed
May 9, 2024
weissi
reviewed
May 9, 2024
weissi
reviewed
May 9, 2024
ayushi2103
commented
May 10, 2024
FranzBusch
reviewed
May 10, 2024
FranzBusch
reviewed
May 10, 2024
FranzBusch
reviewed
May 10, 2024
FranzBusch
reviewed
May 10, 2024
weissi
reviewed
May 10, 2024
weissi
reviewed
May 10, 2024
FranzBusch
reviewed
May 13, 2024
FranzBusch
reviewed
May 14, 2024
Member
|
@ayushi2103 Can you update this PR since we just landed #299 which drops support for old Swift versions. This should mean you no longer have to add the conditional conformance. |
c9174e0 to
e071509
Compare
weissi
reviewed
May 17, 2024
weissi
reviewed
May 17, 2024
weissi
reviewed
May 17, 2024
weissi
reviewed
May 17, 2024
Co-authored-by: Johannes Weiss <[email protected]>
Co-authored-by: Johannes Weiss <[email protected]>
FranzBusch
reviewed
May 17, 2024
Co-authored-by: Franz Busch <[email protected]>
Co-authored-by: Franz Busch <[email protected]>
FranzBusch
reviewed
May 21, 2024
FranzBusch
approved these changes
May 22, 2024
Member
FranzBusch
left a comment
There was a problem hiding this comment.
This looks good to me! @weissi you want to take a last look as well before we merge?
weissi
reviewed
May 28, 2024
weissi
reviewed
May 28, 2024
weissi
reviewed
May 29, 2024
Member
weissi
left a comment
There was a problem hiding this comment.
Thank you, this is almost there. Two little suggestions
weissi
approved these changes
May 30, 2024
Member
weissi
left a comment
There was a problem hiding this comment.
Amazing! Thank you so much, this will be quite the perf boost for certain things!!
cgrindel-self-hosted-renovate bot
referenced
this pull request
in cgrindel/rules_swift_package_manager
Jun 27, 2024
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [apple/swift-log](https://togithub.com/apple/swift-log) | minor | `from: "1.5.4"` -> `from: "1.6.1"` | --- ### Release Notes <details> <summary>apple/swift-log (apple/swift-log)</summary> ### [`v1.6.1`](https://togithub.com/apple/swift-log/releases/tag/1.6.1): Swift Log 1.6.1 [Compare Source](https://togithub.com/apple/swift-log/compare/1.6.0...1.6.1) ##### SemVer Patch - Disable existential any build setting ([#​312](https://togithub.com/apple/swift-log/issues/312)) ### [`v1.6.0`](https://togithub.com/apple/swift-log/releases/tag/1.6.0) [Compare Source](https://togithub.com/apple/swift-log/compare/1.5.4...1.6.0) #### SemVer Minor - Add Sendability annotations in [https://github.com/apple/swift-log/pull/308](https://togithub.com/apple/swift-log/pull/308) - Fix deprecation warnings around default log implementations on handlers in [https://github.com/apple/swift-log/pull/310](https://togithub.com/apple/swift-log/pull/310) - Drop Swift versions earlier than 5.8 in [https://github.com/apple/swift-log/pull/299](https://togithub.com/apple/swift-log/pull/299) - Implement Copy-On-Write (CoW) behavior for Logger struct by [@​ayushi2103](https://togithub.com/ayushi2103) in [https://github.com/apple/swift-log/pull/297](https://togithub.com/apple/swift-log/pull/297) ##### SemVer Patch - Replace standardOutput to standardError by [@​ayushi2103](https://togithub.com/ayushi2103) in [https://github.com/apple/swift-log/pull/295](https://togithub.com/apple/swift-log/pull/295) - Use Set to spot duplicated log handler warnings in [https://github.com/apple/swift-log/pull/306](https://togithub.com/apple/swift-log/pull/306) - Make protocol usage obvious using any and some keywords in [https://github.com/apple/swift-log/pull/307](https://togithub.com/apple/swift-log/pull/307) - Remove documentation for non-existent arguments by [@​b1ackturtle](https://togithub.com/b1ackturtle) in [https://github.com/apple/swift-log/pull/309](https://togithub.com/apple/swift-log/pull/309) - Remove Docc plugin which is no longer required in [https://github.com/apple/swift-log/pull/311](https://togithub.com/apple/swift-log/pull/311) ##### Other Changes - Remove archived repository in [https://github.com/apple/swift-log/pull/292](https://togithub.com/apple/swift-log/pull/292) - Add CI for Swift 5.10 in [https://github.com/apple/swift-log/pull/287](https://togithub.com/apple/swift-log/pull/287) - Added swift-log-ecs to README.md by [@​rwbutler](https://togithub.com/rwbutler) in [https://github.com/apple/swift-log/pull/298](https://togithub.com/apple/swift-log/pull/298) - Update README.md add shipbook as backend by [@​elishas](https://togithub.com/elishas) in [https://github.com/apple/swift-log/pull/304](https://togithub.com/apple/swift-log/pull/304) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDkuNCIsInVwZGF0ZWRJblZlciI6IjM2LjEwOS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: Self-hosted Renovate Bot <361546+cgrindel-self-hosted-renovate[bot]@users.noreply.github.enterprise.com>
This file contains hidden or 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
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.
Added CoW implementation for Logger struct to optimize performance and minimize memory overhead.
Motivation:
LogHandler is an existential type and has a String requiring two words so copying a Logger instance duplicates 7 words and executes two ARC operations. By implementing CoW with a boxed LogHandler, we will duplicate 1 word and one ARC operation, enhancing efficiency particularly when Logger instances are frequently passed around.
Modifications:
Added a private property
_handlerof typeBox<LogHandler>to hold theLogHandlerand updated thehandlerproperty to be computed, allowing transparent access to theLogHandler.Result:
When the Logger instances will be passed around, the change will reduce memory overhead and potentially improve performance.