Restore local SCP speed via Sprockets 4, fix Dockerized segfault (SCP-3531) #1109
+7
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes very long iteration times in local SCP instances, which affect almost all SCP engineers. Local page load times are now back to 3-5 seconds, down from 30-180 seconds.
Background
In a first, Mixpanel performance tracking for development helped diagnose this productivity bug.
git bisect
was used to isolate the causal commit. That commit downgraded from Sprockets 4 to Sprockets 3.7.2 to fix segfault errors on Ubuntu. The problematic change fixed the segfault when runningassets:precompile
[1] on Dockerized environments -- CI, staging, and production -- but caused severe slowness for non-Dockerized environments, i.e. development. Oddly, the slowness affected all engineers except one, who had made the change. An affected engineer verified they shared the same Ruby environment and general local setup as the unaffected engineer.Changes
These changes restore local speed while avoiding segfaults in Dockerized environments. The fix was copied from anecdotal solutions noted in the upstream issue, specifically here. The mechanism is unclear but seems effective. Over 5 runs of the triggering command (leveraging ways to rapid test here and here) have been successful.
The original segfault only occurred on 10-15% of deployments. So it's possible that these changes do not fix the segfault. If that proves so, then team chats have decided that the cost of very slow development outweighs the cost of an extra occasional few minutes of downtime and need to manually run the full command [1] in the production VM.
This satisfies SCP-3531.
sudo -E -u app -H bundle exec rake NODE_ENV=production RAILS_ENV=$PASSENGER_APP_ENV SECRET_KEY_BASE=$SECRET_KEY_BASE assets:precompile