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

Re-implement io.pedestal.interceptor.chain #841

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Commits on Apr 19, 2024

  1. Configuration menu
    Copy the full SHA
    464ff63 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a2eb02a View commit details
    Browse the repository at this point in the history
  3. Create a basic benchmark

    v1 is beating v2 most of the time, that's not good.
    
    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━┓
    ┃             Expression             ┃    Mean   ┃     Var     ┃   Ratio   ┃
    ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━━┫
    ┃   (example chain1/execute true 10) ┃ 294.73 µs ┃  ± 17.88 µs ┃   126.2 % ┃
    ┃   (example chain2/execute true 10) ┃ 233.47 µs ┃   ± 6.49 µs ┃   100.0 % ┃ (fastest)
    ┃   (example chain1/execute true 50) ┃ 278.71 µs ┃   ± 7.70 µs ┃   119.4 % ┃
    ┃   (example chain2/execute true 50) ┃   2.35 ms ┃ ± 127.43 µs ┃ 1,005.9 % ┃ (slowest)
    ┃  (example chain1/execute true 100) ┃ 237.70 µs ┃   ± 7.42 µs ┃   101.8 % ┃
    ┃  (example chain2/execute true 100) ┃   1.36 ms ┃ ± 620.82 µs ┃   581.7 % ┃
    ┃  (example chain1/execute false 10) ┃   1.20 ms ┃ ± 110.45 µs ┃   514.6 % ┃
    ┃  (example chain2/execute false 10) ┃   1.86 ms ┃  ± 59.25 µs ┃   798.8 % ┃
    ┃  (example chain1/execute false 50) ┃ 953.14 µs ┃  ± 26.90 µs ┃   408.3 % ┃
    ┃  (example chain2/execute false 50) ┃   2.16 ms ┃ ± 134.51 µs ┃   927.0 % ┃
    ┃ (example chain1/execute false 100) ┃   1.89 ms ┃  ± 62.11 µs ┃   810.6 % ┃
    ┃ (example chain2/execute false 100) ┃ 991.04 µs ┃  ± 53.19 µs ┃   424.5 % ┃
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━┛
    hlship committed Apr 19, 2024
    Configuration menu
    Copy the full SHA
    883ee8f View commit details
    Browse the repository at this point in the history
  4. v1 is still beating v2 most of the time

    feels like PersistentQueue may be the way to go after all, gettting nth element
    of a vector is too slow.
    
    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┓
    ┃             Expression             ┃    Mean   ┃     Var     ┃  Ratio  ┃
    ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━┫
    ┃   (example chain1/execute true 10) ┃ 299.00 µs ┃  ± 11.98 µs ┃ 128.7 % ┃
    ┃   (example chain2/execute true 10) ┃ 235.72 µs ┃   ± 6.02 µs ┃ 101.5 % ┃
    ┃   (example chain1/execute true 50) ┃ 271.39 µs ┃   ± 2.73 µs ┃ 116.9 % ┃
    ┃   (example chain2/execute true 50) ┃   2.23 ms ┃  ± 60.40 µs ┃ 959.1 % ┃
    ┃  (example chain1/execute true 100) ┃ 232.24 µs ┃ ± 653.58 ns ┃ 100.0 % ┃ (fastest)
    ┃  (example chain2/execute true 100) ┃   1.13 ms ┃  ± 40.31 µs ┃ 487.2 % ┃
    ┃  (example chain1/execute false 10) ┃   1.19 ms ┃  ± 43.36 µs ┃ 510.9 % ┃
    ┃  (example chain2/execute false 10) ┃   1.85 ms ┃  ± 50.32 µs ┃ 797.6 % ┃
    ┃  (example chain1/execute false 50) ┃ 964.75 µs ┃  ± 29.27 µs ┃ 415.4 % ┃
    ┃  (example chain2/execute false 50) ┃   2.23 ms ┃  ± 46.00 µs ┃ 961.8 % ┃ (slowest)
    ┃ (example chain1/execute false 100) ┃   1.89 ms ┃  ± 52.39 µs ┃ 815.1 % ┃
    ┃ (example chain2/execute false 100) ┃ 973.70 µs ┃  ± 28.41 µs ┃ 419.3 % ┃
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━┛
    hlship committed Apr 19, 2024
    Configuration menu
    Copy the full SHA
    2d7fd3c View commit details
    Browse the repository at this point in the history
  5. V2 still slower especially in the async case

    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┓
    ┃             Expression             ┃    Mean   ┃     Var     ┃  Ratio  ┃
    ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━┫
    ┃   (example chain1/execute true 10) ┃ 300.21 µs ┃  ± 12.59 µs ┃ 114.0 % ┃
    ┃   (example chain2/execute true 10) ┃ 263.24 µs ┃  ± 11.35 µs ┃ 100.0 % ┃ (fastest)
    ┃   (example chain1/execute true 50) ┃ 290.43 µs ┃  ± 15.45 µs ┃ 110.3 % ┃
    ┃   (example chain2/execute true 50) ┃   2.16 ms ┃ ± 142.63 µs ┃ 821.2 % ┃ (slowest)
    ┃  (example chain1/execute true 100) ┃ 265.68 µs ┃   ± 9.36 µs ┃ 100.9 % ┃
    ┃  (example chain2/execute true 100) ┃   1.08 ms ┃  ± 41.11 µs ┃ 408.5 % ┃
    ┃  (example chain1/execute false 10) ┃   1.13 ms ┃  ± 54.85 µs ┃ 428.5 % ┃
    ┃  (example chain2/execute false 10) ┃   1.86 ms ┃  ± 77.25 µs ┃ 704.8 % ┃
    ┃  (example chain1/execute false 50) ┃ 958.99 µs ┃  ± 44.39 µs ┃ 364.3 % ┃
    ┃  (example chain2/execute false 50) ┃   2.10 ms ┃  ± 78.32 µs ┃ 797.6 % ┃
    ┃ (example chain1/execute false 100) ┃   1.85 ms ┃  ± 69.48 µs ┃ 701.7 % ┃
    ┃ (example chain2/execute false 100) ┃ 960.76 µs ┃  ± 36.04 µs ┃ 365.0 % ┃
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━┛
    hlship committed Apr 19, 2024
    Configuration menu
    Copy the full SHA
    ce87bbe View commit details
    Browse the repository at this point in the history

Commits on Apr 20, 2024

  1. V2 still slower especially in the larger async case

    This has got me down because how can that old ugly broken code be faster?
    
    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┓
    ┃             Expression             ┃    Mean   ┃     Var     ┃  Ratio  ┃
    ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━┫
    ┃   (example chain1/execute true 10) ┃ 291.22 µs ┃   ± 4.23 µs ┃ 110.4 % ┃
    ┃   (example chain2/execute true 10) ┃ 267.34 µs ┃   ± 7.82 µs ┃ 101.4 % ┃
    ┃   (example chain1/execute true 50) ┃ 293.59 µs ┃  ± 18.86 µs ┃ 111.3 % ┃
    ┃   (example chain2/execute true 50) ┃   2.23 ms ┃ ± 109.84 µs ┃ 846.2 % ┃ (slowest)
    ┃  (example chain1/execute true 100) ┃ 263.75 µs ┃  ± 11.87 µs ┃ 100.0 % ┃ (fastest)
    ┃  (example chain2/execute true 100) ┃   1.05 ms ┃  ± 21.40 µs ┃ 398.7 % ┃
    ┃  (example chain1/execute false 10) ┃   1.15 ms ┃  ± 49.73 µs ┃ 437.8 % ┃
    ┃  (example chain2/execute false 10) ┃   1.90 ms ┃  ± 62.41 µs ┃ 719.1 % ┃
    ┃  (example chain1/execute false 50) ┃ 986.54 µs ┃  ± 21.83 µs ┃ 374.0 % ┃
    ┃  (example chain2/execute false 50) ┃   2.04 ms ┃  ± 45.58 µs ┃ 773.3 % ┃
    ┃ (example chain1/execute false 100) ┃   1.79 ms ┃  ± 29.31 µs ┃ 677.0 % ┃
    ┃ (example chain2/execute false 100) ┃ 927.77 µs ┃  ± 18.47 µs ┃ 351.8 % ┃
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━┛
    hlship committed Apr 20, 2024
    Configuration menu
    Copy the full SHA
    282979d View commit details
    Browse the repository at this point in the history
  2. V2 is faster for small async and large sync chains, but slower otherw…

    …ise. Odd!
    
    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━┓
    ┃             Expression             ┃    Mean   ┃     Var    ┃  Ratio  ┃
    ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━┫
    ┃   (example chain1/execute true 10) ┃ 294.55 µs ┃ ± 11.79 µs ┃ 113.0 % ┃
    ┃   (example chain2/execute true 10) ┃ 260.61 µs ┃  ± 9.16 µs ┃ 100.0 % ┃ (fastest)
    ┃   (example chain1/execute true 50) ┃ 290.55 µs ┃ ± 12.64 µs ┃ 111.5 % ┃
    ┃   (example chain2/execute true 50) ┃   2.14 ms ┃ ± 79.23 µs ┃ 819.3 % ┃ (slowest)
    ┃  (example chain1/execute true 100) ┃ 263.40 µs ┃ ± 10.36 µs ┃ 101.1 % ┃
    ┃  (example chain2/execute true 100) ┃   1.08 ms ┃ ± 40.20 µs ┃ 413.2 % ┃
    ┃  (example chain1/execute false 10) ┃   1.10 ms ┃ ± 45.12 µs ┃ 423.9 % ┃
    ┃  (example chain2/execute false 10) ┃   1.81 ms ┃ ± 68.63 µs ┃ 693.3 % ┃
    ┃  (example chain1/execute false 50) ┃ 940.31 µs ┃ ± 24.03 µs ┃ 360.8 % ┃
    ┃  (example chain2/execute false 50) ┃   2.06 ms ┃ ± 84.38 µs ┃ 789.3 % ┃
    ┃ (example chain1/execute false 100) ┃   1.82 ms ┃ ± 79.02 µs ┃ 697.4 % ┃
    ┃ (example chain2/execute false 100) ┃ 966.00 µs ┃ ± 32.83 µs ┃ 370.7 % ┃
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━━━┛
    hlship committed Apr 20, 2024
    Configuration menu
    Copy the full SHA
    b95c460 View commit details
    Browse the repository at this point in the history
  3. On further analysis ... these numbers are so all over the place, I'm …

    …just happy
    
    things are relatively close.  More accurate results, perhaps, with the very slow bench (rather than the default
    quick bench).
    
    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━┓
    ┃             Expression             ┃    Mean   ┃     Var    ┃   Ratio   ┃
    ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━┫
    ┃   (example chain1/execute false 5) ┃ 173.56 µs ┃  ± 2.30 µs ┃   100.6 % ┃
    ┃   (example chain2/execute false 5) ┃   1.76 ms ┃ ± 26.54 µs ┃ 1,022.5 % ┃
    ┃  (example chain1/execute false 10) ┃ 172.60 µs ┃  ± 1.88 µs ┃   100.0 % ┃ (fastest)
    ┃  (example chain2/execute false 10) ┃ 936.96 µs ┃ ± 42.44 µs ┃   542.9 % ┃
    ┃  (example chain1/execute false 50) ┃   2.06 ms ┃ ± 33.00 µs ┃ 1,193.7 % ┃
    ┃  (example chain2/execute false 50) ┃   1.07 ms ┃ ± 14.47 µs ┃   621.7 % ┃
    ┃ (example chain1/execute false 100) ┃   1.77 ms ┃ ± 26.09 µs ┃ 1,025.8 % ┃
    ┃ (example chain2/execute false 100) ┃ 256.64 µs ┃  ± 3.49 µs ┃   148.7 % ┃
    ┃    (example chain1/execute true 5) ┃   1.07 ms ┃ ± 15.58 µs ┃   621.5 % ┃
    ┃    (example chain2/execute true 5) ┃ 257.37 µs ┃  ± 3.40 µs ┃   149.1 % ┃
    ┃   (example chain1/execute true 10) ┃ 281.25 µs ┃  ± 4.07 µs ┃   162.9 % ┃
    ┃   (example chain2/execute true 10) ┃ 187.22 µs ┃  ± 2.95 µs ┃   108.5 % ┃
    ┃   (example chain1/execute true 50) ┃ 928.81 µs ┃ ± 14.83 µs ┃   538.1 % ┃
    ┃   (example chain2/execute true 50) ┃   2.07 ms ┃ ± 35.27 µs ┃ 1,197.0 % ┃ (slowest)
    ┃  (example chain1/execute true 100) ┃ 284.05 µs ┃  ± 4.73 µs ┃   164.6 % ┃
    ┃  (example chain2/execute true 100) ┃ 191.76 µs ┃  ± 3.14 µs ┃   111.1 % ┃
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━━━━━┛
    hlship committed Apr 20, 2024
    Configuration menu
    Copy the full SHA
    ef817be View commit details
    Browse the repository at this point in the history
  4. Code cleanup

    hlship committed Apr 20, 2024
    Configuration menu
    Copy the full SHA
    57a61a0 View commit details
    Browse the repository at this point in the history

Commits on Apr 21, 2024

  1. Aha! Round-robin testing yields invalid results

    Also, inlined function calls for speed
    
    Now version 2 is nearly always faster than version 1
    hlship committed Apr 21, 2024
    Configuration menu
    Copy the full SHA
    2395a23 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9b1e81b View commit details
    Browse the repository at this point in the history
  3. Look what the linter found!

    hlship committed Apr 21, 2024
    Configuration menu
    Copy the full SHA
    ffad3ee View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    7a2054d View commit details
    Browse the repository at this point in the history

Commits on Apr 26, 2024

  1. Bump dependencies

    hlship committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    c30ba69 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e552561 View commit details
    Browse the repository at this point in the history