-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce response times for deployments with specialized implementations
Reduce the time needed for completing an app deployment with some specialized implementations: + In case of migration, parallelize more tasks. + Speed up Elm App compilation with new caches. Compute a hash over the compilation arguments and store results in a dictionary. Limit memory usage of that cache by removing older items.
- Loading branch information
Showing
8 changed files
with
190 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Linq; | ||
|
||
namespace ElmFullstack | ||
{ | ||
static public class Cache | ||
{ | ||
static public void RemoveItemsToLimitRetainedSize<TKey, TValue, TOrderKey>( | ||
IDictionary<TKey, TValue> cache, | ||
Func<KeyValuePair<TKey, TValue>, long> computeItemSize, | ||
Func<KeyValuePair<TKey, TValue>, TOrderKey> computeItemRetentionPriority, | ||
long retainedSizeLimit) | ||
{ | ||
var itemsOrderedByRetentionPrio = | ||
cache | ||
.OrderByDescending(computeItemRetentionPriority) | ||
.ToImmutableList(); | ||
|
||
long aggregateSize = 0; | ||
|
||
foreach (var item in itemsOrderedByRetentionPrio) | ||
{ | ||
var itemSize = computeItemSize(item); | ||
|
||
aggregateSize += itemSize; | ||
|
||
if (retainedSizeLimit < aggregateSize) | ||
cache.Remove(item.Key, out _); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.