question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FSC: Consider enabling background JIT with non-dynamic PGO for faster compilation

See original GitHub issue

Context

I noticed that JIT takes a considerable amount of time in compilation, and the fraction of time it takes is especially high for small projects.

I experimented with using non-dynamic PGO for JITting to allow JITting to happen in the background, before its results are needed.

Tests

I tested it against an empty project from the dotnet template (just one file). The PGO-enabled compilation was ~300ms faster (~0.95s -> ~0.65s). I generated the profile by running compilation on the same test project a few times, and measured timings then.

Here is a profile showing JIT work happening without PGO: image It shows 1200ms of JIT on the main thread, and similar amount on other threads (mostly blocking actual work).

Here is a profile showing JIT work happening with PGO: image It shows 835ms of JIT on the main thread, ~700ms on other work threads, and 1250ms on a dedicated JITting thread (CLR worker).

Questions

  • Am I missing something? Is non-dynamic PGO being used already somehow?
  • Are there any major drawbacks to using this?
  • If enabled, how would the profile be deployed/generated on the end-user’s machine? Would hiding it behind a feature flag/env variable make sense?
  • Can SDK ship no profile and let the user’s first build generate one? We could use profile names based on the name of the project being compiled. This means no deployment changes are needed, and it can be fully controlled by the enduser
  • I know dynamic PGO exists in NET6, but I don’t think that’s needed for the compilation process.
  • I’m aware background compiler service might become a reality at some point, making JIT irrelevant, but this solution seems so cheap that it should be worth considering anyway.

Issue Analytics

  • State:open
  • Created 3 months ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
jkotascommented, Jun 19, 2023

I know very little about it and how well tested it is maybe @jkotas knows better?

Multicore JIT is supported feature. If you run into functional problems with it, we will investigate them. It is used by Powershell.

0reactions
vzarytovskiicommented, Jul 10, 2023

The flag I tested is 3 lines of code and requires no changes in the deployment.

It only looks like it 😃 We need to make changes to several places, including (probably) our signed build (both SDK and VS), dotnet/dotnet, source build, maybe something else (because we don’t “maintain” flags for publishing).

MIBC might be the easiest solution here (I have added almost everything which is needed, so it’s already in progress).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managed Profile-Guided Optimization Using Background JIT
I'll refer to this technique as dynamic MPGO. Use background JIT to hide as much as possible the overhead to JIT by intelligently...
Read more >
Dynamic PGO · Issue #43618 · dotnet/runtime
Dynamic PGO enables the JIT to do in-process profiling of methods that pass through Tier0, and then use this data at Tier1. If...
Read more >
**What is Dynamic PGO and what does it improve over ...
Dynamic PGO leverages Tiered Compilation to perform this optimization process on the fly. If Dynamic PGO is enabled (it's an opt in) the...
Read more >
From First Principles: Why Scala?
I am a Scala programmer & think it's a great language. Here are some arguments for why not Scala: * Li's libs (os-lib,...
Read more >
Untitled
Adorable pics of baby animals, Pondok pesantren al husain krakitan, Paththini maniyo song, Ajani goldmane card value, Royal collection baby china, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found