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

Make summary, wordcount etc. more effective #2378

Closed
wants to merge 3 commits into from

Commits on Sep 14, 2016

  1. Avoid splitting words for summary

    For people using autogenerated summaries, this is one of the hot spots in the memory department.
    
    We don't need to split al the content into words to do proper summary truncation.
    
    This is obviously more effective:
    
    ```
    BenchmarkTestTruncateWordsToWholeSentence-4            300000          4720 ns/op           0 B/op           0 allocs/op
    BenchmarkTestTruncateWordsToWholeSentenceOld-4         100000         17699 ns/op        3072 B/op           3 allocs/op
    ```
    bep committed Sep 14, 2016
    Configuration menu
    Copy the full SHA
    44e1121 View commit details
    Browse the repository at this point in the history
  2. Improve TotalWords counter func

    It is obviously more efficient when we do not care about the actual words.
    
    ```
    BenchmarkTotalWords-4            100000         18795 ns/op           0 B/op           0 allocs/op
    BenchmarkTotalWordsOld-4          30000         46751 ns/op        6400 B/op           1 allocs/op
    ```
    bep committed Sep 14, 2016
    Configuration menu
    Copy the full SHA
    ea0e8c5 View commit details
    Browse the repository at this point in the history
  3. Lazy calculate WordCount, ReadingTime and FuzzyWordCount

    This avoids having to execute these expensive operations for sites not using these values.
    
    This commit sums up a set of wordcounting and autosummary related performance improvements.
    
    The effect of these kind of depends on what features your site use, but a benchmark from 4 Hugo sites in the wild shows promise:
    
    ```
    benchmark           old ns/op       new ns/op       delta
    BenchmarkHugo-4     21293005843     20032857342     -5.92%
    
    benchmark           old allocs     new allocs     delta
    BenchmarkHugo-4     65290922       65186032       -0.16%
    
    benchmark           old bytes      new bytes      delta
    BenchmarkHugo-4     9771213416     9681866464     -0.91%
    ```
    bep committed Sep 14, 2016
    Configuration menu
    Copy the full SHA
    dfdcbe0 View commit details
    Browse the repository at this point in the history