handling all facebook requests with jited c code
play

Handling all Facebook requests with JITed C++ code Yuhan Guo, - PowerPoint PPT Presentation

Handling all Facebook requests with JITed C++ code Yuhan Guo, Huapeng Zhou Software Engineers, Facebook User requests L7 User Web servers Loadbalancer User requests L7 User Web servers Loadbalancer Core HTTP stack +


  1. Handling all Facebook requests with JITed C++ code Yuhan Guo, Huapeng Zhou Software Engineers, Facebook

  2. User requests L7 User Web servers Loadbalancer

  3. User requests L7 User Web servers Loadbalancer • Core HTTP stack + Business logic • Large • v.s. Small • Stable • v.s. Fast iteration

  4. Other scripting language • Interfacing • Testing • Debugging • Profiling • Performance • Side-e ff ects

  5. What we want • Interfacing • Testing • Debugging • Profiling • Performance

  6. Clang/LLVM

  7. Build time int getID(string url) { auto p = UrlParser(url); C++ script ... } class UrlParser { Pre-compiled ... Header }; JIT Engine getID(url); Main Binary

  8. Runtime C++ script LLVM IR Clang Pre-compiled Compiler options from Header Clang PCH metadata Clang/LLVM Statically JIT Engine linked libraries Main Binary

  9. Runtime Executable C++ script LLVM IR code Clang LLVM OrcJit Pre-compiled Exported Header Symbols Clang/LLVM Statically JIT Engine linked libraries Main Binary

  10. What we want? • Interfacing • Testing • Debugging • Profiling • Performance

  11. Interfacing Executable C++ script LLVM IR code LLVM Clang OrcJit Pre-compiled Exported Header Symbols Clang/LLVM Statically JIT Engine linked libraries Main Binary

  12. Interfacing Executable C++ script LLVM IR code LLVM Clang OrcJit Pre-compiled Exported --dynamic-list Header Symbols Clang/LLVM Statically while (true) { JIT Engine linked libraries fork(); } Main Binary

  13. Testing Unit test C++ script Test script Pre-compiled Test PCH Header JIT Engine Unit Tester

  14. Testing Unit test • Using same JIT Engine TEST(Foo, bar){ auto id = getID(url); • Google Test EXPECT_EQUAL(id, 42); • ASan/UBSan }

  15. Testing Integration test • Spin up main binary + scripts locally • Real HTTP test request against local host

  16. Debugging • Register in-memory symbol files with GDB • Github JitFromScratch project has been helpful llvm::JITEventListener::createGDBRegistrationListener

  17. Profiling • PerfJITEventListener added in https://reviews.llvm.org/D44892 • Based on jitdump • Rolled our own PerfMapJITEventListener • Based on /tmp/perf-%pid.map START SIZE symbolname START SIZE symbolname ...

  18. Performance Execution time Time distribution

  19. Cost? • Addition binary size: ~100MB • Addition start up time: ~2s • Quirks: Thread local storage • Adapt to OrcJIT upstream API change

  20. What's next? • Performance tuning based on Perf • Clang checker • Module? • Coroutines-TS?

  21. Thank you! • https://llvm.org/docs/tutorial/index.html#building-a-jit-in- llvm has been extremely helpful • Continuous support from LLVM society is awesome • Giving back to community https://reviews.llvm.org/D53911

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend