CtrlCore: Fixed performance issue with Font cache in Gtk3 backend

git-svn-id: svn://ultimatepp.org/upp/trunk@14590 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-06-13 17:13:27 +00:00
parent 97bba1661a
commit cf695cade4
7 changed files with 15 additions and 7 deletions

View file

@ -381,6 +381,7 @@ public:
const K& GetLRUKey();
void DropLRU();
void Shrink(int maxsize, int maxcount = 30000);
void ShrinkCount(int maxcount = 30000) { Shrink(INT_MAX, maxcount); }
template <class P> int Remove(P predicate);
template <class P> bool RemoveOne(P predicate);

View file

@ -294,7 +294,7 @@ static LRUCache<bool, SpellKey> speller_cache;
bool SpellWord(const WString& ws, int lang)
{
speller_cache.Shrink(2000);
speller_cache.ShrinkCount(2000);
SpellMaker m;
m.k.lang = lang;
m.k.wrd = ws;

View file

@ -47,7 +47,7 @@ void ShrinkValueCache()
Mutex::Lock __(ValueCacheMutex);
if(!ValueCacheMaxSizeLimitHigh)
AdjustValueCache();
TheValueCache().Shrink(ValueCacheMaxSize, 2000);
TheValueCache().Shrink(ValueCacheMaxSize, 20000);
LLOG("MakeValue cache size after shrink: " << TheValueCache().GetSize());
}

View file

@ -45,7 +45,7 @@ nst]_`=_[@3 0]&]
[s5;:LRUCache`:`:Maker`:`:Make`(T`&`)const: [@(0.0.255) virtual] [@(0.0.255) int]_[* Make](
[*@4 T][@(0.0.255) `&]_[*@3 object])_[@(0.0.255) const]_`=_[@3 0]&]
[s2;%% Creates the data based on parameters, returns the size of
created data.&]
created data in bytes.&]
[s3;%% &]
[s4; &]
[s5;:LRUCache`:`:Maker`:`:`~Maker`(`): [@(0.0.255) `~][* Maker]()&]
@ -56,7 +56,8 @@ created data.&]
[s3; &]
[s5;:LRUCache`:`:GetSize`(`)const: [@(0.0.255) int]_[* GetSize]()_[@(0.0.255) const]&]
[s2;%% Returns the total size of data in cache (as sum of numbers
returned by Maker`::Make).&]
returned by Maker`::Make). Note that LRUCache adds and estimate
of its internal memory consumption per item as well.&]
[s3;%% &]
[s4; &]
[s5;:LRUCache`:`:GetCount`(`)const: [@(0.0.255) int]_[* GetCount]()_[@(0.0.255) const]&]
@ -94,6 +95,12 @@ and [%-*@3 maxcount] items removing the least recently used items
first.&]
[s3;%% &]
[s4; &]
[s5;:Upp`:`:LRUCache`:`:ShrinkCount`(int`): [@(0.0.255) void]_[* ShrinkCount]([@(0.0.255) i
nt]_[*@3 maxcount]_`=_[@3 30000])&]
[s2;%% Reduces the cache to contain no more than [%-*@3 maxcount] regardless
of data size.&]
[s3;%% &]
[s4; &]
[s5;:LRUCache`:`:Remove`(P`): [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 P]>_[@(0.0.255) i
nt]_[* Remove]([*@4 P]_[*@3 predicate])&]
[s2;%% Removes data items from the cache for which [%-*@3 predicate]

View file

@ -85,7 +85,7 @@ void SystemDraw::FlushText()
SetColor(textink);
cairo_show_glyphs(cr, gs, textcache.GetCount());
cache.Shrink(64);
cache.Shrink(INT_MAX, 128);
textcache.Clear();
}

View file

@ -3,7 +3,7 @@
namespace Upp {
#define LLOG(x) // LOG(x)
#define LTIMING(x) // RTIMING(x)
#define LTIMING(x) // DTIMING(x)
LineEdit::LineEdit() {
isdrag = false;

View file

@ -69,7 +69,7 @@ int FileHexView::Byte(int64 addr)
{
blk = addr >> BLKSHIFT;
String h = cache.Get(*this);
cache.Shrink(10); // cache only 10 blocks (~150 KB)
cache.ShrinkCount(10); // cache only 10 blocks (~150 KB)
int ii = addr & (BLKSIZE - 1);
return ii < h.GetCount() ? (byte)h[ii] : 0;
}