3 पॉइंट द्वारा GN⁺ 2023-07-04 | 1 टिप्पणियां | WhatsApp पर शेयर करें
  • Arena या region, compiler और compiler-जैसी चीज़ों के लिए एक सरल और प्रभावी तकनीक हैं.
  • Arena का उपयोग करके abstract syntax tree (AST) को flatten करने से performance बेहतर हो सकती है और सुविधा मिल सकती है.
  • Flattening का मतलब है AST nodes को एक single array में pack करना और pointers की जगह array indices का उपयोग करना.
  • Flattened AST बेहतर locality, छोटे references, सस्ती allocation और deallocation जैसे फ़ायदे देते हैं.
  • Flattened AST memory management को सरल बना सकते हैं और सुविधाजनक deduplication संभव कर सकते हैं.
  • Performance results दिखाते हैं कि flattened interpreter version, सामान्य version की तुलना में 2.4 गुना तेज़ हो सकता है.
  • AST के flat representation का उपयोग करके recursion हटाई जा सकती है और linear traversal का लाभ लेकर performance को और बेहतर किया जा सकता है.
  • यह लेख programming language interpreter में data structure flattening के ज़रिए हासिल किए गए performance improvements पर चर्चा करता है.
  • इसके अतिरिक्त, flattened interpreter recursion-based interpreter की तुलना में 1.2 सेकंड बनाम 1.3 सेकंड के साथ 8.2% performance improvement दिखाता है.
  • यह तकनीक मूल रूप से bytecode interpreter के विचार को फिर से खोजती है, जहाँ Expr struct bytecode instruction के रूप में इस्तेमाल होती है.
  • LuaJIT, Sorbet type checker, Oil shell आदि से जुड़े data structure flattening पर अन्य लेखों और projects का उल्लेख किया गया है.
  • Video games, serialized data processing, data-oriented design, और entity-component systems जैसे domains में भी flattening और locality optimization से जुड़े समान concepts दिखाई देते हैं.
  • यह लेख Rust में implemented toy "calculator" language पर यही तकनीक लागू करने वाली Inanna Malick की post देखने की सिफारिश करता है.
  • Rust में इस तकनीक के उपयोग की सीमाओं पर चर्चा की गई है, जिनमें यह सीमा शामिल है कि Expr struct के अंदर दूसरे Expr को inline शामिल नहीं किया जा सकता.
  • Performance comparison, M1 Max processor और 32GB memory वाले MacBook Pro पर macOS 13.3.1 और Rust 1.69.0 चलाने वाले environment में किया गया था.

1 टिप्पणियां

 
GN⁺ 2023-07-04
Hacker News राय
  • Blender तेज़ और lossless file loading तथा saving के लिए disk और memory में एक ही representation का उपयोग करता है.
  • efficient inline markup parsing के लिए pulldown-cmark में flattened AST का उपयोग किया जाता है.
  • flattened AST representation, node count या stack depth की परवाह किए बिना, O(1) tree transformation को संभव बनाता है.
  • अन्य CommonMark parsers की तुलना में pulldown-cmark का performance बेहतरीन है.
  • Warren Abstract Machine (WAM), Prolog के लिए heap पर flattened representation का उपयोग करता है.
  • AST flattening, Lisp जैसी भाषाओं में पहले से उपयोग की जा रही एक अवधारणा थी.
  • resizable array में nodes को store करना memory allocation समस्याएँ पैदा कर सकता है, लेकिन page-size blocks में pooling करके इसे कम किया जा सकता है.
  • code में AST nodes को कैसे represent किया जाता है, इस पर सावधानी ज़रूरी है, और अनावश्यक padding से बचना चाहिए.
  • pointers की जगह indices का उपयोग करने से छोटा और तेज़ code मिल सकता है.
  • कुछ विशेष scenarios में उपयोगी custom memory allocator का इस्तेमाल करके flattened memory को implement किया जा सकता है.
  • memory-constrained environments में JavaScript parser और interpreter को implement करने के लिए compact AST structure का उपयोग किया गया था.