[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-133534-en":3,"doc-seo-133534-105":30,"detail-sidebar-cat-0-en-105":92},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":20,"is_deleted":4,"is_public":20,"is_downloadable":20,"audit_status":20,"page_count":21,"language":22,"language_code":23,"site_id":24,"html_lang":23,"table_of_contents":25,"faqs":26,"seo_title":27,"seo_description":14,"update_tm":28,"read_time":29},133534,2336464648746,"Skyler","https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c",6,"Technology","Merlin - Multi-tier Optimization of eBPF Code for Performance and Compactness","eBPF (extended Berkeley Packet Filter) improves observability, performance, and security in the Linux kernel by executing safe, sandboxed bytecode through a register-based virtual machine with a customized ISA and strict verifier constraints. These limits, such as a restricted instruction budget, make efficient optimization essential, yet existing tools often miss key opportunities. Merlin introduces an optimization framework using customized LLVM passes and bytecode rewriting before verification, applying instruction merging and strength reduction. Evaluation on 19 XDP programs and three eBPF-based systems shows successful verification, 73% fewer instructions, 60% lower runtime overhead, and improved throughput/latency versus K2, with higher scalability.","Merlin: Multi-tier Optimization of eBPF Code for Performance and Compactness  \nJinsong Mao  \n[jinsongmao@umass.edu](jinsongmao@umass.edu)[ ](jinsongmao@umass.edu)University of Massachusetts Amherst USA  \nJuan Zhai  \n[juanzhai@umass.edu](juanzhai@umass.edu)[ ](juanzhai@umass.edu)University of Massachusetts Amherst USA  \nHailun Ding  \n[hailun.ding@rutgers.edu](hailun.ding@rutgers.edu)[ ](hailun.ding@rutgers.edu)Rutgers University USA  \nShiqing Ma  \n[shiqingma@umass.edu](shiqingma@umass.edu)[ ](shiqingma@umass.edu)University of Massachusetts Amherst USA  \nAbstract  \neBPF (extended Berkeley Packet Filter) significantly enhancesobservability, performance, and security within the Linux kernel, playing a pivotal role in various real-world applications. Implemented as a register-based kernel virtual machine, eBPF features a customized Instruction Set Architecture (ISA) with stringent kernel safety requirements, e.g., a limited number of instructions. This constraint necessitates substantial optimization efforts for eBPF programs to meet performance objectives. Despite the availability of compilers supporting eBPF program compilation, existing tools often overlook key optimization opportunities, resulting in suboptimal performance. In response, this paper introduces Merlin, an optimization framework leveraging customized LLVM passes and bytecode rewriting for Instruction Representation (IR) transformation and bytecode refinement. Merlin employs two primary optimization strategies, i.e., instruction merging and strength reduction. These optimizations are deployed before eBPF verification. We evaluate Merlin across 19 XDP programs (drawn from the Linux kernel, Meta, hXDP, and Cilium) and three eBPF-based systems (Sysdig, Tetragon, and Tracee, each comprising several hundred eBPF programs) . The results show that all optimized programs pass the kernel verification. Meanwhile, Merlin can reduce number of instructions by 73% and runtime overhead by 60% compared with the original programs. Merlin can also improve the throughput by 0.59% and reduce the latency by 5.31%, compared to state-of-the-art technique K2 , while being 106 times faster and more scalable to larger and more complex programs without additional manual efforts.  \nPermission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for thirdparty components of this work must be honored. For all other uses, contact the owner/author(s) .  \nASPLOS’24, April 27-May 1, 2024, La Jolla, CA, USA © 2024 Copyright held by the owner/author(s) .  \nACM ISBN 979-8-4007-0386-7/24/04 .  \n[https://doi.org/10.1145/3620666.3651387](https://doi.org/10.1145/3620666.3651387)  \nCCS Concepts: • Hardware → Emerging languages and compilers; • Software and its engineering → Software performance.  \nKeywords: eBPF Optimization, LLVM  \nACM Reference Format:  \nJinsong Mao, HailunDing, Juan Zhai, and Shiqing Ma. 2024. Merlin: Multi-tier Optimization ofeBPF Code for Performance and Compactness. In 29th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 3 (ASPLOS’24), April 27-May 1, 2024, La Jolla, CA, USA. ACM, New York, NY, USA, 15 pages. [https://doi.org/10.1145/3620666.3651387](https://doi.org/10.1145/3620666.3651387)  \n1 Introduction  \nExtended Berkeley Packet Filter (eBPF) is a Linux kernel technology that allows safe, sandboxed execution of userprovided programs to efficiently observe and trace various kernel objects like networking stacks, system calls, and filesystems [8] . eBPF provides a programmable interface for users to customize monitoring and performance analysis without having to modify kernel source code. Since its introduction in Linux kernel 4.4, eBPF has been widely adopted in major cloud providers and companie","cbCaiphKkARbwMKh","https://ap.wps.com/l/cbCaiphKkARbwMKh","pdf",2825390,1,15,"English","en",105,"# Abstract\n# Introduction","[{\"question\":\"What problem does Merlin address in eBPF program deployment?\",\"answer\":\"eBPF bytecode is limited in length and instruction count and must satisfy strict verifier checks, so many useful programs need heavy optimization to both pass verification and achieve good performance.\"},{\"question\":\"How does Merlin optimize eBPF code before verification?\",\"answer\":\"Merlin uses customized LLVM passes and bytecode rewriting to transform instruction representation, then applies two main strategies: instruction merging and strength reduction.\"},{\"question\":\"What performance and compactness gains does Merlin achieve?\",\"answer\":\"Across 19 XDP programs and three systems, Merlin reduces instruction count by 73% and runtime overhead by 60%, and improves throughput and latency compared with the K2 state-of-the-art technique.\"}]","Merlin - Multi-tier Optimization of eBPF Code for Performance and Compactness | PDF",1787221469,38,{"code":4,"msg":31,"data":32},"ok",{"site_id":24,"language":23,"slug":33,"title":13,"keywords":34,"description":14,"schema_data":35,"social_meta":87,"head_meta":89,"extra_data":91,"updated_unix":28},"merlin-multi-tier-optimization-of-ebpf-code-for-performance-and-compactness","",{"@graph":36,"@context":86},[37,54,69],{"@type":38,"itemListElement":39},"BreadcrumbList",[40,44,48,51],{"item":41,"name":42,"@type":43,"position":20},"https://docshare.wps.com","Home","ListItem",{"item":45,"name":46,"@type":43,"position":47},"https://docshare.wps.com/document/","Document",2,{"item":49,"name":12,"@type":43,"position":50},"https://docshare.wps.com/document/technology/",3,{"item":52,"name":13,"@type":43,"position":53},"https://docshare.wps.com/document/merlin-multi-tier-optimization-of-ebpf-code-for-performance-and-compactness/133534/",4,{"url":52,"name":13,"@type":55,"author":56,"headline":13,"publisher":58,"fileFormat":61,"inLanguage":23,"description":14,"dateModified":62,"datePublished":63,"encodingFormat":61,"isAccessibleForFree":64,"interactionStatistic":65},"DigitalDocument",{"name":9,"@type":57},"Person",{"url":41,"name":59,"@type":60},"DocShare","Organization","application/pdf","2026-08-23","2026-08-20",true,{"@type":66,"interactionType":67,"userInteractionCount":20},"InteractionCounter",{"@type":68},"ViewAction",{"@type":70,"mainEntity":71},"FAQPage",[72,78,82],{"name":73,"@type":74,"acceptedAnswer":75},"What problem does Merlin address in eBPF program deployment?","Question",{"text":76,"@type":77},"eBPF bytecode is limited in length and instruction count and must satisfy strict verifier checks, so many useful programs need heavy optimization to both pass verification and achieve good performance.","Answer",{"name":79,"@type":74,"acceptedAnswer":80},"How does Merlin optimize eBPF code before verification?",{"text":81,"@type":77},"Merlin uses customized LLVM passes and bytecode rewriting to transform instruction representation, then applies two main strategies: instruction merging and strength reduction.",{"name":83,"@type":74,"acceptedAnswer":84},"What performance and compactness gains does Merlin achieve?",{"text":85,"@type":77},"Across 19 XDP programs and three systems, Merlin reduces instruction count by 73% and runtime overhead by 60%, and improves throughput and latency compared with the K2 state-of-the-art technique.","https://schema.org",{"og:url":52,"og:type":88,"og:title":13,"og:site_name":59,"og:description":14},"article",{"robots":90,"canonical":52},"index,follow",{"doc_id":7,"site_id":24},{"code":4,"msg":5,"data":93},[94,98,102,106,111,114,119,124,129,132,136],{"id":20,"doc_module":4,"doc_module_name":46,"category_name":95,"show_sort_weight":96,"slug":97},"Story & Novel",90,"story-novel",{"id":47,"doc_module":4,"doc_module_name":46,"category_name":99,"show_sort_weight":100,"slug":101},"Literature",80,"literature",{"id":53,"doc_module":4,"doc_module_name":46,"category_name":103,"show_sort_weight":104,"slug":105},"Exam",70,"exam",{"id":107,"doc_module":4,"doc_module_name":46,"category_name":108,"show_sort_weight":109,"slug":110},5,"Comic",60,"comic",{"id":11,"doc_module":4,"doc_module_name":46,"category_name":12,"show_sort_weight":112,"slug":113},50,"technology",{"id":115,"doc_module":4,"doc_module_name":46,"category_name":116,"show_sort_weight":117,"slug":118},7,"Healthcare",40,"healthcare",{"id":120,"doc_module":4,"doc_module_name":46,"category_name":121,"show_sort_weight":122,"slug":123},8,"Research & Report",30,"research-report",{"id":125,"doc_module":4,"doc_module_name":46,"category_name":126,"show_sort_weight":127,"slug":128},9,"Religion & Spirituality",20,"religion-spirituality",{"id":127,"doc_module":4,"doc_module_name":46,"category_name":130,"show_sort_weight":127,"slug":131},"World Cup","world-cup",{"id":133,"doc_module":4,"doc_module_name":46,"category_name":134,"show_sort_weight":133,"slug":135},10,"Lifestyle","lifestyle",{"id":137,"doc_module":4,"doc_module_name":46,"category_name":138,"show_sort_weight":107,"slug":139},19,"General","general"]