Skip to content

Commit f73ab51

Browse files
authored
setup code chunks 60 vs. 1000 as A/B testing target (#3817)
1 parent 1b0825c commit f73ab51

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererConstants.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import com.intellij.openapi.editor.markup.EffectType
77
import com.intellij.openapi.editor.markup.TextAttributes
88
import com.intellij.ui.JBColor
99
import software.amazon.awssdk.regions.Region
10+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererUserGroup
11+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererUserGroupSettings
1012
import java.awt.Font
1113
import java.text.SimpleDateFormat
1214
import java.time.format.DateTimeFormatter
@@ -77,7 +79,8 @@ object CodeWhispererConstants {
7779
}
7880

7981
object CrossFile {
80-
const val CHUNK_SIZE = 60
82+
val CHUNK_SIZE
83+
get() = if (CodeWhispererUserGroupSettings.getInstance().getUserGroup() == CodeWhispererUserGroup.Control) 60 else 1000
8184
}
8285

8386
object Utg {

jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererFileContextProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ class DefaultCodeWhispererFileContextProvider(private val project: Project) : Fi
173173
chunks.addAll(file.toCodeChunk(relativePath))
174174
hasUsed.add(file)
175175
if (chunks.size > CodeWhispererConstants.CrossFile.CHUNK_SIZE) {
176-
LOG.debug { "finish fetching 60 chunks in ${System.currentTimeMillis() - parseFilesStart} ms" }
176+
LOG.debug { "finish fetching ${CodeWhispererConstants.CrossFile.CHUNK_SIZE} chunks in ${System.currentTimeMillis() - parseFilesStart} ms" }
177177
return chunks.take(CodeWhispererConstants.CrossFile.CHUNK_SIZE)
178178
}
179179
}
180180
}
181181

182-
LOG.debug { "finish fetching 60 chunks in ${System.currentTimeMillis() - parseFilesStart} ms" }
182+
LOG.debug { "finish fetching ${CodeWhispererConstants.CrossFile.CHUNK_SIZE} chunks in ${System.currentTimeMillis() - parseFilesStart} ms" }
183183
return chunks.take(CodeWhispererConstants.CrossFile.CHUNK_SIZE)
184184
}
185185

jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererFileContextProviderTest.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import org.mockito.kotlin.mock
2525
import org.mockito.kotlin.spy
2626
import org.mockito.kotlin.times
2727
import org.mockito.kotlin.verify
28+
import org.mockito.kotlin.whenever
2829
import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererCpp
2930
import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererCsharp
3031
import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererGo
@@ -38,6 +39,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages
3839
import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererTypeScript
3940
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererUserGroup
4041
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererUserGroupSettings
42+
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants
4143
import software.aws.toolkits.jetbrains.services.codewhisperer.util.DefaultCodeWhispererFileContextProvider
4244
import software.aws.toolkits.jetbrains.services.codewhisperer.util.FileContextProvider
4345
import software.aws.toolkits.jetbrains.utils.rules.HeavyJavaCodeInsightTestFixtureRule
@@ -67,6 +69,18 @@ class CodeWhispererFileContextProviderTest {
6769
sut = FileContextProvider.getInstance(project) as DefaultCodeWhispererFileContextProvider
6870
}
6971

72+
@Test
73+
fun `crossfile configuration`() {
74+
val userGroupSetting = mock<CodeWhispererUserGroupSettings>()
75+
ApplicationManager.getApplication().replaceService(CodeWhispererUserGroupSettings::class.java, userGroupSetting, disposableRule.disposable)
76+
77+
whenever(userGroupSetting.getUserGroup()).thenReturn(CodeWhispererUserGroup.Control)
78+
assertThat(CodeWhispererConstants.CrossFile.CHUNK_SIZE).isEqualTo(60)
79+
80+
whenever(userGroupSetting.getUserGroup()).thenReturn(CodeWhispererUserGroup.CrossFile)
81+
assertThat(CodeWhispererConstants.CrossFile.CHUNK_SIZE).isEqualTo(1000)
82+
}
83+
7084
@Test
7185
fun `shouldFetchUtgContext - fully support`() {
7286
assertThat(DefaultCodeWhispererFileContextProvider.shouldFetchUtgContext(CodeWhispererJava.INSTANCE, CodeWhispererUserGroup.CrossFile)).isTrue

0 commit comments

Comments
 (0)