$30 off During Our Annual Pro Sale. View Details »

ApcClassLoader

 ApcClassLoader

polidog

May 29, 2016
Tweet

More Decks by polidog

Other Decks in Technology

Transcript

  1. ApcClassLoader
    symfony meetup #12
    @polidog

    View Slide

  2. ࣗݾ঺հ
    • @polidog
    • λϏΟίϜגࣜձࣾͰSymfonyॻ͍ͯ·͢
    • ࠷ۙ͸BEARSundayษڧͯ͠·͢

    View Slide

  3. ApcClassLoaderʁ

    View Slide

  4. View Slide

  5. ApcClassLoaderʁ
    • web/app.phpͰίϝϯτΞ΢τͯ͋͠Δ΍ͭ

    ͱࢥͬͨΒ࠷৽ͷSymfonyͩͱ࡟আ͞Εͯ
    ͨɾɾɾ
    • ͳͯ͘΋ಈ͘
    • ͳΜͱͳ࣮͘ߦ଎౓͕ૣ͘ͳΓͦ͏

    View Slide

  6. ͱΓ͋͑ͣಈ͔ͯ͠ΈΑ͏

    View Slide

  7. apc(u)͕ඞཁͰ͢ɻ

    View Slide

  8. brew install php70-apcu

    View Slide

  9. web/app.phpΛฤू

    View Slide

  10. use Symfony\Component\ClassLoader\ApcClassLoader;
    $apcLoader = new ApcClassLoader(sha1(__FILE__),
    $loader);

    $loader->unregister();

    $apcLoader->register(true);


    View Slide

  11. ܭଌͯ͠Έͨ

    View Slide

  12. ܭଌ৚݅
    • MacBook Pro (Retina, 15-inch, Mid 2014) 16GB Memory, 2.2
    GHz Intel Core i7
    • php7.0.6
    • ϏϧτΠϯαʔό࢖ͬͯΔ
    • ඵؒ10ϦΫΤετΛ5ඵִؒ
    • vegeta࢖ͬͯݕূ

    https://github.com/tsenart/vegeta

    View Slide

  13. ApcClassLoaderͳ͠

    View Slide

  14. $ echo "GET http://localhost:8000/" | vegeta attack -rate=50 -
    duration=5s | vegeta report


    Requests [total, rate] 50, 10.20

    Duration [total, attack, wait] 4.91808977s, 4.899999865s,
    18.089905ms

    Latencies [mean, 50, 95, 99, max] 29.650298ms, 17.586892ms,
    39.421233ms, 216.898977ms, 304.779713ms

    Bytes In [total, mean] 230050, 4601.00

    Bytes Out [total, mean] 0, 0.00

    Success [ratio] 100.00%

    Status Codes [code:count] 200:50

    Error Set:

    View Slide

  15. ApcClassLoader͋Γ

    View Slide

  16. $ echo "GET http://localhost:8000/" | vegeta attack -rate=50 -
    duration=5s | vegeta report


    Requests [total, rate] 50, 10.20

    Duration [total, attack, wait] 4.913044931s, 4.899999873s,
    13.045058ms

    Latencies [mean, 50, 95, 99, max] 12.37756ms, 12.595445ms,
    13.760764ms, 13.93599ms, 15.280703ms

    Bytes In [total, mean] 230050, 4601.00

    Bytes Out [total, mean] 0, 0.00

    Success [ratio] 100.00%

    Status Codes [code:count] 200:50

    Error Set:

    View Slide

  17. ApcClassLoaderૣ͍ʂʂʂ

    View Slide

  18. ApcClassLoader͸ԿΛͯ͠
    ͍Δͷ͔ʁ

    View Slide

  19. ApcClassLoader͸ԿΛ͍ͯ͠
    Δͷ͔ʁ
    • spl_autoload_registerʹApcClassLoaderͷloadClassϝιουΛొ࿥͠
    ͍ͯΔ͚ͩ
    • findFileͰapcuʹΩϟογϡ͞Ε͍ͯͳ͚Ε͹ɺϑΝΠϧΛΩϟογϡ
    ͢ΔΑ͏ʹ͍ͯ͠Δ

    https://git.io/vrHLh
    • ௨ৗ͸PSRͷComposer\Autoload\ClassLoaderͷfindFile͕࣮ߦ͞Εͯ
    ͍ΔͷͰ஗͍ɻ

    https://git.io/vrHLN


    View Slide

  20. ·ͱΊ

    View Slide

  21. ·ͱΊ
    • ApcClassLoader͸ૣ͍ʂ
    • ϓϩμΫγϣϯͰ࢖ͬͨ΄͏͕ྑͦ͞͏
    • ϝϞϦগͳ͍࣮ߦ؀ڥͩͱͪΐͬͱ৺഑

    (ࠓ౓ௐ΂Δʣ

    View Slide

  22. ͓͠·͍ɻ

    View Slide