Status Update
Comments
al...@google.com <al...@google.com> #2
It's really odd that yield
was used here in the first place. +cc adamp in case he can discern a reason.
I want to propose a solution based on my lazy tree iterator that speeds up this function by hundreds and thousands of times.
I can copy/paste that in, but if you want proper commit attribution you can use our
ma...@gmail.com <ma...@gmail.com> #3
Oh yes, I'll try it. I didn't know that this was possible)
al...@google.com <al...@google.com> #4
Bugjuggler: wait 2 weeks
Putting this on ice until either (a) I get a notification from Gerrit / GitHub or (b) I get back from vacation. Please leave a comment if you have a commit up somewhere for review.
bu...@google.com <bu...@google.com> #5
ma...@gmail.com <ma...@gmail.com> #6
I tried to do this, but I lost my brain until I understood how it works.
It is necessary to correct the instructions for
I have configured the dependencies, but now I get an error when I try to run the command
cd Development/androidx/playground-projects/core-playground
./gradlew studio
I'm getting an error in LibraryVersionsService.kt
> Task :supportBuildSrc:private:compileKotlin
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:23:12 Unresolved reference: tomlj
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:24:12 Unresolved reference: tomlj
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:25:12 Unresolved reference: tomlj
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:36:33 Unresolved reference: TomlParseResult
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:36:52 Property delegate must have a 'getValue(LibraryVersionsService, KProperty<*>)' method. None of the following functions is suitable:
public inline operator fun <T> Lazy<???>.getValue(thisRef: Any?, property: KProperty<*>): ??? defined in kotlin
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:37:22 Unresolved reference: Toml
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:41:51 Unresolved reference: it
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:41:69 Unresolved reference: it
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:48:40 Unresolved reference: TomlTable
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:54:50 Property delegate must have a 'getValue(LibraryVersionsService, KProperty<*>)' method. None of the following functions is suitable:
public inline operator fun <T> Lazy<Map<String, Version>>.getValue(thisRef: Any?, property: KProperty<*>): Map<String, Version> defined in kotlin
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:56:43 Cannot infer a type for this parameter. Please specify it explicitly.
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:115:76 Property delegate must have a 'getValue(LibraryVersionsService, KProperty<*>)' method. None of the following functions is suitable:
public inline operator fun <T> Lazy<List<LibraryGroupAssociation>>.getValue(thisRef: Any?, property: KProperty<*>): List<LibraryGroupAssociation> defined in kotlin
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:118:47 Unresolved reference: TomlTable
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:120:29 Overload resolution ambiguity:
public fun File.startsWith(other: String): Boolean defined in kotlin.io
public fun CharSequence.startsWith(prefix: CharSequence, ignoreCase: Boolean = ...): Boolean defined in kotlin.text
public fun String.startsWith(prefix: String, ignoreCase: Boolean = ...): Boolean defined in kotlin.text
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:133:40 Cannot infer a type for this parameter. Please specify it explicitly.
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:140:24 Not enough information to infer type variable for subcalls of if expression
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:150:75 Not enough information to infer type variable T
e: file:///Users/17543251/Development/androidx/buildSrc/private/src/main/kotlin/androidx/build/LibraryVersionsService.kt:151:21 Unresolved reference: it
> Task :supportBuildSrc:private:compileKotlin FAILED
FAILURE: Build failed with an exception.
I almost gave up, maybe it would be better if you made the corrections yourself.
bu...@google.com <bu...@google.com>
al...@google.com <al...@google.com> #7
Yep, I can take care of it. I think I have "forge author" rights, so we can probably still get you on the commit as author.
al...@google.com <al...@google.com> #8
je...@google.com <je...@google.com> #9
Oh hey this seems super cool to me; thanks!
A potential clarification:
I think the slowness of the yieldAll() approach isn't necessarily that yieldAll() processes an individual element more slowly, but that the current approach using yieldAll() can pass an individual element through yieldAll() many times: once per level of the hierarchy.
Perhaps a clearer description would be something more like "ViewGroup.descendant is very, very slow because it constructs a new Sequence for each level of the hierarchy."
Thanks again!
ap...@google.com <ap...@google.com> #11
Branch: androidx-main
commit 68930c1b6df3672e70be7394a1ce30e96ebd855d
Author: Max Sidorov <maxssoft@gmail.com>
Date: Wed Jan 03 15:20:41 2024
Improve efficiency of ViewGroup.descendants using lazy tree iterator
Includes some minor formatting and documentation changes from original
proposal in the linked issue, including replacing `.asSequence()` with
`Sequence { ... }` to obtain an unconstrained sequence.
Benchmarks from original author:
Fixes: 316568512
Test: ViewGroupTest
Change-Id: I0a38193d207d1573eddc333fef11bb0ae0e56070
M core/core-ktx/src/main/java/androidx/core/view/ViewGroup.kt
na...@google.com <na...@google.com> #12
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.core:core-ktx:1.13.0-alpha04
Description
Component used: androidx.core.view
I'm writing an article about different ways to optimize recursion. I found that the standard ViewGroup.descendant function is very, very slow. This is because it uses slow calls to yield, yieldAll. I think this function is used by so many developers and it's too bad that it works so slowly.
You can see this for yourself if you look at the measurement results
Test results for find view in view hierarchy
Optimization
I want to propose a solution based on my lazy tree iterator that speeds up this function by hundreds and thousands of times.https://github.com/maxssoft/yield_recursion/blob/develop/benchmarks/src/main/java/com/maxssoft/func/TreeIterator.kt
Source code of the optimized function and TreeIterator