We use Moodle to power a very large LTI provider system (600k tools, 8k courses, still just in pilot), and the current cron system for sending back grades takes forever. It could easily take an hour to send everything with the current loops and queries. I optimized them for our setup and it can still take 3 minutes. Running the cron every 5 minutes, that's still too long of a delay to wait for grades to show up.
Our solution for getting over this issue was to update grade_update() in gradelib.php to send the grades immediately. We'll be updating the LTI provider plugin cron job to then only act as a fallback and send grades that failed to go back immediately for whatever reason.
Now that LTI provider is part of core, this is likely code that a lot of other people can make use of if it was part of core. I don't have a check to see if the LTI provider plugin is enabled, since we're still on 3.0.3+, but that would likely make sense before this made it in to core.
The code updates are very simple, and just in gradelib.php.
On line 2 of the file add
In grade_update(), on line 295 (of the version we're running), inside of if (!$failed), before return GRADE_UPDATE_OK, add the following code
It's basically taken from the LTI provider plugin, with a couple minor changes. Again, to go in to core I'd wrap it in a check that the LTI enrolment plugin is active. All of our grades are also LTI, so a check if $user actually returns something would be smart for systems that have people using Moodle directly along with LTI users, so it's not erroring trying to send back grades on non-LTI activities.