Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
slash
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
slash
Commits
f18a34eb
Unverified
Commit
f18a34eb
authored
Aug 02, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize FCO LRU eviction
parent
d75053a1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
7 deletions
+43
-7
fellow_cache.c
src/fellow_cache.c
+42
-5
fellow_cache_storage.h
src/fellow_cache_storage.h
+1
-1
fellow_storage.c
src/fellow_storage.c
+0
-1
No files found.
src/fellow_cache.c
View file @
f18a34eb
...
@@ -303,6 +303,13 @@ struct fellow_cache_seg {
...
@@ -303,6 +303,13 @@ struct fellow_cache_seg {
unsigned
fco_infdb
:
1
;
unsigned
fco_infdb
:
1
;
unsigned
lcb_add
:
1
;
unsigned
lcb_add
:
1
;
unsigned
lcb_remove
:
1
;
unsigned
lcb_remove
:
1
;
/*
* during LRU (fco mutate path): the FCO is already
* removed from the LRU, but fcs_onlru is still 1
* for fcs consistency. If mutation fails, the FCO
* is put back on LRU for real
*/
unsigned
fco_lru_mutate
:
1
;
/*
/*
* for FCO, protected by fdb_mtx
* for FCO, protected by fdb_mtx
...
@@ -1412,7 +1419,7 @@ fellow_cache_obj_free(const struct fellow_cache *fc,
...
@@ -1412,7 +1419,7 @@ fellow_cache_obj_free(const struct fellow_cache *fc,
*
*
* state must be FCO_INCORE, object is on LRU, must be referenced
* state must be FCO_INCORE, object is on LRU, must be referenced
*
*
*
lru and fco mtx are
held
*
fco mtx is
held
*
*
* similar in structure to fellow_cache_obj_deref(), but
* similar in structure to fellow_cache_obj_deref(), but
* - keep reference
* - keep reference
...
@@ -1420,7 +1427,7 @@ fellow_cache_obj_free(const struct fellow_cache *fc,
...
@@ -1420,7 +1427,7 @@ fellow_cache_obj_free(const struct fellow_cache *fc,
*/
*/
void
void
fellow_cache_obj_evict_mutate
(
struct
fellow_cache_lru
*
lru
,
fellow_cache_obj_evict_mutate
(
const
struct
fellow_cache_lru
*
lru
,
struct
fellow_cache_obj
*
fco
)
struct
fellow_cache_obj
*
fco
)
{
{
struct
fellow_cache_seg
*
fcs
;
struct
fellow_cache_seg
*
fcs
;
...
@@ -1453,9 +1460,14 @@ fellow_cache_obj_evict_mutate(struct fellow_cache_lru *lru,
...
@@ -1453,9 +1460,14 @@ fellow_cache_obj_evict_mutate(struct fellow_cache_lru *lru,
AN
(
fco
->
oc
);
AN
(
fco
->
oc
);
fco
->
oc
=
NULL
;
fco
->
oc
=
NULL
;
// lru
/* finish lru transaction which has been started in
VTAILQ_REMOVE
(
&
lru
->
lru_head
,
fcs
,
lru_list
);
* fellow_cache_lru_work(): the fcs is already removed
* from LRU, we just finish the flags
*/
AN
(
fcs
->
fco_lru_mutate
);
AN
(
fcs
->
fcs_onlru
);
AN
(
fcs
->
fcs_onlru
);
fcs
->
fco_lru_mutate
=
0
;
fcs
->
fcs_onlru
=
0
;
fcs
->
fcs_onlru
=
0
;
assert_cache_seg_consistency
(
fcs
);
assert_cache_seg_consistency
(
fcs
);
...
@@ -2976,6 +2988,9 @@ fellow_cache_lru_work(struct worker *wrk, struct fellow_cache_lru *lru)
...
@@ -2976,6 +2988,9 @@ fellow_cache_lru_work(struct worker *wrk, struct fellow_cache_lru *lru)
* - fcs != NULL
* - fcs != NULL
* - or foreach finishes, then fcs == NULL and the mtx
* - or foreach finishes, then fcs == NULL and the mtx
* needs to be unlocked
* needs to be unlocked
*
* this is safe because the oc holds a ref on the fco, so
* the LRU state of the fco does not change
*/
*/
CHECK_OBJ_NOTNULL
(
lru
,
FELLOW_CACHE_LRU_MAGIC
);
CHECK_OBJ_NOTNULL
(
lru
,
FELLOW_CACHE_LRU_MAGIC
);
...
@@ -3007,15 +3022,37 @@ fellow_cache_lru_work(struct worker *wrk, struct fellow_cache_lru *lru)
...
@@ -3007,15 +3022,37 @@ fellow_cache_lru_work(struct worker *wrk, struct fellow_cache_lru *lru)
if
(
fcs
->
state
==
FCO_INCORE
)
{
if
(
fcs
->
state
==
FCO_INCORE
)
{
oc
=
fco
->
oc
;
oc
=
fco
->
oc
;
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
AZ
(
fcs
->
fco_lru_mutate
);
fcs
->
fco_lru_mutate
=
1
;
VTAILQ_REMOVE
(
&
lru
->
lru_head
,
fcs
,
lru_list
);
AZ
(
pthread_mutex_unlock
(
&
lru
->
lru_mtx
));
r
=
stvfe_mutate
(
wrk
,
lru
,
oc
);
r
=
stvfe_mutate
(
wrk
,
lru
,
oc
);
if
(
r
)
{
// success
AZ
(
fcs
->
fco_lru_mutate
);
}
else
{
// will be put back on LRU below
AN
(
fcs
->
fcs_onlru
);
AN
(
fcs
->
fco_lru_mutate
);
fcs
->
fco_lru_mutate
=
0
;
}
AZ
(
pthread_mutex_unlock
(
&
fco
->
mtx
));
AZ
(
pthread_mutex_unlock
(
&
fco
->
mtx
));
if
(
r
)
{
if
(
r
)
{
/* mutate was successful
/* mutate was successful
* VSC_C_main->n_lru_nuked++; // XXX per lru ?
* VSC_C_main->n_lru_nuked++; // XXX per lru ?
*/
*/
AZ
(
pthread_mutex_unlock
(
&
lru
->
lru_mtx
));
break
;
break
;
}
}
AZ
(
pthread_mutex_lock
(
&
lru
->
lru_mtx
));
// mutate has failed
AN
(
fcs
->
fcs_onlru
);
AZ
(
fcs
->
fco_lru_mutate
);
VTAILQ_INSERT_TAIL
(
&
lru
->
lru_head
,
fcs
,
lru_list
);
// re-start because we let go of lru_mtx
fcss
=
VTAILQ_FIRST
(
&
lru
->
lru_head
);
oc
=
NULL
;
oc
=
NULL
;
fco
=
NULL
;
fco
=
NULL
;
continue
;
continue
;
...
...
src/fellow_cache_storage.h
View file @
f18a34eb
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
*/
*/
struct
fellow_cache_lru
;
struct
fellow_cache_lru
;
void
fellow_cache_obj_evict_mutate
(
struct
fellow_cache_lru
*
lru
,
void
fellow_cache_obj_evict_mutate
(
const
struct
fellow_cache_lru
*
lru
,
struct
fellow_cache_obj
*
fco
);
struct
fellow_cache_obj
*
fco
);
void
fellow_cache_obj_slim
(
const
struct
fellow_cache
*
fc
,
void
fellow_cache_obj_slim
(
const
struct
fellow_cache
*
fc
,
struct
fellow_cache_obj
*
fco
);
struct
fellow_cache_obj
*
fco
);
...
...
src/fellow_storage.c
View file @
f18a34eb
...
@@ -1809,7 +1809,6 @@ stvfe_mutate(struct worker *wrk, struct fellow_cache_lru *lru,
...
@@ -1809,7 +1809,6 @@ stvfe_mutate(struct worker *wrk, struct fellow_cache_lru *lru,
AN
(
oc
->
stobj
->
priv
);
AN
(
oc
->
stobj
->
priv
);
AN
(
oc
->
stobj
->
priv2
);
AN
(
oc
->
stobj
->
priv2
);
// XXX LRU with change, reduce LRU mtx scope
fellow_cache_obj_evict_mutate
(
lru
,
oc
->
stobj
->
priv
);
fellow_cache_obj_evict_mutate
(
lru
,
oc
->
stobj
->
priv
);
oc
->
stobj
->
priv
=
NULL
;
oc
->
stobj
->
priv
=
NULL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment