Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memoize call_stack registry for same key entry #717

Merged
merged 1 commit into from
Oct 7, 2024

Commits on Oct 6, 2024

  1. Memoize call_stack registry for same key entry

    With this simple trick, a local rails server with less than a dozen SQL 
    queries using AR drastically reduces the amount of memory allocated by 
    bullet.
    before:
    ```
    allocated memory by gem
    -----------------------------------
        796102  activesupport-7.2.1
        726428  bullet/lib
    ```
    
    after:
    ```
    allocated memory by gem
    -----------------------------------
        794350  activesupport-7.2.1
        313180  sprockets-4.2.1
        259688  activerecord-7.2.1
        204936  bullet/lib
    ```
    
    Using the patched perf/benchmark.rb file to work with sqlite instead of 
    mysql, I saw reproductible numbers:
    
    main
    ```
                                                                            
    user     system      total        real
    Querying & Iterating 1000 Posts with 10000 Comments and 100 Users       
    14.503545   0.638605  15.142150 ( 15.201747)
    ```
    
    patch
    ```
                                                                            
    user     system      total        real
    Querying & Iterating 1000 Posts with 10000 Comments and 100 Users       
    12.781415   0.664749  13.446164 ( 13.533855)
    ```
    vprigent committed Oct 6, 2024
    Configuration menu
    Copy the full SHA
    0c74d2b View commit details
    Browse the repository at this point in the history