Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jit: Introduce background compilation #457

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

qwe661234
Copy link
Collaborator

Given the significant runtime compilation overhead associated with performing aggressive optimizations, we have implemented a background compilation mechanism to mitigate this issue. When the runtime profiler identifies a strong hotspot, it adds a T2C compilation request to the wait queue. A background thread, which continuously monitors this queue, triggers T2C to process the requests and notifies the main thread upon completion by updating a flag.

This mechanism defers the execution of T2C-generated machine code, leading to more frequent use of T1C-generated code. Despite this, the approach effectively minimizes runtime compilation delays by eliminating the need for the main thread to wait for T2C compilation to complete, thereby improving overall performance.

  • The workflow of background compilation.
    image

  • The performance comparison with and without the background compialtion.
    image

Close: #239

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Benchmarks

Benchmark suite Current: 51ce53b Previous: 6b462c0 Ratio
Dhrystone 5.22 Average DMIPS over 10 runs 4.88 Average DMIPS over 10 runs 0.93
Coremark 0.004 Average iterations/sec over 10 runs 0.004 Average iterations/sec over 10 runs 1

This comment was automatically generated by workflow using github-action-benchmark.

@jserv jserv added this to the release-2024.1 milestone Jun 13, 2024
src/riscv.c Outdated Show resolved Hide resolved
src/riscv_private.h Outdated Show resolved Hide resolved
@jserv jserv requested a review from vacantron June 13, 2024 05:52
@qwe661234 qwe661234 force-pushed the Add_bg_thread branch 3 times, most recently from eb20baf to 2f5e037 Compare June 13, 2024 05:58
src/riscv.c Outdated Show resolved Hide resolved
src/riscv.c Outdated Show resolved Hide resolved
@qwe661234 qwe661234 force-pushed the Add_bg_thread branch 2 times, most recently from 8b87096 to d03919d Compare June 13, 2024 06:07
@jserv
Copy link
Contributor

jserv commented Jun 13, 2024

I defer to @vacantron for confirmation.

@jserv jserv changed the title Introduce background compilation jit: Introduce background compilation Jun 13, 2024
src/riscv.c Show resolved Hide resolved
src/riscv.c Outdated Show resolved Hide resolved
src/feature.h Show resolved Hide resolved
src/riscv.c Outdated
(uint64_t) ((memory_t *) PRIV(rv)->mem)->mem_base);
free(entry);
}
/* Instead of writing while(rv->quit), placing the code here prevents
Copy link
Contributor

Choose a reason for hiding this comment

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

Does volatile help for such purpose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it works.

Given the significant runtime compilation overhead associated with
performing aggressive optimizations, we have implemented a background
compilation mechanism to mitigate this issue. When the runtime profiler
identifies a strong hotspot, it adds a T2C compilation request to the
wait queue. A background thread, which continuously monitors this queue,
triggers T2C to process the requests and notifies the main thread upon
completion by updating a flag.
@jserv jserv merged commit 4bb8593 into sysprog21:master Jun 18, 2024
8 checks passed
@jserv
Copy link
Contributor

jserv commented Jun 18, 2024

Finally, T2C is landed!

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.

jit: Background compilation thread
3 participants