Slide 1

Slide 1 text

The Journey of rubocop-daemon into RuboCop RubyKaigi 2024 LT 2024-05-16 - Hayato Kawai (@fohte)

Slide 2

Slide 2 text

Who Fohte (Hayato Kawai) Infra Engineer at Wantedly, Inc.

Slide 3

Slide 3 text

The Birth of rubocop-daemon

Slide 4

Slide 4 text

Motivation for Creating rubocop-daemon ● Running RuboCop in an editor is slow, typically taking about 1-2 seconds ○ Immediate feedback during coding is essential; the code written 1 second ago is too old!

Slide 5

Slide 5 text

Why RuboCop is Slow ● Each command execution reloads RuboCop: $ rubocop … require 'rubocop' RuboCop::CLI.new.run Terminal RuboCop $ rubocop … require 'rubocop' RuboCop::CLI.new.run

Slide 6

Slide 6 text

require 'rubocop' is Slow ● Just require 'rubocop' takes about 0.8 seconds without even the core 'lint' functionality $ rubocop … require 'rubocop' RuboCop::CLI.new.run Terminal RuboCop $ rubocop … require 'rubocop' RuboCop::CLI.new.run

Slide 7

Slide 7 text

💡 Could I try daemonization?

Slide 8

Slide 8 text

I created the rubocop-daemon gem in 2018.

Slide 9

Slide 9 text

Architecture of rubocop-daemon ● Save require 'rubocop' time by having a rubocop-daemon server preload it ○ similar to how an HTTP server operates: rubocop-daemon (server) $ rubocop-daemon exec … Terminal $ rubocop-daemon exec …

Slide 10

Slide 10 text

Lessons from rubocop-daemon

Slide 11

Slide 11 text

Gained organic recognition

Slide 12

Slide 12 text

Exciting OSS Buzz ● Being recognized as a third-party gem within the RuboCop community is rewarding ● Active issues and patches are also rewarding ○ It signs that the tool is beneficial and widely used

Slide 13

Slide 13 text

Challenges of OSS: Increasing Support Needs ● The more widely it is used, the more support for diverse environments is needed ○ In rubocop-daemon, some editors/plugins require setup guides ■ e.g. Vim, VSCode, …

Slide 14

Slide 14 text

Challenges of OSS: Not All Patches Can be Integrated ● Integrating a patch means taking ownership of that code ○ taking the responsibility for future issues and reviews.

Slide 15

Slide 15 text

Challenges of OSS: Not All Patches Can be Integrated ● In recognition of the time spent writing the patches, I want to integrate them. ○ It would be difficult to maintain everything

Slide 16

Slide 16 text

a few years later…

Slide 17

Slide 17 text

Finally integrated into RuboCop core in 2022 🎉 https://github.com/ruboco p/rubocop/pull/10706 Big Thanks to @koic

Slide 18

Slide 18 text

Finally integrated into RuboCop core in 2022 🎉 ● I'm happy that my feature is widely used by the RuboCop community ○ (I'm honored to have my name credited in the RuboCop files) ● Effectively handed over maintenance to RuboCop core team, who deserves trusting

Slide 19

Slide 19 text

Conclusion: OSS is a Great Culture ● OSS is a great culture but also brings challenges to OSS owners ● Contributing upstream isn't the only option ○ You can instead start with a third-party gem!