Skip to content

Commit

Permalink
v5.8.x Breakup minimum episode control into chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
terrelsa13 committed Oct 27, 2024
1 parent afd5cba commit 4195148
Show file tree
Hide file tree
Showing 3 changed files with 555 additions and 526 deletions.
13 changes: 6 additions & 7 deletions mumc_modules/mumc_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ def getDataSize(self,obj,seen=None):
obj_id = id(obj)
if obj_id in seen:
return 0
# Important mark as seen *before* entering recursion to gracefully handle
# self-referential objects
# Important mark as seen *before* entering recursion to gracefully handle self-referential objects
seen.add(obj_id)
if hasattr(obj, '__dict__'):
for cls in obj.__class__.__mro__:
Expand Down Expand Up @@ -138,16 +137,16 @@ def getTimeWindow(self):


def addEntryToCache(self,url,data):
potentialEntrySize=(self.getDataSize(url) + self.getDataSize(data))
if (potentialEntrySize <= self.api_query_cache_size):
estimatedEntryDataSize=(self.getDataSize(url) + self.getDataSize(data))
if (estimatedEntryDataSize <= self.api_query_cache_size):
try:
if (potentialEntrySize > (self.api_query_cache_size - self.total_cached_data_size)):
if (estimatedEntryDataSize > (self.api_query_cache_size - self.total_cached_data_size)):
#LRU get time window
safety_time_window=self.getTimeWindow()
temp_cached_entry_hits=self.cached_entry_hits.copy()
temp_cached_entry_urls=self.cached_entry_urls.copy()
temp_cached_entry_times=self.cached_entry_times.copy()
while potentialEntrySize > (self.api_query_cache_size - self.total_cached_data_size):
while estimatedEntryDataSize > (self.api_query_cache_size - self.total_cached_data_size):
if (len(self.cached_entry_sizes) > 0):
#LFU get least accessed cache entry
least_accessed_entry_index=self.getLowestAttributeValueCacheEntryIndex(temp_cached_entry_hits)
Expand Down Expand Up @@ -183,7 +182,7 @@ def addEntryToCache(self,url,data):
self.cached_data.append(data)
self.cached_entry_times.append(time.time() * 1000)
self.cached_entry_hits.append(0)
self.cached_entry_sizes.append(potentialEntrySize)
self.cached_entry_sizes.append(estimatedEntryDataSize)
size=self.cached_entry_sizes[index]
self.total_cached_data_size+=size
self.total_data_size_thru_cache+=size
Expand Down
Loading

0 comments on commit 4195148

Please sign in to comment.