The design of the eviction improvement
A message that is not in the archive (sent off-list or not yet received): 639332441.73.1437495369873.JavaMail.root@thunderbeast.private.linuxbox.com
Thanks for the explanations, Greg.
Quoted 22 lines · ----- "Gregory Farnum
Quoted 5 lines · Matt W. Benjamin
Hi,
Couple of points.
1) a successor to 2Q is MQ (Li et al). We have an intrusive MQ LRU
implementation
Quoted 1 line
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.
Quoted 2 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 cost
Quoted 1 line
of "looking for" dirty objects; I suspect that it makes sense to
amortize the
Quoted 1 line
cost of locating segments eligible to be flushed, rather than
minimize
Quoted 1 line
bookkeeping.
Quoted 9 lines
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
For current semantics/structure of PGs + specific tier held fixed, makes sense. For our object addressing currently, we have a greater requirement for partial object caching. (Partly, we did this to achieve periodicity w/sequential I/O.) I think broadly, there are large performance tradeoffs here. In AFS and DCE, there is full consistency in materialized caches. Also, caches are dimensioned by chunks. If the cache is materialized in memory, the semantics aren't those of "disk." Basically, consistency guarantees are policy. Different snapshot mechanisms, or omtting them, e.g., should logically enable relaxed consistency, modulo policy.
Matt
Quoted 243 lines
Quoted 20 lines
Matt
Quoted 14 lines · ----- "Zhiqiang Wang
Quoted 13 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 improvementQuoted 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 3 lines
Quoted 3 lines
Quoted 1 line
ng_eviction. We discussed the drawbacks of the current evictionalgorithm 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 10 lines
Quoted 10 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
discussion. I have a
Quoted 4 lines
few questions though...
Quoted 2 lines
# Design points:
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
## LRU lists
- Maintain LRU lists at the PG level.
The SharedLRU and SimpleLRU implementation in the current codehave 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.
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 6 lines
Quoted 6 lines
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
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 6 lines
Quoted 6 lines
:-)
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
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 ofthe
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 isnot
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 10 lines
Quoted 10 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,
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 toevict. 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 10 lines
Quoted 10 lines
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
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 asthe
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 removedwhen
Quoted 2 lines
Quoted 2 lines
persisting
Quoted 1 line
the lists. The saved lists are used to restore the LRU lists
when
Quoted 11 lines
Quoted 11 lines
OSD reboots.
Quoted 4 lines
Quoted 4 lines
Any comments/feedbacks are welcomed.
--
To unsubscribe from this list: send the line "unsubscribeceph-devel"
Quoted 1 line
Quoted 1 line
in the body of a message to [email protected] More
majordomo
Quoted 3 lines
Quoted 3 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
--
To unsubscribe from this list: send the line "unsubscribeceph-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 "unsubscribeceph-devel"
Quoted 10 lines
Quoted 3 lines
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 48103Quoted 7 lines
tel. 734-761-4689 fax. 734-769-8938 cel. 734-216-5309--
To unsubscribe from this list: send the line "unsubscribeceph-devel" in
Quoted 2 lines
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
Signature · 14 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 -- 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