In the pingora-lru crate, the structure LruUnit<T> and related functions are implemented. The structure LruUnit<T> contains a data domain name used_weight, which should be equal to the sum of the weights of all elements stored in the structure.
I found that in the related functions of LruUnit<T>, the two functions remove and insert_tail did not handle changes in used_weight. Instead, corresponding processing is carried out in the admit and evict functions. Therefore, the result is that if the structure is operated by remove or insert_tail, used_weight will be inconsistent with the expected effect.
Therefore, I modified the remove and insert_tail functions of LruUnit, and added tests for these two functions(remove and insert_tail). If possible, I can submit these codes in the form of a PR.
Pingora info
Pingora version: commit hash is 0de54eb9071a9c4baccc6bad7acad11e9c54186f
Rust version: cargo 1.77.0 (3fe68eabf 2024-02-29)
Operating system version: Ubuntu 20.04
Describe the bug
In the
pingora-lru
crate, the structureLruUnit<T>
and related functions are implemented. The structureLruUnit<T>
contains a data domain nameused_weight
, which should be equal to the sum of the weights of all elements stored in the structure.I found that in the related functions of
LruUnit<T>
, the two functionsremove
andinsert_tail
did not handle changes inused_weight
. Instead, corresponding processing is carried out in theadmit
andevict
functions. Therefore, the result is that if the structure is operated byremove
orinsert_tail
,used_weight
will be inconsistent with the expected effect.Therefore, I modified the, and added tests for these two functions(
remove
andinsert_tail
functions of LruUnitremove
andinsert_tail
). If possible, I can submit these codes in the form of a PR.Pingora info
Pingora version: commit hash is 0de54eb9071a9c4baccc6bad7acad11e9c54186f Rust version: cargo 1.77.0 (3fe68eabf 2024-02-29) Operating system version: Ubuntu 20.04