Skip to content

Integrate JiT compilation into CLI#2110

Open
rafal-hawrylak wants to merge 5 commits intomainfrom
cli_jit_integration
Open

Integrate JiT compilation into CLI#2110
rafal-hawrylak wants to merge 5 commits intomainfrom
cli_jit_integration

Conversation

@rafal-hawrylak
Copy link
Collaborator

No description provided.

@rafal-hawrylak rafal-hawrylak self-assigned this Mar 9, 2026
@rafal-hawrylak rafal-hawrylak marked this pull request as ready for review March 9, 2026 20:28
@rafal-hawrylak rafal-hawrylak requested a review from a team as a code owner March 9, 2026 20:28
@rafal-hawrylak rafal-hawrylak enabled auto-merge (squash) March 9, 2026 20:28
- Enhance error coercion in common/errors/errors.ts
- Sync protos/execution.proto and protos/jit.proto with new fields
* feat: add worker process management for JiT compilation

- Introduce base worker and JiT-specific child process logic

- Implement RPC bridge for database access during JiT

- Add VM scripts and loader for isolated execution

- Add unit tests for the RPC mechanism
* feat: add action descriptor support to JiT compilation results

- Implement action and column descriptor logic in core/jit_compiler.ts

- Support overrides for descriptions, labels, and tags in JiT results

- Enhance error coercion in common/errors/errors.ts

- Add comprehensive JiT metadata tests in core/jit_compiler_test.ts

- Sync protos/execution.proto and protos/jit.proto with new result fields
* feat: enable JiT compilation in CLI run, build and compile commands

- Connect main CLI execution flow to the JiT worker process

- Add comprehensive JiT test suite

- Finalize AoT build logic to preserve JiT-specific fields

- Update CLI console and entry points for integrated JiT support
Copy link
Contributor

@kolina kolina left a comment

Choose a reason for hiding this comment

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

Let's test compatibility with different Dataform core versions.

Also this change seems worth it to bump a minor version of Dataform core

this.childProcess.on("close", exitCode => {
if (exitCode !== 0) {
reject(new Error(`Compilation child process exited with exit code ${exitCode}.`));
const timeoutValue = compileConfig.timeoutMillis || DEFAULT_COMPILATION_TIMEOUT_MILLIS;
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that the default timeout is smaller currently?

reject(coerceAsError(messageOrError));
});

this.childProcess.on("close", exitCode => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify: in the base worker you have a hook for "exit", they'll be equivalent?

return await compileInChildProcess;
} finally {
if (!this.childProcess.killed) {
this.childProcess.kill("SIGKILL");
Copy link
Contributor

Choose a reason for hiding this comment

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

In the base worker you don't send SIGKILL, I'd preserve this logic to avoid compiler ignoring SIGTERM for some reason

private readonly dbadapter: dbadapters.IDbAdapter,
private readonly graph: dataform.IExecutionGraph,
private readonly executionOptions: IExecutionOptions = {},
private readonly projectDir: string,
Copy link
Contributor

Choose a reason for hiding this comment

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

if it's part of IExecutionOptions, do you need to pass it separately?

if (this.stopped) {
return actionResult;
try {
await this.dbadapter.withClientLock(async client => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This withClientLock function doesn't do anything meaningful today (maybe it was needed before when we supported other warehouses), I'd remove it.

type: "table",
tableType: "incremental",
jitCode: `async (jctx) => {
return jctx.incremental() ? "SELECT 'inc' as t" : "SELECT 'full' as t";
Copy link
Contributor

Choose a reason for hiding this comment

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

add a test for incremental mode?

this.childProcess = childProcess;
export class CompileChildProcess extends BaseWorker<string, string | Error> {
constructor() {
super("../../vm/compile_loader");
Copy link
Contributor

Choose a reason for hiding this comment

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

Do I understand correctly that this will change the order of fork script resolution? I'd prefer to keep the original order

Comment on lines +14 to +16
// AoT compile() in cli/vm/compile.ts returns a JSON string of CompiledGraph.
// We need to wrap it in a CoreExecutionResponse and Base64 encode it
// to match what cli/api/commands/compile.ts expects.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it true? From my reading of code:

  • compile in cli/vm/compile.ts calls main function of Dataform core and returns its result here, in the CLI we always pass base-64 core execution request here
  • The main function in the Dataform core in this case returns base64-encoded serialized proto response here (comment about older version of the Dataform CLI is a bit confusing)

reserved 1, 3, 7, 13;
bool disabled = 15;

reserved 1, 3, 7;
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we have less reserved field numbers here?

await callback(mockDbAdapterInstance);

const runner = new Runner(mockDbAdapterInstance, RUN_TEST_GRAPH);
const runner = new Runner(mockDbAdapterInstance, RUN_TEST_GRAPH, ".");
Copy link
Contributor

Choose a reason for hiding this comment

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

If someone uses the Dataform CLI as a library, will they need to update their code in the same manner?

Copy link
Collaborator

@ikholopov-omni ikholopov-omni left a comment

Choose a reason for hiding this comment

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

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.

3 participants