Skip to content

Migrate from the deprecated native atomics #3798

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

Merged
merged 3 commits into from
Aug 14, 2023
Merged

Conversation

mvicsokolova
Copy link
Contributor

This commit is required for the aggregate build that checks the change of deprecation level for native atomics (https://jetbrains.team/p/kt/reviews/10650/timeline). Usages of native atomics from kotlin.native.concurrent package are replaced with new atomics from kotlin.concurrent because old native atomics will be deprecated with error.

NOTE: this commit is not present in develop branch, because new kotlin.concurrent atomics are only available since Kotlin 1.9.0. IT SHOULD BE REMOVED after kotlinx.coroutines updates Kotlin version to 1.9.0.

Here is the build that checked this branch against the 1.9.20-dev Kotlin version. This TC config may be used to check that changes from the given branch won't break the aggregate build.

@dkhalanskyjb
Copy link
Collaborator

I don't have any context for this, so I'll need some explanation.

  1. Do I understand correctly that in 1.9.0, in the space of a single release, old atomics get deprecated and force everyone to immediately migrate to the new ones? Now that's harsh! Usually, we do it differently: first, the deprecated API causes warnings, and only later, when people have had enough time to migrate, the warning becomes an error. Was the speed of this change discussed and approved?
  2. I don't know how kotlin-community/dev is built. Will it always be built with version 1.9.0+? Currently, the build does not pass with the old version, because, as you said, the new atomics are unavailable there.
  3. Can this not be tweaked somehow creatively so that the build passes both on the current version and on 1.9.0+? For example, won't it work with import kotlin.concurrent.*; import kotlin.native.concurrent.* (or maybe if their order is switched)? Then we can just merge it to develop, dropping a comment to the import list to explain that the order and form of the imports are significant.

@mvicsokolova
Copy link
Contributor Author

Hi!)

  1. No no, the deprecation was not that fast. Old atomics were deprecated with WARNING in 1.9.0, and now I've prepared the MR (https://jetbrains.team/p/kt/reviews/10650/timeline) for 1.9.20 where deprecation level is changed for ERROR. And this breaks the aggregate build, because there are usages of old atomics in coroutines.
  2. kotlin-community/dev branch is used in aggregate builds, and uses 1.9.20-dev Kotlin currently. And having Kotlin set to 1.8.20 in all kotlin-community/dev branches is wrong. I asked our release managers to update Kotlin version in gradle.properties of kotlin-community/dev branches for all the libraries to 1.9.20-dev-*. So, after that the new atomics will be available.

@mvicsokolova
Copy link
Contributor Author

mvicsokolova commented Jun 30, 2023

  1. I tried adding imports of both kotlin.concurrent.* and kotlin.native.concurrent.*, this will work for develop where Kotlin is 1.8.20 and atomics will be resolved to kotlin.native.concurrent, because they are only present in that package. But for Kotlin 1.9.20-dev atomics are still resolved to the old kotlin.native.concurrent package and the build fails with deprecation error. But I'll try changing the order of packages.

@dkhalanskyjb
Copy link
Collaborator

My only concern is that a branch should build with ./gradlew clean build when you check it out. When I do it with kotlin-community/dev currently, the build seems to go through fine, but with this PR, it will no longer do so.

I asked our release managers to update Kotlin version in gradle.properties of kotlin-community/dev branches for all the libraries to 1.9.20-dev-*.

Why can't we do it ourselves? Is it not just about updating the Kotlin version in a couple of places? For example, what's preventing us from upgrading Kotlin to something like 1.9.0-RC in this same PR?

@qwwdfsad
Copy link
Member

What should we do with this PR? Seems kind of abandoned

@mvicsokolova
Copy link
Contributor Author

I'll create a PR with the necessary changes in develop: in this case just swapping package imports (kotlin.concurrent and kotlin.native.concurrent) should help.

@woainikk woainikk force-pushed the kotlin-community/dev branch from 20c6db7 to 79c22b7 Compare July 24, 2023 08:47
@mvicsokolova mvicsokolova force-pushed the update-native-atomics branch from eccc5ea to 9a13158 Compare July 27, 2023 20:10
@mvicsokolova
Copy link
Contributor Author

mvicsokolova commented Jul 27, 2023

So, here is the update on this PR:
in this MR (https://jetbrains.team/p/kt/reviews/10650/timeline) atomics from kotlin.native.concurrent are deprecated with error for 1.9.20 -> the aggregate build fails.

In coroutines we need to migrate from old atomics to the new atomics from kotlin.concurrent package, but those are only available since 1.9.0

In order to add this commit to develop first I tried to import both kotlin.concurrent.* and kotllin.native.concurrent.* packages, thus the build of the develop branch passes but the aggregate still fails, because the old kotlin.native.concurrent.AtomicReference is resolved.

Is there a better solution for this, then just adding this commit to kotlin-community?

@qwwdfsad qwwdfsad requested review from qwwdfsad and removed request for dkhalanskyjb July 28, 2023 10:50
@mvicsokolova mvicsokolova changed the base branch from kotlin-community/dev to develop July 28, 2023 12:51
demiurg906 and others added 2 commits July 28, 2023 14:59
This commit is required for the aggregate build that checks the change of deprecation level for native atomics (https://jetbrains.team/p/kt/reviews/10650/timeline). Usages of native atomics from kotlin.native.concurrent package are replaced with new atomics from kotlin.concurrent because old native atomics will be deprecated with error.

NOTE: this commit is not present in develop branch, because new kotlin.concurrent atomics are only available since Kotlin 1.9.0. IT SHOULD BE REMOVED after kotlinx.coroutines updates Kotlin version to 1.9.0.
@mvicsokolova mvicsokolova force-pushed the update-native-atomics branch from 9a13158 to 77b630c Compare July 28, 2023 13:00
@mvicsokolova mvicsokolova added the kotlin-merge-blocker PRs labeled as merge-blockers are effectively preventing a corresponding merge into main Kotlin repo label Jul 28, 2023
@mvicsokolova
Copy link
Contributor Author

I've reverted this commit, we don't need it in this PR

@qwwdfsad qwwdfsad requested a review from mshishkina July 31, 2023 10:15
@mshishkina mshishkina requested review from woainikk and removed request for mshishkina July 31, 2023 12:08
@woainikk woainikk merged commit 7ef545e into develop Aug 14, 2023
@mvicsokolova mvicsokolova deleted the update-native-atomics branch August 14, 2023 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kotlin-merge-blocker PRs labeled as merge-blockers are effectively preventing a corresponding merge into main Kotlin repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants