Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Speed up zing me – ntvv2 code with PHP extension module

68,012 views

Published on

  • Dating direct: ❤❤❤ http://bit.ly/369VOVb ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ❶❶❶ http://bit.ly/369VOVb ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DỊCH VỤ THIẾT KẾ POWERPOINT (Thiết kế profile cho doanh nghiệp--- Thiết kế Brochure--- Thiết kế Catalogue--- slide bài giảng--- slide bài phát biểu---slide bài TIỂU LUẬN, LUẬN VĂN TỐT NGHIỆP--- dạy học viên thiết kế powerpoint…)-----(Giá từ 8.000 đ - 10.000 đ/1trang slide)------ Mọi chi tiết vui lòng liên hệ với chúng tôi: điện thoại 0973.764.894 hoặc zalo 0973.764.894 (Miss. Huyền) ----- • Thời gian hoàn thành: 1-2 ngày sau khi nhận đủ nội dung ----- Qui trình thực hiện: ----- 1. Bạn gửi nội dung cần thiết kế về địa chỉ email: dvluanvan@gmail.com ----- 2. DỊCH VỤ THIẾT KẾ POWERPOINT báo giá chi phí và thời gian thực hiện cho bạn ----- 3. Bạn chuyển tiền tạm ứng 50% chi phí để tiến hành thiết kế ----- 4. Gửi file slide demo cho bạn xem để thống nhất chỉnh sửa hoàn thành. ----- 5. Bạn chuyển tiền 50% còn lại. ----- 6. Bàn giao file gốc cho bạn.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Speed up zing me – ntvv2 code with PHP extension module

  1. 1. 18/12/2010Speed up ZingMe-NTVV2 withPHP extension module By Nguyen Trung Thanh ZingMe Team leader Web Technical - VNG
  2. 2. ContentsIntroductionWhy?PHP extension basicSWIGSample
  3. 3. INTRODUCTION - ntvv2
  4. 4. Introduction• Ntvv2 (http://me.zing.vn/apps/ntvv2) – 1.M daily active user – Average 800 rps (per webserver) max 1100 rps – 9300 rps (all database servers) – 3 webservers• Use Membase for cache and storage• Use other db for secondary storage• All bussiness function is moved to PHP extension
  5. 5. Why to write PHP module?Make complicated Bussiness functions run faster, consume less memoryPHP high-level overhead cpu/memAdvance facility with PHP-FPM Cache something in PHP processStrictly Confidential – Do Not Distribute
  6. 6. PHP extension basicWhat is an extension?LifecycleSetting up a build environmenthttp://devzone.zend.com/article/4486http://devzone.zend.com/article/1021-Extension-Writing-Part-I- Introduction-to-PHP-and-Zend
  7. 7. What is an extension?Have you ever used PHP extension?PHP consist of many extensionsAll function we used is from extensions
  8. 8. Lifecycle
  9. 9. Setting up build environment- Setup PHP-devel- Sample extension
  10. 10. Is it complicated?● Is there any sexier and easier way?● We can use SWIG
  11. 11. SWIGSWIG is an interface compiler that connects programs written in C and C++ with scripting languages such as PHP, Python, Ruby...How SWIG worksUsing SWIGInstall module to PHP extensionsSampleStrictly Confidential – Do Not Distribute
  12. 12. How SWIG works
  13. 13. What does SWIG do for you ?NamespaceConstantsType conversion For simple types (int, float, char *, enum)Wraps complex types Pointers to structs and classesExposes functions
  14. 14. Using SWIGDefile module in swig fileGenerate source codeCreate module project, build it
  15. 15. Define moduleData typeWrapper class/functions %module ntvv2module %{ #include <string> #include <vector> #include <list> #include <string> #include “ntvvgame.h" %} struct LandInfo{ int id; std::string data; } ;Strictly Confidential – Do Not Distribute LandInfo updateLandInfo(int uid, int landID);
  16. 16. Exposure•Swig recognizes C/C++ declarationsstruct or classfunctions•Hiding elements%ignore solver::noupdate;%include “satsolver/solver.h”
  17. 17. Useful commands•Renaming%rename("to_s") asString();%rename( "name=" ) set_name( const char *name );%rename("empty?") empty();•Aliasing%alias get "[]";•Constants%constant int Script = C_CONSTANT;•Defines%define YUILogComponent "bindings"%enddef%define %macro(PARAMETER)
  18. 18. SWIG stepsGenerate codeCreate project, compiling – Add genterated code to projectRunning – Add extension module to PHP
  19. 19. SampleCache data in PHP moduleStrictly Confidential – Do Not Distribute
  20. 20. Q&A

×