Repository navigation
DAOS-17823 client: implement LRU cache in shared memory - #16785
Conversation
fix the padding issue in hash table insertion Signed-off-by: Lei Huang <lei.huang@hpe.com>
|
Ticket title is 'To implement LRU cache based on shm' |
Signed-off-by: Lei Huang <lei.huang@hpe.com>
Signed-off-by: Lei Huang <lei.huang@hpe.com>
Signed-off-by: Lei Huang <lei.huang@hpe.com>
Test put()/get() concurrently. Allow-unstable-test: true Signed-off-by: Lei Huang <lei.huang@hpe.com>
Allow-unstable-test: true Signed-off-by: Lei Huang <lei.huang@hpe.com>
knard38
left a comment
There was a problem hiding this comment.
I will continue the review tomorrow, but if my understanding is correct some points needs to be fixed.
set cache pointer in test_lrucache and decrease the number of repeat times simplify the rule for dynamic allocation of key and data in LRU cache Allow-unstable-test: true Signed-off-by: Lei Huang <lei.huang@hpe.com>
Allow-unstable-test: true Signed-off-by: Lei Huang <lei.huang@hpe.com>
Allow-unstable-test: true Signed-off-by: Lei Huang <lei.huang@hpe.com>
| int depth; | ||
|
|
||
| /* Allocate, initialize, and perform topology detection */ | ||
| hwloc_topology_init(&topology); |
There was a problem hiding this comment.
My apologies to not have done it in the example, but the return code of the function calls to hwloc_topology_init() and hwloc_topology_load() should be checked.
From my understanding, the call to hwloc_topology_destroy() have to be done only if hwloc_topology_init() succeed.
There was a problem hiding this comment.
Thank you very much! Fixed as you suggested.
Allow-unstable-test: true Signed-off-by: Lei Huang <lei.huang@hpe.com>
|
Test stage Functional Hardware Medium MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-16785/21/execution/node/1554/log |
| *new_node = NULL; | ||
|
|
||
| /* make sure LRU is not full */ | ||
| if (subcache->first_av < 0) |
There was a problem hiding this comment.
I do not understand how an LRU can be full. by definition it should kick the oldest element out.
did i misunderstand this here?
There was a problem hiding this comment.
Yes. That's true for regular LRU cache.
In current implementation, data copy is not done in-place and the reference count is increased by 1 after we call shm_lru_get(). The caller gets the pointer of cache entry data. The reference count is decrease once user gets all needed data from the cache entry. This allows multiple consumers to read the same cache entry concurrently.
The entry with non-zero reference count cannot be evicted. When we search an entry starting from the tail for eviction, we skip such entries since users may be reading data from them.
There was a problem hiding this comment.
i see.. we probably should do some dynamic solution there.
meanwhile the put should document that on EBUSY one needs to retry or just disregard putting the element as this is not fatal.
There was a problem hiding this comment.
Thank you! I will add the document as you suggested in another PR.
Regarding "some dynamic solution", could you please provide more information if there is any suggestion in your mind? Thank you!
| memcpy(buf_key, key, key_size); | ||
| } else { | ||
| /* use preallocated buffer for key */ | ||
| node->off_key = subcache->off_keylist + idx_node * (long int)cache->key_size; |
There was a problem hiding this comment.
do we ever grow the lru size anywhere or it is always fixed?
There was a problem hiding this comment.
LRU size is fixed.
|
@mchaarawi The failure in Functional Hardware Medium MD on SSD / FTEST_io.IoConsistency.1-./io/io_consistency.py is not related. Can we force land this PR? Thank you very much! |
|
please add a description for landing.. |
Done as you suggested. Thank you! |
Least Recently Used (LRU) cache designed for shared memory is implemented. It has a fixed capacity. Fine-grained lock is used by dividing cache into many smaller sub-caches to achieve better performance in high concurrency.
Steps for the author:
After all prior steps are complete: