You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/09/26 01:37:29 UTC

[GitHub] [kafka] ahuang98 opened a new pull request #9340: Improving Fetch Session Caching for KAFKA-9401

ahuang98 opened a new pull request #9340:
URL: https://github.com/apache/kafka/pull/9340


   WIP - Does not follow original cache eviction logic of waiting `evictionMs` before allowing smaller session to be evicted by a larger session. Working on reverting those changes. All WIP comments below pertain to this issue. 
   
   ## Summary of changes 
   #### @lbradstreet
   - JMH benchmark to log performance improvements
   - making `EvictableKey`'s `compareTo` method faster
   - restructuring of `tryEvict` (WIP to make sure this works with original cache eviction logic)
   - restructuring of `touch`
       - `evictableBy` treemaps changed to store unprivileged and privileged sessions respectively (WIP, will change this)
   
   #### ahuang98
    - `sessions` turned into LinkedHashMap (from mutable.HashMap) to absorb function of `lastUsed`
       - entries in `sessions` are now ordered by the time the session was last touched
    -  `evictableBy` treemaps renamed to `unprivilegedSessions` and `privilegedSesions` (WIP, will need to revert this)
   
   ## Testing
    - Unit test
       - assertion in `testSessionCache` currently commented out due to misunderstanding of cache eviction behavior (WIP, will uncomment out and add additional tests)
    - JMH benchmark
       - running benchmark w/ 8 warmup iterations and 6 measurement iterations on an ec2 instance shows performance of optimized code with a cache size set at 5000 entries is comparable if not slightly better than performance of trunk with a cache size of 1000. (note, cache eviction logic is slightly different in the optimized code though)
   
   | cacheSize | percentPrivileged | benchPrivileged | newSession | numEvictableEntries | cacheUtilization | Mode | Cnt | sessions_lastUsed Score | sessions_lastUsed Error | trunk Score | trunk Error | Units |
   | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
   | 1000 | 10 | FALSE | FALSE | 0 | 99 | avgt | 6 | 2552.391 | 107.575 | 4221.632 | 359.275 | ns/op |
   | 1000 | 10 | FALSE | FALSE | 1 | 99 | avgt | 6 | 2582.457 | 125.423 | 4222.194 | 414.809 | ns/op |
   | 1000 | 10 | FALSE | FALSE | 10 | 99 | avgt | 6 | 2746.227 | 61.092 | 4251.687 | 370.021 | ns/op |
   | 1000 | 10 | FALSE | TRUE | 0 | 99 | avgt | 6 | 1198.266 | 222.24 | 2252.08 | 702.901 | ns/op |
   | 1000 | 10 | FALSE | TRUE | 1 | 99 | avgt | 6 | 1134.612 | 120.705 | 2169.681 | 550.987 | ns/op |
   | 1000 | 10 | FALSE | TRUE | 10 | 99 | avgt | 6 | 1179.589 | 218.907 | 2103.325 | 353.927 | ns/op |
   | 1000 | 10 | FALSE | FALSE | 0 | 100 | avgt | 6 | 2622.648 | 180.46 | 4298.698 | 461.962 | ns/op |
   | 1000 | 10 | FALSE | FALSE | 1 | 100 | avgt | 6 | 2610.549 | 167.135 | 4189.434 | 304.004 | ns/op |
   | 1000 | 10 | FALSE | FALSE | 10 | 100 | avgt | 6 | 2606.701 | 95.392 | 4290.71 | 393.693 | ns/op |
   | 1000 | 10 | FALSE | TRUE | 0 | 100 | avgt | 6 | 1997.809 | 143.441 | 3520.044 | 357.352 | ns/op |
   | 1000 | 10 | FALSE | TRUE | 1 | 100 | avgt | 6 | 2009.162 | 174.531 | 3697.102 | 1342.944 | ns/op |
   | 1000 | 10 | FALSE | TRUE | 10 | 100 | avgt | 6 | 2057.212 | 114.299 | 3473.398 | 691.091 | ns/op |
   | 2000 | 10 | FALSE | FALSE | 0 | 99 | avgt | 6 | 3719.148 | 104.879 | 5398.167 | 136.906 | ns/op |
   | 2000 | 10 | FALSE | FALSE | 1 | 99 | avgt | 6 | 3487.926 | 220.468 | 5371.3 | 121.94 | ns/op |
   | 2000 | 10 | FALSE | FALSE | 10 | 99 | avgt | 6 | 3582.789 | 49.977 | 5233.165 | 80.441 | ns/op |
   | 2000 | 10 | FALSE | TRUE | 0 | 99 | avgt | 6 | 1674.242 | 24.652 | 2897.423 | 38.511 | ns/op |
   | 2000 | 10 | FALSE | TRUE | 1 | 99 | avgt | 6 | 1666.169 | 113.422 | 2704.126 | 19.803 | ns/op |
   | 2000 | 10 | FALSE | TRUE | 10 | 99 | avgt | 6 | 1696.892 | 155.846 | 2793.346 | 38.972 | ns/op |
   | 2000 | 10 | FALSE | FALSE | 0 | 100 | avgt | 6 | 3466.104 | 47.457 | 5497.131 | 57.95 | ns/op |
   | 2000 | 10 | FALSE | FALSE | 1 | 100 | avgt | 6 | 3447.317 | 57.066 | 5519.515 | 104.217 | ns/op |
   | 2000 | 10 | FALSE | FALSE | 10 | 100 | avgt | 6 | 3619.742 | 49.741 | 5247.048 | 77.843 | ns/op |
   | 2000 | 10 | FALSE | TRUE | 0 | 100 | avgt | 6 | 2741.251 | 66.38 | 4432.045 | 40.222 | ns/op |
   | 2000 | 10 | FALSE | TRUE | 1 | 100 | avgt | 6 | 2783.172 | 43.712 | 4537.006 | 664.541 | ns/op |
   | 2000 | 10 | FALSE | TRUE | 10 | 100 | avgt | 6 | 2787.124 | 59.319 | 4589.346 | 604.493 | ns/op |
   | 5000 | 10 | FALSE | FALSE | 0 | 99 | avgt | 6 | 4044.472 | 49.122 | 6333.033 | 222.079 | ns/op |
   | 5000 | 10 | FALSE | FALSE | 1 | 99 | avgt | 6 | 3908.32 | 83.414 | 7172.89 | 3360.043 | ns/op |
   | 5000 | 10 | FALSE | FALSE | 10 | 99 | avgt | 6 | 4101.308 | 98.899 | 6056.719 | 305.08 | ns/op |
   | 5000 | 10 | FALSE | TRUE | 0 | 99 | avgt | 6 | 1768.217 | 34.502 | 3160.962 | 167.346 | ns/op |
   | 5000 | 10 | FALSE | TRUE | 1 | 99 | avgt | 6 | 1860.036 | 63.331 | 2924.341 | 99.126 | ns/op |
   | 5000 | 10 | FALSE | TRUE | 10 | 99 | avgt | 6 | 1857.753 | 21.139 | 3161.729 | 84.213 | ns/op |
   | 5000 | 10 | FALSE | FALSE | 0 | 100 | avgt | 6 | 4179.245 | 87.847 | 5913.662 | 187.321 | ns/op |
   | 5000 | 10 | FALSE | FALSE | 1 | 100 | avgt | 6 | 3959.985 | 25.396 | 5976.045 | 128.325 | ns/op |
   | 5000 | 10 | FALSE | FALSE | 10 | 100 | avgt | 6 | 4190.708 | 57.154 | 5853.785 | 193.559 | ns/op |
   | 5000 | 10 | FALSE | TRUE | 0 | 100 | avgt | 6 | 3197.425 | 86.966 | 5008.812 | 103.899 | ns/op |
   | 5000 | 10 | FALSE | TRUE | 1 | 100 | avgt | 6 | 3011.672 | 71.971 | 4815.088 | 86.41 | ns/op |
   | 5000 | 10 | FALSE | TRUE | 10 | 100 | avgt | 6 | 3384.219 | 1447.347 | 4695.905 | 85.022 | ns/op |
   | 1000 | 10 | TRUE | FALSE | 0 | 99 | avgt | 6 | 2561.184 | 144.235 | 4088.493 | 423.601 | ns/op |
   | 1000 | 10 | TRUE | FALSE | 1 | 99 | avgt | 6 | 2549.567 | 120.933 | 4060.126 | 537.96 | ns/op |
   | 1000 | 10 | TRUE | FALSE | 10 | 99 | avgt | 6 | 2470.353 | 25.189 | 3983.763 | 457.027 | ns/op |
   | 1000 | 10 | TRUE | TRUE | 0 | 99 | avgt | 6 | 1147.309 | 100.24 | 1751.043 | 411.793 | ns/op |
   | 1000 | 10 | TRUE | TRUE | 1 | 99 | avgt | 6 | 1150.934 | 123.416 | 1698.838 | 507.797 | ns/op |
   | 1000 | 10 | TRUE | TRUE | 10 | 99 | avgt | 6 | 1164.19 | 71.091 | 1704.753 | 368.605 | ns/op |
   | 1000 | 10 | TRUE | FALSE | 0 | 100 | avgt | 6 | 2541.009 | 116.648 | 3919.933 | 518.604 | ns/op |
   | 1000 | 10 | TRUE | FALSE | 1 | 100 | avgt | 6 | 2532.357 | 141.573 | 4003.604 | 429.815 | ns/op |
   | 1000 | 10 | TRUE | FALSE | 10 | 100 | avgt | 6 | 2450.298 | 156.206 | 3874.682 | 487.093 | ns/op |
   | 1000 | 10 | TRUE | TRUE | 0 | 100 | avgt | 6 | 2034.706 | 109.759 | 3167.018 | 353.418 | ns/op |
   | 1000 | 10 | TRUE | TRUE | 1 | 100 | avgt | 6 | 2175.458 | 186.355 | 3366.812 | 1005.47 | ns/op |
   | 1000 | 10 | TRUE | TRUE | 10 | 100 | avgt | 6 | 2057.477 | 267.091 | 3052.87 | 459.771 | ns/op |
   | 2000 | 10 | TRUE | FALSE | 0 | 99 | avgt | 6 | 3451.253 | 48.341 | 5223.387 | 48.042 | ns/op |
   | 2000 | 10 | TRUE | FALSE | 1 | 99 | avgt | 6 | 3469.055 | 78.082 | 5329.018 | 78.966 | ns/op |
   | 2000 | 10 | TRUE | FALSE | 10 | 99 | avgt | 6 | 3797.724 | 106.811 | 5265.529 | 849.037 | ns/op |
   | 2000 | 10 | TRUE | TRUE | 0 | 99 | avgt | 6 | 1706.486 | 24.011 | 2329.256 | 49.947 | ns/op |
   | 2000 | 10 | TRUE | TRUE | 1 | 99 | avgt | 6 | 1686.125 | 84.575 | 2173.363 | 12.349 | ns/op |
   | 2000 | 10 | TRUE | TRUE | 10 | 99 | avgt | 6 | 1665.939 | 81.493 | 2256.057 | 46.32 | ns/op |
   | 2000 | 10 | TRUE | FALSE | 0 | 100 | avgt | 6 | 3514.014 | 309.137 | 5110.368 | 98.069 | ns/op |
   | 2000 | 10 | TRUE | FALSE | 1 | 100 | avgt | 6 | 3618.191 | 50.222 | 5121.661 | 767.183 | ns/op |
   | 2000 | 10 | TRUE | FALSE | 10 | 100 | avgt | 6 | 3539.023 | 87.241 | 5022.353 | 99.247 | ns/op |
   | 2000 | 10 | TRUE | TRUE | 0 | 100 | avgt | 6 | 2920.482 | 61.11 | 4114.026 | 83.705 | ns/op |
   | 2000 | 10 | TRUE | TRUE | 1 | 100 | avgt | 6 | 2948.267 | 36.899 | 4108.646 | 36.71 | ns/op |
   | 2000 | 10 | TRUE | TRUE | 10 | 100 | avgt | 6 | 2777.247 | 72.705 | 4683.309 | 2034.037 | ns/op |
   | 5000 | 10 | TRUE | FALSE | 0 | 99 | avgt | 6 | 4208.537 | 136.771 | 6108.738 | 317.838 | ns/op |
   | 5000 | 10 | TRUE | FALSE | 1 | 99 | avgt | 6 | 4275.204 | 104.718 | 5758.545 | 368.036 | ns/op |
   | 5000 | 10 | TRUE | FALSE | 10 | 99 | avgt | 6 | 3802.396 | 69.06 | 5907.618 | 1179.157 | ns/op |
   | 5000 | 10 | TRUE | TRUE | 0 | 99 | avgt | 6 | 1817.052 | 36.965 | 2576.559 | 77.116 | ns/op |
   | 5000 | 10 | TRUE | TRUE | 1 | 99 | avgt | 6 | 1830.881 | 22.607 | 2245.371 | 332.015 | ns/op |
   | 5000 | 10 | TRUE | TRUE | 10 | 99 | avgt | 6 | 1700.745 | 24.753 | 2387.301 | 73.854 | ns/op |
   | 5000 | 10 | TRUE | FALSE | 0 | 100 | avgt | 6 | 4098.944 | 92.348 | 6130.021 | 543.315 | ns/op |
   | 5000 | 10 | TRUE | FALSE | 1 | 100 | avgt | 6 | 3999.026 | 68.434 | 5846.927 | 254.565 | ns/op |
   | 5000 | 10 | TRUE | FALSE | 10 | 100 | avgt | 6 | 3947.831 | 56.928 | 6015.531 | 1080.499 | ns/op |
   | 5000 | 10 | TRUE | TRUE | 0 | 100 | avgt | 6 | 3147.252 | 21.468 | 4447.048 | 82.383 | ns/op |
   | 5000 | 10 | TRUE | TRUE | 1 | 100 | avgt | 6 | 3105.685 | 120.959 | 4722.019 | 881.861 | ns/op |
   | 5000 | 10 | TRUE | TRUE | 10 | 100 | avgt | 6 | 3150.724 | 33.32 | 4497.308 | 53.045 | ns/op |
   
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] ahuang98 commented on pull request #9340: Improving Fetch Session Caching for KAFKA-10558

Posted by GitBox <gi...@apache.org>.
ahuang98 commented on pull request #9340:
URL: https://github.com/apache/kafka/pull/9340#issuecomment-701654144


   PR needs more work and testing


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] ahuang98 commented on pull request #9340: Improving Fetch Session Caching for KAFKA-9401

Posted by GitBox <gi...@apache.org>.
ahuang98 commented on pull request #9340:
URL: https://github.com/apache/kafka/pull/9340#issuecomment-700886220


   retest this please


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] kamalcph commented on pull request #9340: Improving Fetch Session Caching for KAFKA-10558

Posted by GitBox <gi...@apache.org>.
kamalcph commented on pull request #9340:
URL: https://github.com/apache/kafka/pull/9340#issuecomment-1085675534


   gentle reminder


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] ahuang98 closed pull request #9340: Improving Fetch Session Caching for KAFKA-10558

Posted by GitBox <gi...@apache.org>.
ahuang98 closed pull request #9340:
URL: https://github.com/apache/kafka/pull/9340


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] kamalcph commented on pull request #9340: Improving Fetch Session Caching for KAFKA-10558

Posted by GitBox <gi...@apache.org>.
kamalcph commented on pull request #9340:
URL: https://github.com/apache/kafka/pull/9340#issuecomment-1080221703


   @ahuang98 @lbradstreet 
   
   We are also having this issue when FetchConsumer requests scale beyond 50k requests per second. What's the current status of this patch? Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] ahuang98 removed a comment on pull request #9340: Improving Fetch Session Caching for KAFKA-9401

Posted by GitBox <gi...@apache.org>.
ahuang98 removed a comment on pull request #9340:
URL: https://github.com/apache/kafka/pull/9340#issuecomment-700886220


   retest this please


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org