Skip to content

Apply -X NoAdaptiveCompilation to all or regex-ed code - #2144

Open
BCSharp wants to merge 2 commits into
IronLanguages:mainfrom
BCSharp:compile-regex
Open

BCSharp wants to merge 2 commits into
IronLanguages:mainfrom
BCSharp:compile-regex

Conversation

@BCSharp

@BCSharp BCSharp commented Nov 4, 2026

Copy link
Copy Markdown
Member

This resolves the last question from #2126. Most compilation options cover all code (CompilationThreshold, Tracing, NoFrames/Frames/FullFrames, GCStress, MaxRecursion, EnableProfiler, -O/-OO), so NoAdaptiveCompilation (which compiles unconditionally) naturally should do the same. But since disabling adaptive compilation for all code significantly increases start time (though not as much as -X CompilationThreshold=0), I opted for an optional regex to filter modules to where the adaptive compilation should be disabled.

In a way how -X Debug and -X NoDebug=<regex> used to work.

However, something seems wrong with Debug/NoDebug. It does not apply to anything beyond __main__ since #599. That's a separate issue, I am not pursuing it.

@slozier slozier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.


case "NoAdaptiveCompilation":
LanguageSetup.Options["NoAdaptiveCompilation"] = ScriptingRuntimeHelpers.True;
if (val != null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe LanguageSetup.Options.Remove("NoAdaptiveCompilationFilter")?

}

internal bool ShouldInterpret(PythonCompilerOptions options, SourceUnit source) {
if (IsAdaptiveCompilationDisabled(source)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does a regex match on every call that has a filter? I guess it's probably lost in the noise.

@BCSharp BCSharp Nov 5, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. There is a cache in PythonAst, applicable to functions, generators and class bodies in imported modules and exec/eval code, but not for module bodies and a few other code paths. I will push an update.

I've also noticed that -X Debug -X NoDebug=… runs its filtering regex on each read. I leave it to whoever will be fixing -X Debug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants