• Bundler की performance limits का विश्लेषण करते हुए, Python के package manager uv के तेज़ होने के कारणों की तुलना
  • uv की speed का कारण Rust language नहीं, बल्कि parallel downloads, global cache, metadata-based dependency handling जैसी structural design choices हैं
  • Bundler में download और install process आपस में जुड़े हुए हैं, जिससे parallel processing पर पाबंदी लगती है; इन्हें अलग करने पर बड़ा सुधार संभव है
  • global cache integration, hardlink installs, PubGrub resolver integration आदि से RubyGems और Bundler के duplication को कम किया जा सकता है
  • language rewrite के बिना भी ज़्यादातर performance gains Ruby code के भीतर हासिल किए जा सकते हैं, और uv-स्तर की speed के काफ़ी करीब पहुँचा जा सकता है

Bundler और uv की performance तुलना

  • RailsWorld में उठे “Bundler, uv जितना तेज़ क्यों नहीं है?” सवाल के बाद Bundler के performance bottlenecks की जाँच की गई
  • लेखक को भरोसा है कि Bundler, uv-स्तर की speed हासिल कर सकता है, और वे साफ़ कहते हैं कि performance gap भाषा का नहीं, design का मसला है
  • Andrew Nesbitt के लेख “How uv got so fast” का हवाला देते हुए, uv की core optimization techniques को Bundler पर लागू किया जा सकता है या नहीं, इसका विश्लेषण किया गया

क्या Rust में rewrite ज़रूरी है?

  • यह सही है कि uv, Rust में लिखा गया है, लेकिन उसकी speed का मूल कारण Rust itself नहीं है
  • अगर Bundler के bottlenecks हटाने के बाद “अब सिर्फ Rust में rewrite ही अगला सुधार है” वाली स्थिति आ जाए, तो उसे सफलता माना जाएगा
  • Rust rewrite से मौजूदा compatibility constraints के बिना experimental design आज़माने की आज़ादी मिलती है, लेकिन यह अनिवार्य नहीं है

Bundler के structural bottlenecks

  • Bundler, gem download और install को एक ही method में जोड़ता है, जिससे parallel downloads संभव नहीं हो पाते
    • example code में install method, fetch_gem_if_not_cached और install को लगातार चलाता है
    • इसकी वजह से dependency chain वाले gem (a -> b -> c) सिर्फ sequentially install हो पाते हैं
  • प्रयोग में पाया गया कि dependencies होने पर 9 सेकंड से ज़्यादा लगते हैं, जबकि independent gems (d, e, f) parallel download के साथ 4 सेकंड से कम में पूरे हो जाते हैं
  • download और install को अलग करने पर dependency rules बनाए रखते हुए भी parallel processing संभव हो जाती है
    • चार चरणों में विभाजन का प्रस्ताव: download → unpack → compile → install
    • pure Ruby gems के लिए dependency install order को और ढीला करके अतिरिक्त speed gain मिल सकता है

cache और install optimization

  • uv की global cache और hardlink install approach, Bundler पर भी लागू की जा सकती है
    • Bundler और RubyGems अभी Ruby version के हिसाब से अलग-अलग cache इस्तेमाल करते हैं
    • $XDG_CACHE_HOME आधारित shared cache में इन्हें एकीकृत करने की ज़रूरत है
    • hardlink install, cache integration के बाद लागू किया जा सकता है
  • Bundler पहले से PubGrub dependency resolver इस्तेमाल करता है, लेकिन RubyGems अब भी molinillo का उपयोग करता है
    • दोनों systems के resolver integration को technical debt कम करने की कुंजी माना गया है

Rust-संबंधित optimization तत्वों की लागू-योग्यता

  • Zero-copy deserialization को RubyGems के YAML parsing stage में कुछ हद तक लागू किया जा सकता है
  • Ruby का GVL(Global VM Lock), IO-केंद्रित कामों में parallel processing पर बहुत बड़ी पाबंदी नहीं लगाता
    • IO और ZLIB processing के दौरान GVL release हो जाता है, इसलिए parallel execution संभव है
    • लेकिन छोटे file writes में GVL management overhead performance drop का कारण बनता है
    • Ruby के भीतर इसे बेहतर बनाने का काम चल रहा है
  • version comparison optimization: uv, versions को u64 integer में encode करके comparison तेज़ करता है
    • Ruby में भी Gem::Version को integer-based representation में बदलकर resolver performance सुधारी जा सकती है
    • इस दिशा में refactoring की कोशिश पहले हुई थी, लेकिन backward compatibility issues की वजह से उसे टाल दिया गया

निष्कर्ष और आगे की योजना

  • uv की speed, भाषा से ज़्यादा अनावश्यक काम हटाने वाली design की देन है, और Bundler को भी उसी दिशा में बेहतर बनाया जा सकता है
  • RubyGems और Bundler के पास पहले से modern package management structure मौजूद है, इसलिए uv-स्तर की speed हासिल करना व्यावहारिक लक्ष्य है
  • सबसे बड़ी चुनौती legacy code और compatibility बनाए रखना है
  • Rust में rewrite किए बिना भी 99% performance improvement Ruby code के भीतर संभव है, और बाकी 1% का असर मामूली होगा
  • अगली पोस्ट में Bundler और RubyGems की वास्तविक profiling और ठोस bottleneck causes पर चर्चा की जाएगी

अभी कोई टिप्पणी नहीं है.

अभी कोई टिप्पणी नहीं है.