Skip to contentSkip to conversation

The design of the eviction improvement

DISCUSSION Matt W. Benjamin 3 participants 4 messages Jul 21, 2015 – Jul 22, 2015 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi,

Couple of points.

1) a successor to 2Q is MQ (Li et al). We have an intrusive MQ LRU implementation
with 2 levels currently, plus a pinned queue, that addresses stuff like partitioning ("sharding"), scan resistance, and coordination w/lookup tables. We might extend/re-use it.

2) I'm a bit confused by active/inactive vocabulary, dimensioning of cache segments (are you proposing to/do we now always cache whole objects?), and cost of "looking for" dirty objects; I suspect that it makes sense to amortize the cost of locating segments eligible to be flushed, rather than minimize bookkeeping.

Matt

Quoted 175 lines · ----- "Zhiqiang Wang
Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Sage Weil
Sent: Tuesday, July 21, 2015 6:38 AM
To: Wang, Zhiqiang
Cc: [email protected]; [email protected]
Subject: Re: The design of the eviction improvement

Quoted 5 lines
Quoted 3 lines · Zhiqiang

Hi all,

This is a follow-up of one of the CDS session at

http://tracker.ceph.com/projects/ceph/wiki/Improvement_on_the_cache_tieri

Quoted 1 line

ng_eviction. We discussed the drawbacks of the current eviction

algorithm and

Quoted 1 line

several ways to improve it. Seems like the LRU variants is the right

way to go. I

Quoted 1 line

come up with some design points after the CDS, and want to discuss

it with you.

Quoted 1 line

It is an approximate 2Q algorithm, combining some benefits of the

clock

Quoted 1 line

algorithm, similar to what the linux kernel does for the page

cache.

Quoted 2 lines

Unfortunately I missed this last CDS so I'm behind on the

discussion. I have a

Quoted 7 lines

few questions though...

Quoted 5 lines

# Design points:

## LRU lists
- Maintain LRU lists at the PG level.
The SharedLRU and SimpleLRU implementation in the current code

have a

Quoted 1 line
Quoted 1 line

max_size, which limits the max number of elements in the list.

This

Quoted 1 line
Quoted 1 line

mostly looks like a MRU, though its name implies they are LRUs.

Since

Quoted 1 line
Quoted 1 line

the object size may vary in a PG, it's not possible to caculate

the

Quoted 1 line
Quoted 1 line

total number of objects which the cache tier can hold ahead of

time.

Quoted 3 lines
Quoted 1 line

We need a new LRU implementation with no limit on the size.

This last sentence seems to me to be the crux of it. Assuming we

have an

Quoted 1 line

OSD based by flash storing O(n) objects, we need a way to maintain

an LRU of

Quoted 1 line

O(n) objects in memory. The current hitset-based approach was taken

based

Quoted 1 line

on the assumption that this wasn't feasible--or at least we didn't

know how to

Quoted 1 line

implmement such a thing. If it is, or we simply want to stipulate

that cache

Quoted 1 line

tier OSDs get gobs of RAM to make it possible, then lots of better

options

Quoted 3 lines

become possible...

Let's say you have a 1TB SSD, with an average object size of 1MB --

that's

Quoted 1 line

1 million objects. At maybe ~100bytes per object of RAM for an LRU

entry

Quoted 1 line

that's 100MB... so not so unreasonable, perhaps!

I was having the same question before proposing this. I did the similar calculation and thought it would be ok to use this many memory :-)

Quoted 2 lines
Quoted 2 lines

- Two lists for each PG: active and inactive Objects are first

put

Quoted 1 line
Quoted 1 line

into the inactive list when they are accessed, and moved between

these two

Quoted 6 lines

lists based on some criteria.

Quoted 5 lines

Object flag: active, referenced, unevictable, dirty.
- When an object is accessed:
1) If it's not in both of the lists, it's put on the top of the inactive list
2) If it's in the inactive list, and the referenced flag is not

set, the referenced

Quoted 2 lines

flag is set, and it's moved to the top of the inactive list.

Quoted 1 line

3) If it's in the inactive list, and the referenced flag is set,

the referenced flag

Quoted 1 line

is cleared, and it's removed from the inactive list, and put on top

of the active

Quoted 2 lines

list.

Quoted 1 line

4) If it's in the active list, and the referenced flag is not set,

the referenced

Quoted 2 lines

flag is set, and it's moved to the top of the active list.

Quoted 1 line

5) If it's in the active list, and the referenced flag is set,

it's moved to the top

Quoted 3 lines

of the active list.

Quoted 2 lines

- When selecting objects to evict:
1) Objects at the bottom of the inactive list are selected to

evict. They are

Quoted 2 lines

removed from the inactive list.

Quoted 1 line

2) If the number of the objects in the inactive list becomes low,

some of the

Quoted 1 line

objects at the bottom of the active list are moved to the inactive

list. For those

Quoted 1 line

objects which have the referenced flag set, they are given one more

chance in

Quoted 1 line

the active list. They are moved to the top of the active list with

the referenced

Quoted 1 line

flag cleared. For those objects which don't have the referenced flag

set, they

Quoted 1 line

are moved to the inactive list, with the referenced flag set. So

that they can be

Quoted 4 lines

quickly promoted to the active list when necessary.

Quoted 3 lines

## Combine flush with eviction
- When evicting an object, if it's dirty, it's flushed first.

After flushing, it's

Quoted 2 lines

evicted. If not dirty, it's evicted directly.

Quoted 1 line

- This means that we won't have separate activities and won't set

different

Quoted 2 lines

ratios for flush and evict. Is there a need to do so?

Quoted 1 line

- Number of objects to evict at a time. 'evict_effort' acts as the

priority, which

Quoted 3 lines

is used to calculate the number of objects to evict.

As someone else mentioned in a follow-up, the reason we let the

dirty level be

Quoted 1 line

set lower than the full level is that it provides headroom so that

objects can be

Quoted 1 line

quickly evicted (delete, no flush) to make room for new writes or

new

Quoted 3 lines

promotions.

That said, we probably can/should streamline the flush so that an

evict can

Quoted 1 line

immediately follow without waiting for the agent to come around

again.

Quoted 1 line

(I don't think we do that now?)

I was afraid of having to maintain different lists for flush/evict. So I proposed to combine flush with evict. But seems like we don't need to. When reaching the dirty ratio and selecting objects to flush, we look for dirty objects from the inactive list. The objects are marked clean and kept in the same position in the LRU list after flushing. When evicting objects, clean objects in the inactive list are selected. Dirty objects are ignored. This will keep the flush/evict the same as current implementation. Make sense?

Quoted 7 lines

sage

Quoted 3 lines

## LRU lists Snapshotting
- The two lists are snapshotted persisted periodically.
- Only one copy needs to be saved. The old copy is removed when

persisting

Quoted 1 line

the lists. The saved lists are used to restore the LRU lists when

OSD reboots.

Quoted 4 lines
Quoted 4 lines

Any comments/feedbacks are welcomed.
--
To unsubscribe from this list: send the line "unsubscribe

ceph-devel"

Quoted 1 line
Quoted 1 line

in the body of a message to [email protected] More

majordomo

Quoted 5 lines
Quoted 3 lines

info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe

ceph-devel" in the body

Quoted 2 lines

of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 10 lines
Matt Benjamin
CohortFS, LLC.
315 West Huron Street, Suite 140A
Ann Arbor, Michigan 48103

http://cohortfs.com

tel.  734-761-4689 
fax.  734-769-8938 
cel.  734-216-5309 
#2 lore raw
Quoted 4 lines · Matt W. Benjamin

Hi,

Couple of points.

Quoted 8 lines

1) a successor to 2Q is MQ (Li et al). We have an intrusive MQ LRU implementation
with 2 levels currently, plus a pinned queue, that addresses stuff like partitioning ("sharding"), scan resistance, and coordination w/lookup tables. We might extend/re-use it.

2) I'm a bit confused by active/inactive vocabulary, dimensioning of cache segments (are you proposing to/do we now always cache whole objects?), and cost of "looking for" dirty objects; I suspect that it makes sense to amortize the cost of locating segments eligible to be flushed, rather than minimize bookkeeping.

We make caching decisions in terms of whole objects right now, yeah. There's really nothing in the system that's capable of doing segments within an object, and it's not just about tracking a little more metadata about dirty objects — the way we handle snapshots, etc would have to be reworked if we were allowing partial-object caching. Plus keep in mind the IO cost of the bookkeeping — it needs to be either consistently persisted to disk or reconstructable from whatever happens to be in the object. That can get expensive really fast. -Greg

Quoted 189 lines

Matt

Quoted 167 lines · ----- "Zhiqiang Wang
Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Sage Weil
Sent: Tuesday, July 21, 2015 6:38 AM
To: Wang, Zhiqiang
Cc: [email protected]; [email protected]
Subject: Re: The design of the eviction improvement

Quoted 5 lines
Quoted 3 lines · Zhiqiang

Hi all,

This is a follow-up of one of the CDS session at

http://tracker.ceph.com/projects/ceph/wiki/Improvement_on_the_cache_tieri

Quoted 1 line

ng_eviction. We discussed the drawbacks of the current eviction

algorithm and

Quoted 1 line

several ways to improve it. Seems like the LRU variants is the right

way to go. I

Quoted 1 line

come up with some design points after the CDS, and want to discuss

it with you.

Quoted 1 line

It is an approximate 2Q algorithm, combining some benefits of the

clock

Quoted 1 line

algorithm, similar to what the linux kernel does for the page

cache.

Quoted 2 lines

Unfortunately I missed this last CDS so I'm behind on the

discussion. I have a

Quoted 7 lines

few questions though...

Quoted 5 lines

# Design points:

## LRU lists
- Maintain LRU lists at the PG level.
The SharedLRU and SimpleLRU implementation in the current code

have a

Quoted 1 line
Quoted 1 line

max_size, which limits the max number of elements in the list.

This

Quoted 1 line
Quoted 1 line

mostly looks like a MRU, though its name implies they are LRUs.

Since

Quoted 1 line
Quoted 1 line

the object size may vary in a PG, it's not possible to caculate

the

Quoted 1 line
Quoted 1 line

total number of objects which the cache tier can hold ahead of

time.

Quoted 3 lines
Quoted 1 line

We need a new LRU implementation with no limit on the size.

This last sentence seems to me to be the crux of it. Assuming we

have an

Quoted 1 line

OSD based by flash storing O(n) objects, we need a way to maintain

an LRU of

Quoted 1 line

O(n) objects in memory. The current hitset-based approach was taken

based

Quoted 1 line

on the assumption that this wasn't feasible--or at least we didn't

know how to

Quoted 1 line

implmement such a thing. If it is, or we simply want to stipulate

that cache

Quoted 1 line

tier OSDs get gobs of RAM to make it possible, then lots of better

options

Quoted 3 lines

become possible...

Let's say you have a 1TB SSD, with an average object size of 1MB --

that's

Quoted 1 line

1 million objects. At maybe ~100bytes per object of RAM for an LRU

entry

Quoted 1 line

that's 100MB... so not so unreasonable, perhaps!

I was having the same question before proposing this. I did the similar calculation and thought it would be ok to use this many memory :-)

Quoted 2 lines
Quoted 2 lines

- Two lists for each PG: active and inactive Objects are first

put

Quoted 1 line
Quoted 1 line

into the inactive list when they are accessed, and moved between

these two

Quoted 6 lines

lists based on some criteria.

Quoted 5 lines

Object flag: active, referenced, unevictable, dirty.
- When an object is accessed:
1) If it's not in both of the lists, it's put on the top of the inactive list
2) If it's in the inactive list, and the referenced flag is not

set, the referenced

Quoted 2 lines

flag is set, and it's moved to the top of the inactive list.

Quoted 1 line

3) If it's in the inactive list, and the referenced flag is set,

the referenced flag

Quoted 1 line

is cleared, and it's removed from the inactive list, and put on top

of the active

Quoted 2 lines

list.

Quoted 1 line

4) If it's in the active list, and the referenced flag is not set,

the referenced

Quoted 2 lines

flag is set, and it's moved to the top of the active list.

Quoted 1 line

5) If it's in the active list, and the referenced flag is set,

it's moved to the top

Quoted 3 lines

of the active list.

Quoted 2 lines

- When selecting objects to evict:
1) Objects at the bottom of the inactive list are selected to

evict. They are

Quoted 2 lines

removed from the inactive list.

Quoted 1 line

2) If the number of the objects in the inactive list becomes low,

some of the

Quoted 1 line

objects at the bottom of the active list are moved to the inactive

list. For those

Quoted 1 line

objects which have the referenced flag set, they are given one more

chance in

Quoted 1 line

the active list. They are moved to the top of the active list with

the referenced

Quoted 1 line

flag cleared. For those objects which don't have the referenced flag

set, they

Quoted 1 line

are moved to the inactive list, with the referenced flag set. So

that they can be

Quoted 4 lines

quickly promoted to the active list when necessary.

Quoted 3 lines

## Combine flush with eviction
- When evicting an object, if it's dirty, it's flushed first.

After flushing, it's

Quoted 2 lines

evicted. If not dirty, it's evicted directly.

Quoted 1 line

- This means that we won't have separate activities and won't set

different

Quoted 2 lines

ratios for flush and evict. Is there a need to do so?

Quoted 1 line

- Number of objects to evict at a time. 'evict_effort' acts as the

priority, which

Quoted 3 lines

is used to calculate the number of objects to evict.

As someone else mentioned in a follow-up, the reason we let the

dirty level be

Quoted 1 line

set lower than the full level is that it provides headroom so that

objects can be

Quoted 1 line

quickly evicted (delete, no flush) to make room for new writes or

new

Quoted 3 lines

promotions.

That said, we probably can/should streamline the flush so that an

evict can

Quoted 1 line

immediately follow without waiting for the agent to come around

again.

Quoted 1 line

(I don't think we do that now?)

I was afraid of having to maintain different lists for flush/evict. So I proposed to combine flush with evict. But seems like we don't need to. When reaching the dirty ratio and selecting objects to flush, we look for dirty objects from the inactive list. The objects are marked clean and kept in the same position in the LRU list after flushing. When evicting objects, clean objects in the inactive list are selected. Dirty objects are ignored. This will keep the flush/evict the same as current implementation. Make sense?

Quoted 7 lines

sage

Quoted 3 lines

## LRU lists Snapshotting
- The two lists are snapshotted persisted periodically.
- Only one copy needs to be saved. The old copy is removed when

persisting

Quoted 1 line

the lists. The saved lists are used to restore the LRU lists when

OSD reboots.

Quoted 4 lines
Quoted 4 lines

Any comments/feedbacks are welcomed.
--
To unsubscribe from this list: send the line "unsubscribe

ceph-devel"

Quoted 1 line
Quoted 1 line

in the body of a message to [email protected] More

majordomo

Quoted 5 lines
Quoted 3 lines

info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe

Quoted 8 lines

ceph-devel" in the body

Quoted 2 lines

of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Matt Benjamin
CohortFS, LLC.
315 West Huron Street, Suite 140A
Ann Arbor, Michigan 48103

http://cohortfs.com

Quoted 7 lines
tel.  734-761-4689
fax.  734-769-8938
cel.  734-216-5309

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Matt W. Benjamin

Hi Matt,

Quoted 7 lines

-----Original Message-----
From: Matt W. Benjamin [mailto:[email protected]]
Sent: Tuesday, July 21, 2015 10:16 PM
To: Wang, Zhiqiang
Cc: [email protected]; [email protected]; Sage Weil
Subject: Re: The design of the eviction improvement

Quoted 8 lines

Hi,

Couple of points.

1) a successor to 2Q is MQ (Li et al). We have an intrusive MQ LRU implementation with 2 levels currently, plus a pinned queue, that addresses stuff like partitioning ("sharding"), scan resistance, and coordination w/lookup tables. We might extend/re-use it.

The MQ algorithm is more complex, and seems like it has more overhead than 2Q. The approximate 2Q algorithm here combines some benefits of the clock algorithm, and works well on the linux kernel. MQ could be another choice. There are some other candidates like LIRS, ARC, etc., which have been deployed in some practical systems.

Quoted 6 lines

2) I'm a bit confused by active/inactive vocabulary, dimensioning of cache segments (are you proposing to/do we now always cache whole objects?), and cost of "looking for" dirty objects; I suspect that it makes sense to amortize the cost of locating segments eligible to be flushed, rather than minimize bookkeeping.

Though currently the caching decisions are made in the unit of object as Greg pointed out in another mail, I think we still have something to improve here. I'll come back to this some time later.

Quoted 193 lines

Matt

Quoted 168 lines · ----- "Zhiqiang Wang
Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Sage Weil
Sent: Tuesday, July 21, 2015 6:38 AM
To: Wang, Zhiqiang
Cc: [email protected]; [email protected]
Subject: Re: The design of the eviction improvement

Quoted 5 lines
Quoted 3 lines · Zhiqiang

Hi all,

This is a follow-up of one of the CDS session at

http://tracker.ceph.com/projects/ceph/wiki/Improvement_on_the_cache_ti
eri

Quoted 1 line

ng_eviction. We discussed the drawbacks of the current eviction

algorithm and

Quoted 1 line

several ways to improve it. Seems like the LRU variants is the right

way to go. I

Quoted 1 line

come up with some design points after the CDS, and want to discuss

it with you.

Quoted 1 line

It is an approximate 2Q algorithm, combining some benefits of the

clock

Quoted 1 line

algorithm, similar to what the linux kernel does for the page

cache.

Quoted 2 lines

Unfortunately I missed this last CDS so I'm behind on the

discussion. I have a

Quoted 7 lines

few questions though...

Quoted 5 lines

# Design points:

## LRU lists
- Maintain LRU lists at the PG level.
The SharedLRU and SimpleLRU implementation in the current code

have a

Quoted 1 line
Quoted 1 line

max_size, which limits the max number of elements in the list.

This

Quoted 1 line
Quoted 1 line

mostly looks like a MRU, though its name implies they are LRUs.

Since

Quoted 1 line
Quoted 1 line

the object size may vary in a PG, it's not possible to caculate

the

Quoted 1 line
Quoted 1 line

total number of objects which the cache tier can hold ahead of

time.

Quoted 3 lines
Quoted 1 line

We need a new LRU implementation with no limit on the size.

This last sentence seems to me to be the crux of it. Assuming we

have an

Quoted 1 line

OSD based by flash storing O(n) objects, we need a way to maintain

an LRU of

Quoted 1 line

O(n) objects in memory. The current hitset-based approach was taken

based

Quoted 1 line

on the assumption that this wasn't feasible--or at least we didn't

know how to

Quoted 1 line

implmement such a thing. If it is, or we simply want to stipulate

that cache

Quoted 1 line

tier OSDs get gobs of RAM to make it possible, then lots of better

options

Quoted 3 lines

become possible...

Let's say you have a 1TB SSD, with an average object size of 1MB --

that's

Quoted 1 line

1 million objects. At maybe ~100bytes per object of RAM for an LRU

entry

Quoted 1 line

that's 100MB... so not so unreasonable, perhaps!

I was having the same question before proposing this. I did the similar calculation and thought it would be ok to use this many memory :-)

Quoted 2 lines
Quoted 2 lines

- Two lists for each PG: active and inactive Objects are first

put

Quoted 1 line
Quoted 1 line

into the inactive list when they are accessed, and moved between

these two

Quoted 6 lines

lists based on some criteria.

Quoted 5 lines

Object flag: active, referenced, unevictable, dirty.
- When an object is accessed:
1) If it's not in both of the lists, it's put on the top of the inactive list
2) If it's in the inactive list, and the referenced flag is not

set, the referenced

Quoted 2 lines

flag is set, and it's moved to the top of the inactive list.

Quoted 1 line

3) If it's in the inactive list, and the referenced flag is set,

the referenced flag

Quoted 1 line

is cleared, and it's removed from the inactive list, and put on top

of the active

Quoted 2 lines

list.

Quoted 1 line

4) If it's in the active list, and the referenced flag is not set,

the referenced

Quoted 2 lines

flag is set, and it's moved to the top of the active list.

Quoted 1 line

5) If it's in the active list, and the referenced flag is set,

it's moved to the top

Quoted 3 lines

of the active list.

Quoted 2 lines

- When selecting objects to evict:
1) Objects at the bottom of the inactive list are selected to

evict. They are

Quoted 2 lines

removed from the inactive list.

Quoted 1 line

2) If the number of the objects in the inactive list becomes low,

some of the

Quoted 1 line

objects at the bottom of the active list are moved to the inactive

list. For those

Quoted 1 line

objects which have the referenced flag set, they are given one more

chance in

Quoted 1 line

the active list. They are moved to the top of the active list with

the referenced

Quoted 1 line

flag cleared. For those objects which don't have the referenced flag

set, they

Quoted 1 line

are moved to the inactive list, with the referenced flag set. So

that they can be

Quoted 4 lines

quickly promoted to the active list when necessary.

Quoted 3 lines

## Combine flush with eviction
- When evicting an object, if it's dirty, it's flushed first.

After flushing, it's

Quoted 2 lines

evicted. If not dirty, it's evicted directly.

Quoted 1 line

- This means that we won't have separate activities and won't set

different

Quoted 2 lines

ratios for flush and evict. Is there a need to do so?

Quoted 1 line

- Number of objects to evict at a time. 'evict_effort' acts as the

priority, which

Quoted 3 lines

is used to calculate the number of objects to evict.

As someone else mentioned in a follow-up, the reason we let the

dirty level be

Quoted 1 line

set lower than the full level is that it provides headroom so that

objects can be

Quoted 1 line

quickly evicted (delete, no flush) to make room for new writes or

new

Quoted 3 lines

promotions.

That said, we probably can/should streamline the flush so that an

evict can

Quoted 1 line

immediately follow without waiting for the agent to come around

again.

Quoted 1 line

(I don't think we do that now?)

I was afraid of having to maintain different lists for flush/evict. So I proposed to combine flush with evict. But seems like we don't need to. When reaching the dirty ratio and selecting objects to flush, we look for dirty objects from the inactive list. The objects are marked clean and kept in the same position in the LRU list after flushing. When evicting objects, clean objects in the inactive list are selected. Dirty objects are ignored. This will keep the flush/evict the same as current implementation. Make sense?

Quoted 7 lines

sage

Quoted 3 lines

## LRU lists Snapshotting
- The two lists are snapshotted persisted periodically.
- Only one copy needs to be saved. The old copy is removed when

persisting

Quoted 1 line

the lists. The saved lists are used to restore the LRU lists when

OSD reboots.

Quoted 4 lines
Quoted 4 lines

Any comments/feedbacks are welcomed.
--
To unsubscribe from this list: send the line "unsubscribe

ceph-devel"

Quoted 1 line
Quoted 1 line

in the body of a message to [email protected] More

majordomo

Quoted 5 lines
Quoted 3 lines

info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe

Quoted 8 lines

ceph-devel" in the body

Quoted 2 lines

of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Matt Benjamin
CohortFS, LLC.
315 West Huron Street, Suite 140A
Ann Arbor, Michigan 48103

http://cohortfs.com

tel.  734-761-4689
fax.  734-769-8938
cel.  734-216-5309
#4 lore raw

Hi,

Quoted 17 lines · ----- "Zhiqiang Wang

Hi Matt,

Quoted 7 lines

-----Original Message-----
From: Matt W. Benjamin [mailto:[email protected]]
Sent: Tuesday, July 21, 2015 10:16 PM
To: Wang, Zhiqiang
Cc: [email protected]; [email protected]; Sage Weil
Subject: Re: The design of the eviction improvement

Quoted 6 lines

Hi,

Couple of points.

1) a successor to 2Q is MQ (Li et al). We have an intrusive MQ LRU implementation with 2 levels currently, plus a pinned queue, that

addresses

Quoted 1 line

stuff like partitioning ("sharding"), scan resistance, and

Quoted 8 lines

coordination w/lookup

Quoted 1 line

tables. We might extend/re-use it.

The MQ algorithm is more complex, and seems like it has more overhead than 2Q. The approximate 2Q algorithm here combines some benefits of the clock algorithm, and works well on the linux kernel. MQ could be another choice. There are some other candidates like LIRS, ARC, etc., which have been deployed in some practical systems.

MQ has been deployed in practical systems, and is more general.

Quoted 237 lines
Quoted 3 lines

2) I'm a bit confused by active/inactive vocabulary, dimensioning of

cache

Quoted 1 line

segments (are you proposing to/do we now always cache whole

objects?), and

Quoted 1 line

cost of "looking for" dirty objects; I suspect that it makes sense

to amortize

Quoted 1 line

the cost of locating segments eligible to be flushed, rather than

minimize

Quoted 1 line

bookkeeping.

Though currently the caching decisions are made in the unit of object as Greg pointed out in another mail, I think we still have something to improve here. I'll come back to this some time later.

Quoted 8 lines

Matt

Quoted 3 lines · ----- "Zhiqiang Wang
Quoted 3 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Sage

Weil

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

Sent: Tuesday, July 21, 2015 6:38 AM
To: Wang, Zhiqiang
Cc: [email protected]; [email protected]
Subject: Re: The design of the eviction improvement

Quoted 3 lines · Zhiqiang

Hi all,

This is a follow-up of one of the CDS session at

http://tracker.ceph.com/projects/ceph/wiki/Improvement_on_the_cache_ti

Quoted 4 lines
Quoted 4 lines

eri

Quoted 1 line

ng_eviction. We discussed the drawbacks of the current eviction

algorithm and

Quoted 1 line

several ways to improve it. Seems like the LRU variants is the

right

Quoted 2 lines
Quoted 2 lines

way to go. I

Quoted 1 line

come up with some design points after the CDS, and want to

discuss

Quoted 2 lines
Quoted 2 lines

it with you.

Quoted 1 line

It is an approximate 2Q algorithm, combining some benefits of

the

Quoted 5 lines
Quoted 5 lines

clock

Quoted 1 line

algorithm, similar to what the linux kernel does for the page

cache.

Quoted 2 lines

Unfortunately I missed this last CDS so I'm behind on the

Quoted 8 lines
Quoted 8 lines

discussion. I have a

Quoted 7 lines

few questions though...

Quoted 5 lines

# Design points:

## LRU lists
- Maintain LRU lists at the PG level.
The SharedLRU and SimpleLRU implementation in the current

code

Quoted 2 lines
Quoted 2 lines

have a

Quoted 1 line
Quoted 1 line

max_size, which limits the max number of elements in the

list.

Quoted 2 lines
Quoted 2 lines

This

Quoted 1 line
Quoted 1 line

mostly looks like a MRU, though its name implies they are

LRUs.

Quoted 2 lines
Quoted 2 lines

Since

Quoted 1 line
Quoted 1 line

the object size may vary in a PG, it's not possible to

caculate

Quoted 2 lines
Quoted 2 lines

the

Quoted 1 line
Quoted 1 line

total number of objects which the cache tier can hold ahead

of

Quoted 4 lines
Quoted 4 lines

time.

Quoted 3 lines
Quoted 1 line

We need a new LRU implementation with no limit on the size.

This last sentence seems to me to be the crux of it. Assuming

we

Quoted 2 lines
Quoted 2 lines

have an

Quoted 1 line

OSD based by flash storing O(n) objects, we need a way to

maintain

Quoted 2 lines
Quoted 2 lines

an LRU of

Quoted 1 line

O(n) objects in memory. The current hitset-based approach was

taken

Quoted 2 lines
Quoted 2 lines

based

Quoted 1 line

on the assumption that this wasn't feasible--or at least we

didn't

Quoted 2 lines
Quoted 2 lines

know how to

Quoted 1 line

implmement such a thing. If it is, or we simply want to

stipulate

Quoted 2 lines
Quoted 2 lines

that cache

Quoted 1 line

tier OSDs get gobs of RAM to make it possible, then lots of

better

Quoted 4 lines
Quoted 4 lines

options

Quoted 3 lines

become possible...

Let's say you have a 1TB SSD, with an average object size of 1MB

--

Quoted 2 lines
Quoted 2 lines

that's

Quoted 1 line

1 million objects. At maybe ~100bytes per object of RAM for an

LRU

Quoted 5 lines
Quoted 5 lines

entry

Quoted 1 line

that's 100MB... so not so unreasonable, perhaps!

I was having the same question before proposing this. I did the similar calculation and thought it would be ok to use this many

memory

Quoted 4 lines
Quoted 4 lines

:-)

Quoted 2 lines
Quoted 2 lines

- Two lists for each PG: active and inactive Objects are

first

Quoted 2 lines
Quoted 2 lines

put

Quoted 1 line
Quoted 1 line

into the inactive list when they are accessed, and moved

between

Quoted 5 lines
Quoted 5 lines

these two

Quoted 4 lines

lists based on some criteria.

Quoted 3 lines

Object flag: active, referenced, unevictable, dirty.
- When an object is accessed:
1) If it's not in both of the lists, it's put on the top of

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

inactive list
2) If it's in the inactive list, and the referenced flag is

not

Quoted 3 lines
Quoted 3 lines

set, the referenced

Quoted 2 lines

flag is set, and it's moved to the top of the inactive list.

Quoted 1 line

3) If it's in the inactive list, and the referenced flag is

set,

Quoted 2 lines
Quoted 2 lines

the referenced flag

Quoted 1 line

is cleared, and it's removed from the inactive list, and put on

top

Quoted 3 lines
Quoted 3 lines

of the active

Quoted 2 lines

list.

Quoted 1 line

4) If it's in the active list, and the referenced flag is not

set,

Quoted 3 lines
Quoted 3 lines

the referenced

Quoted 2 lines

flag is set, and it's moved to the top of the active list.

Quoted 1 line

5) If it's in the active list, and the referenced flag is

set,

Quoted 7 lines
Quoted 7 lines

it's moved to the top

Quoted 3 lines

of the active list.

Quoted 2 lines

- When selecting objects to evict:
1) Objects at the bottom of the inactive list are selected to

evict. They are

Quoted 2 lines

removed from the inactive list.

Quoted 1 line

2) If the number of the objects in the inactive list becomes

low,

Quoted 2 lines
Quoted 2 lines

some of the

Quoted 1 line

objects at the bottom of the active list are moved to the

inactive

Quoted 2 lines
Quoted 2 lines

list. For those

Quoted 1 line

objects which have the referenced flag set, they are given one

more

Quoted 2 lines
Quoted 2 lines

chance in

Quoted 1 line

the active list. They are moved to the top of the active list

with

Quoted 2 lines
Quoted 2 lines

the referenced

Quoted 1 line

flag cleared. For those objects which don't have the referenced

flag

Quoted 2 lines
Quoted 2 lines

set, they

Quoted 1 line

are moved to the inactive list, with the referenced flag set.

So

Quoted 8 lines
Quoted 8 lines

that they can be

Quoted 4 lines

quickly promoted to the active list when necessary.

Quoted 3 lines

## Combine flush with eviction
- When evicting an object, if it's dirty, it's flushed first.

After flushing, it's

Quoted 2 lines

evicted. If not dirty, it's evicted directly.

Quoted 1 line

- This means that we won't have separate activities and won't

set

Quoted 3 lines
Quoted 3 lines

different

Quoted 2 lines

ratios for flush and evict. Is there a need to do so?

Quoted 1 line

- Number of objects to evict at a time. 'evict_effort' acts as

the

Quoted 6 lines
Quoted 6 lines

priority, which

Quoted 3 lines

is used to calculate the number of objects to evict.

As someone else mentioned in a follow-up, the reason we let the

dirty level be

Quoted 1 line

set lower than the full level is that it provides headroom so

that

Quoted 2 lines
Quoted 2 lines

objects can be

Quoted 1 line

quickly evicted (delete, no flush) to make room for new writes

or

Quoted 4 lines
Quoted 4 lines

new

Quoted 3 lines

promotions.

That said, we probably can/should streamline the flush so that

an

Quoted 6 lines
Quoted 6 lines

evict can

Quoted 1 line

immediately follow without waiting for the agent to come around

again.

Quoted 1 line

(I don't think we do that now?)

I was afraid of having to maintain different lists for

flush/evict. So

Quoted 1 line
Quoted 1 line

I proposed to combine flush with evict. But seems like we don't

need

Quoted 1 line
Quoted 1 line

to. When reaching the dirty ratio and selecting objects to flush,

we

Quoted 1 line
Quoted 1 line

look for dirty objects from the inactive list. The objects are

marked

Quoted 1 line
Quoted 1 line

clean and kept in the same position in the LRU list after

flushing.

Quoted 2 lines
Quoted 2 lines

When evicting objects, clean objects in the inactive list are selected. Dirty objects are ignored. This will keep the

flush/evict

Quoted 9 lines
Quoted 9 lines

the same as current implementation. Make sense?

Quoted 7 lines

sage

Quoted 3 lines

## LRU lists Snapshotting
- The two lists are snapshotted persisted periodically.
- Only one copy needs to be saved. The old copy is removed

when

Quoted 2 lines
Quoted 2 lines

persisting

Quoted 1 line

the lists. The saved lists are used to restore the LRU lists

when

Quoted 7 lines
Quoted 7 lines

OSD reboots.

Quoted 4 lines
Quoted 4 lines

Any comments/feedbacks are welcomed.
--
To unsubscribe from this list: send the line "unsubscribe

ceph-devel"

Quoted 1 line
Quoted 1 line

in the body of a message to [email protected] More

Quoted 8 lines
Quoted 8 lines

majordomo

Quoted 5 lines
Quoted 3 lines

info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe

ceph-devel" in the body

Quoted 1 line

of a message to [email protected] More majordomo info

Quoted 21 lines

at

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe

ceph-devel"

Quoted 2 lines
Quoted 2 lines

in
the body of a message to [email protected] More majordomo

info

Quoted 13 lines
Quoted 1 line

at http://vger.kernel.org/majordomo-info.html

--
Matt Benjamin
CohortFS, LLC.
315 West Huron Street, Suite 140A
Ann Arbor, Michigan 48103

http://cohortfs.com

tel.  734-761-4689
fax.  734-769-8938
cel.  734-216-5309

Matt

Signature · 10 lines
Matt Benjamin
CohortFS, LLC.
315 West Huron Street, Suite 140A
Ann Arbor, Michigan 48103

http://cohortfs.com

tel.  734-761-4689 
fax.  734-769-8938 
cel.  734-216-5309