{"action":"created","issue":{"url":"https://api.github.com/repos/JetBrains/kotlin/issues/1943","repository_url":"https://api.github.com/repos/JetBrains/kotlin","labels_url":"https://api.github.com/repos/JetBrains/kotlin/issues/1943/labels{/name}","comments_url":"https://api.github.com/repos/JetBrains/kotlin/issues/1943/comments","events_url":"https://api.github.com/repos/JetBrains/kotlin/issues/1943/events","html_url":"https://github.com/JetBrains/kotlin/pull/1943","id":375172452,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2Njc5OTUx","number":1943,"title":"Improve initialization performance of SynchronizedLazyImpl","user":{"login":"negator","id":1631406,"node_id":"MDQ6VXNlcjE2MzE0MDY=","avatar_url":"https://avatars0.githubusercontent.com/u/1631406?v=4","gravatar_id":"","url":"https://api.github.com/users/negator","html_url":"https://github.com/negator","followers_url":"https://api.github.com/users/negator/followers","following_url":"https://api.github.com/users/negator/following{/other_user}","gists_url":"https://api.github.com/users/negator/gists{/gist_id}","starred_url":"https://api.github.com/users/negator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/negator/subscriptions","organizations_url":"https://api.github.com/users/negator/orgs","repos_url":"https://api.github.com/users/negator/repos","events_url":"https://api.github.com/users/negator/events{/privacy}","received_events_url":"https://api.github.com/users/negator/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"ilya-g","id":4257577,"node_id":"MDQ6VXNlcjQyNTc1Nzc=","avatar_url":"https://avatars1.githubusercontent.com/u/4257577?v=4","gravatar_id":"","url":"https://api.github.com/users/ilya-g","html_url":"https://github.com/ilya-g","followers_url":"https://api.github.com/users/ilya-g/followers","following_url":"https://api.github.com/users/ilya-g/following{/other_user}","gists_url":"https://api.github.com/users/ilya-g/gists{/gist_id}","starred_url":"https://api.github.com/users/ilya-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilya-g/subscriptions","organizations_url":"https://api.github.com/users/ilya-g/orgs","repos_url":"https://api.github.com/users/ilya-g/repos","events_url":"https://api.github.com/users/ilya-g/events{/privacy}","received_events_url":"https://api.github.com/users/ilya-g/received_events","type":"User","site_admin":false},"assignees":[{"login":"ilya-g","id":4257577,"node_id":"MDQ6VXNlcjQyNTc1Nzc=","avatar_url":"https://avatars1.githubusercontent.com/u/4257577?v=4","gravatar_id":"","url":"https://api.github.com/users/ilya-g","html_url":"https://github.com/ilya-g","followers_url":"https://api.github.com/users/ilya-g/followers","following_url":"https://api.github.com/users/ilya-g/following{/other_user}","gists_url":"https://api.github.com/users/ilya-g/gists{/gist_id}","starred_url":"https://api.github.com/users/ilya-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilya-g/subscriptions","organizations_url":"https://api.github.com/users/ilya-g/orgs","repos_url":"https://api.github.com/users/ilya-g/repos","events_url":"https://api.github.com/users/ilya-g/events{/privacy}","received_events_url":"https://api.github.com/users/ilya-g/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-10-29T19:09:44Z","updated_at":"2018-10-30T16:15:36Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/JetBrains/kotlin/pulls/1943","html_url":"https://github.com/JetBrains/kotlin/pull/1943","diff_url":"https://github.com/JetBrains/kotlin/pull/1943.diff","patch_url":"https://github.com/JetBrains/kotlin/pull/1943.patch"},"body":"The current version of SynchronizedLazyImpl forces all waiting threads to block on a mutex, which can hamper performance when there are many waiting threads and if the initialization block is a time consuming operation. \r\n\r\nThis change introduces an [AQS](https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/AbstractQueuedSynchronizer.html) implementation which mimics a BooleanLatch (as described in the AQS javadoc), to allow all waiting reader threads to acquire a shared lock immediately after the value has been initialized, rather then forcing them to acquire a mutex. The value is guaranteed to be initialized by a single writer thread.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/JetBrains/kotlin/issues/comments/434367056","html_url":"https://github.com/JetBrains/kotlin/pull/1943#issuecomment-434367056","issue_url":"https://api.github.com/repos/JetBrains/kotlin/issues/1943","id":434367056,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNDM2NzA1Ng==","user":{"login":"negator","id":1631406,"node_id":"MDQ6VXNlcjE2MzE0MDY=","avatar_url":"https://avatars0.githubusercontent.com/u/1631406?v=4","gravatar_id":"","url":"https://api.github.com/users/negator","html_url":"https://github.com/negator","followers_url":"https://api.github.com/users/negator/followers","following_url":"https://api.github.com/users/negator/following{/other_user}","gists_url":"https://api.github.com/users/negator/gists{/gist_id}","starred_url":"https://api.github.com/users/negator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/negator/subscriptions","organizations_url":"https://api.github.com/users/negator/orgs","repos_url":"https://api.github.com/users/negator/repos","events_url":"https://api.github.com/users/negator/events{/privacy}","received_events_url":"https://api.github.com/users/negator/received_events","type":"User","site_admin":false},"created_at":"2018-10-30T16:15:36Z","updated_at":"2018-10-30T16:15:36Z","author_association":"NONE","body":"This is a great point. AQS uses an internal queue of waiting threads, which will impact the memory footprint as the number of threads grows. However, AQS is the basis for most Java synchronization primitives so I would assume it is implemented optimally for the common use cases. Although, if the goal is to minimize the footprint to greatest extent, this is probably not appropriate.\r\n\r\nI does occur to me now that we can simplify this greatly, using a global AtomicReferenceUpdater to simulate an exclusive write lock, and a volatile boolean to simulate the latch. This would impose a small constant amount of memory of an object and a volatile boolean for every lazy val."}}
{"actor":{"display_login":"negator"}}