Re-optimization using JITLink

Description of the project: In Just-In-Time compilers we often choose a low optimization level to minimize compile time and improve launch times and latencies, however some functions (which we call hot functions) are used very frequently and for these functions it is worth optimizing more heavily. In general hot functions can only be identified at runtime (different inputs will cause different functions to become hot), so the aim of the reoptimization project is to build infrastructure to (1) detect hot functions at runtime and (2) compile them a second time at a higher optimization level, hence the name "re-optimization".

There are many possible approaches to both parts of this problem. E.g. hot functions could be identified by sampling, or using existing profiling infrastructure, or by implementing custom instrumentation. Reoptimization could be applied to whole functions, or outlining could be used to enable optimization of portions of functions. Re-entry into the JIT infrastructure from JIT’d code might be implemented on top of existing lazy compilation, or via a custom path.

Whatever design is adopted, the goal is that the infrastructure should be generic so that it can be used by other LLVM API clients, and should support out-of-process JIT-compilation (so some of the solution will be implemented in the ORC runtime).

Expected result:

  • Improve ergonomics of indirection – ideally all forms of indirection (for re-optimization, lazy compilation, and procedure-linkage-tables) should be able to share a single stub (and/or binary rewriting metadata) at runtime.
  • Implement basic re-optimization on top of the tidied up indirection.
  • (Stretch goal) Garbage-collect unoptimized code that is no longer needed once the optimized version is available.

Desirable skills: Intermediate C++; Understanding of LLVM and the LLVM JIT in particular.

Project size: Large.

Difficulty: Medium

Confirmed Mentor: Vassil Vassilev, Lang Hames

1 Like


I have a question about “Project size: Large.”
How long do you expect us to dedicate to this project, and from when to when? Because some of us are studying abroad and VISA may not allow us to work for more than specific hours.


I found a blog post about it! So, in our case, do we not necessarily need to finish the project in 12 weeks or work unpaid when the working hours exceed? Do you have any chance to make the plan flexible? (I am asking the college administration what hours I can work during the summer break simultaneously.)

Time management for contributors | Google Summer of Code Guides

GSoC needs an investment of about 175 hours for medium size projects and 350 hours for large projects.

Hi @diohabara,

Large means 350 hours as you correctly pointed out.

GSoC is quite flexible in that respect and we can organize the time according to your schedule. You can probably frontload a lot of the work. In terms of, VISA and payment schedule, there is no difference between both project kinds. I know some cases where the GSoC admins have allowed earlier payments due to the US student VISAs.

It is very much dependent on the particular case.

Hi @vvassilev,

Thank you for your quick response. I’m glad you clarified the question.

I have another question about the application.
We are allowed to submit no more than three applications per summer, according to the official Q&A site.

Yes, each GSoC Contributor may submit up to three proposals. However, only one per GSoC Contributor may be accepted. No more than one proposal per GSoC Contributor will be accepted, no matter how many proposals you submit.

I am interested in this and your other project, which is also related to JITLink. I would like to have a correction made before I submit it. Is that possible? In that case, would it be a burden to make two corrections, and should I focus on only one before revising my application?

Thank you for your time.

You can make modifications to your proposal anytime before the deadline (or clicking on the submit button depending on the current features of their submission system). Generally you are advised to solicit the proposal with your mentors before submitting to increase your chances.

Note that currently the GSoC program is in very early stages and they are currently in process of approving the organization. Once the organizations are approved we can start the process as for each organization that applies there is a non-zero chance to not be approved.

1 Like

Thank you for your advice & warnings.
I will keep that possibility in mind as I draft the proposal.

I am Rushabh Shah, a third year computer science student from BITS Pilani Goa and I’m interested in working on this project.
I have gone through LLVM documentation and made a basic compiler with help from the getting started guide, I’ve built LLVM and am currently going through the documentation for LLVM JIT.
I was wondering if there are any patches or issues I could work on related to JIT or JITLink to get a better understanding on this project and contributing to LLVM. I’ve gone through the Issues pages on GitHub but couldn’t find a good place to start for JIT.
Thank you for your time :blush:

Hi @rushabh101,

Thanks for reaching out. I’d propose to go through the examples in the Kaleidoscope tutorials. There you can grasp many of the JIT concepts.

Generally going through the bugtracker and scanning for “good first issue” label is a good start.

On the JIT/JITLink side @lhames might be able to help.

Best, Vassil

Hi @mjachi, apologies for the delay, I have been swamped recently. This project is assumes some hands on experience in the area as it is non-trivial. If you send me your CV (in private) I might be able to suggest something that would be a better project to enter the LLVM/JIT realm.

Hi Vassil,
I was wondering if this project has already been taken up. I don’t intend to participate through GSoC, since I’m not even eligible. But I wanted to see if you would be willing to mentor me as an unfunded contributor. If the answer is yes, I’d love to discuss next steps with you.