Revision e4ec80ff19b51a4cdf6d41da0b15b559f8514c2b authored by Shuhei Kadowaki on 10 January 2024, 16:48:28 UTC, committed by Shuhei Kadowaki on 11 January 2024, 08:56:13 UTC
REPL utilizes inference for smarter completions, but since its inference
engine is independent from the native cache and issues like #52763 in
`REPLInterpreter`'s inference, sometimes delays can be noticeable during
tab/hint-completion, and REPL can even freeze in the worst cases.

To address this, the commit allows tab/hint-completion to run
asynchronously on a `:default` thread. This approach removes delays in
multi-threaded process and prevents REPL hang in extreme cases like #52763.
In detail, for tab-completion, completion task simply runs on a separate
thread since completion itself does not block anything. For
hint-completion however, considering that a stuttering display of hints
can be bothersome, when the completion task doesn't conclude within
0.01 sec, we cancel the hint-completion to keep the input in the REPL
smooth.

There are still some points left open for discussion:
- Is it better to allocate a separate thread specifically for REPL
  completion? I'm not sure if this is even possible though.
- Should we make this an optional feature, considering the concern some
  users might have about reduced thread resources?
- For situations where completion hangs or is slow, like in #52763,
  canceling the completion task to release resources would be ideal.
  However, my understanding is that there's no safe method to cancel a
  task, is it correct?
- At present, this commit `Threads.@spawn`s at a relatively high level
  in the completion pipeline. But it might be more effective to
  `Threads.@spawn` closer to the point where inference is actually
  invoked, such as in `complete_line` or `repl_eval_ex`.
1 parent 73cdfd8
Raw File
.clang-format
Language: Cpp
Standard: Cpp11
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Stroustrup
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: BeforeColon
BreakConstructorInitializersBeforeComma: false
BreakInheritanceList: BeforeColon
BreakStringLiterals: false
ColumnLimit: 92
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
IncludeBlocks: Preserve
IncludeCategories:
  - Regex:           '^(<|"(llvm|llvm-c|clang|clang-c)/)'
    Priority:        2
  - Regex:           '^<.*'
    Priority:        3
  - Regex:           '.*'
    Priority:        1
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 8
UseCRLF: true
UseTab: Never
ForEachMacros:
  - JL_TRY
  - JL_CATCH
StatementMacros:
  - bi_fintrinsic
  - bi_iintrinsic_fast
  - bi_intrinsic_ctype
  - bool_fintrinsic
  - bool_iintrinsic_fast
  - bool_intrinsic_ctype
  - checked_intrinsic_ctype
  - cvt_iintrinsic
  - fpiseq_n
  - ter_fintrinsic
  - ter_intrinsic_ctype
  - un_fintrinsic
  - un_fintrinsic_withtype
  - un_iintrinsic_ctype
  - uu_iintrinsic_ctype
back to top