-
Notifications
You must be signed in to change notification settings - Fork 882
feat(shard-distributor): record a smoothed per shard load in etcd #7431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Theis-Mathiassen
wants to merge
143
commits into
cadence-workflow:master
Choose a base branch
from
AndreasHolt:heartbeat-shard-statistics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
143 commits
Select commit
Hold shift + click to select a range
2de12d8
feat(shard distributor): add shard key helpers and metrics state
AndreasHolt 5d95067
feat(shard distributor): persist shard metrics in etcd store
AndreasHolt 6e57536
fix(shard distributor): update LastMoveTime in the case where a shard…
AndreasHolt 595d320
test(shard distributor): add tests for shard metrics
AndreasHolt d9ba54d
fix(shard distributor): modify comment
AndreasHolt 32d2ecd
fix(shard distributor): add atomic check to prevent metrics race
AndreasHolt b624a00
fix(shard distributor): apply shard metric updates in a second phase …
AndreasHolt aad7b2e
feat(shard distributor): move shard metric updates out of AssignShard…
AndreasHolt 6360f8a
fix(shard distributor): keep NamespaceState revisions tied to assignm…
AndreasHolt 1536d0a
refactor(shard distributor): use shard cache and clock for preparing …
AndreasHolt f316fbf
test(shard distributor): BuildShardPrefix, BuildShardKey, ParseShardKey
AndreasHolt 4524da9
feat(shard distributor): simplify shard metrics updates
AndreasHolt 126f725
refactor(shard distributor): ShardMetrics renamed to ShardStatistics.…
AndreasHolt cc53f68
test(shard distributor): small changes to shard key tests s.t. they l…
AndreasHolt 733bbcb
fix(shard distributor): no longer check for key type ShardStatisticsK…
AndreasHolt 6816b8e
refactor(shard distributor): found a place where I forgot to rename t…
AndreasHolt f97e0cf
fix(shard distributor): move non-exported helpers to end of file to f…
AndreasHolt 513e88c
feat(shard distributor): clean up the shard statistics
AndreasHolt 9833525
test(shard distributor): add test case for when shard stats are deleted
AndreasHolt 0332fe5
fix(shard distributor): add mapping (new metric)
AndreasHolt d5a13d9
feat(shard distributor): retain shard stats while shards are within h…
AndreasHolt 634bc02
feat: function to update shard statistics from heartbeat (currently n…
AndreasHolt 812e854
test(shard distributor): add tests to verify statistics are updated a…
AndreasHolt b9813e7
feat(shard distributor): calculate smoothed load (ewma) using the Sha…
AndreasHolt dfb7448
fix(shard distributor): log invalid shard load
AndreasHolt 36ec08f
chore: added logger warning and simplified ewma calculation
Theis-Mathiassen 38a6e81
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen af733e6
fix: remove duplicate test introduced in merge
AndreasHolt a52e86f
chore: consistent error checking, and rename function
Theis-Mathiassen abfc80e
chore: added decompress to unmarshal
Theis-Mathiassen df0feaf
feat(shard distributor): persist shard metrics in etcd store
AndreasHolt 8546a26
feat(shard distributor): move shard metric updates out of AssignShard…
AndreasHolt dde87ef
fix(shard distributor): keep NamespaceState revisions tied to assignm…
AndreasHolt 415e80c
refactor(shard distributor): use shard cache and clock for preparing …
AndreasHolt c67d5c3
feat(shard distributor): simplify shard metrics updates
AndreasHolt 9ffcefb
refactor(shard distributor): ShardMetrics renamed to ShardStatistics.…
AndreasHolt cc769bf
refactor(shard distributor): found a place where I forgot to rename t…
AndreasHolt 8c22663
fix(shard distributor): move non-exported helpers to end of file to f…
AndreasHolt 5ac3c5d
test(shard distributor): add test case for when shard stats are deleted
AndreasHolt 3973b82
feat(shard distributor): retain shard stats while shards are within h…
AndreasHolt 3830d5e
feat: function to update shard statistics from heartbeat (currently n…
AndreasHolt 443c0b1
test(shard distributor): add tests to verify statistics are updated a…
AndreasHolt 9d159e7
feat(shard distributor): calculate smoothed load (ewma) using the Sha…
AndreasHolt 18e63b7
fix(shard distributor): log invalid shard load
AndreasHolt e08a286
chore: added logger warning and simplified ewma calculation
Theis-Mathiassen 08eb635
fix: remove duplicate test introduced in merge
AndreasHolt f63664a
chore: consistent error checking, and rename function
Theis-Mathiassen 10e2ffa
chore: added decompress to unmarshal
Theis-Mathiassen 8c6b0c8
chore: removed an old struct that appeared during rebase
Theis-Mathiassen 158e030
feat(shard distributor): throttle shard-stat writes
AndreasHolt dd45ff0
Merge branch 'heartbeat-shard-statistics' of github.com:AndreasHolt/c…
AndreasHolt 05e0d1d
fix(shard distributor): linter error
AndreasHolt e0779ec
feat(shard distributor): decouple shard stats write-throttling decisi…
AndreasHolt 9546f24
Merge branch 'master' into heartbeat-shard-statistics
AndreasHolt db70702
fix(shard-distributor): inverted condition in shard stats cleanup loop
AndreasHolt 481f9c6
chore(shard-distributor): did some formatting, and use current load i…
Theis-Mathiassen f754dd6
Merge branch 'master' into heartbeat-shard-statistics
AndreasHolt 3366828
fix(shard distributor): decouple shard assignment from stats writes
AndreasHolt 1c01604
feat: add new ExecutorKeyType for stats, add case to GetState and rem…
AndreasHolt e3294b9
feat: update etcdstore.go to support new way of storing stats
AndreasHolt 915da0f
test: persistence of new stats
AndreasHolt e3bd964
test: update test, remove batching
AndreasHolt 352df29
chore: ExecutorShardStatisticsKey is not significant
AndreasHolt a22908e
fix: linter
AndreasHolt 49ed5cc
chore: delete shard key related helpers and tests
AndreasHolt 1ddad41
chore: add logs to cleanup
AndreasHolt c0bc604
fix: comment
AndreasHolt 2e81f28
chore: remove debug logs
AndreasHolt e36f2a1
CI rerun
AndreasHolt 3753640
fix: remove "len(ops) == 0" check
AndreasHolt e11b0d9
Merge remote-tracking branch 'origin/stats-etcd-refactor' into heartb…
Theis-Mathiassen b88ff69
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen e943951
feat: changed heartbeat record statistics in new format
Theis-Mathiassen 03a655a
fix: potential fix to smothed load not working as expected
AndreasHolt 1c0b0fb
feat: implemented getting shard statistics, using cache
Theis-Mathiassen 84976c3
test: added and altered tests to work with statistics from cache
Theis-Mathiassen c779090
Merge branch 'heartbeat-shard-statistics' of github.com:AndreasHolt/c…
Theis-Mathiassen cb27553
feat: locks and optimization
AndreasHolt 746095a
chore: comments
AndreasHolt 0ca3bda
chore: added comment describing a complicated function
Theis-Mathiassen bfd1973
Merge branch 'heartbeat-shard-statistics' of github.com:AndreasHolt/c…
AndreasHolt 7975639
Merge remote-tracking branch 'origin/master' into heartbeat-shard-sta…
Theis-Mathiassen ece4cd4
chore: refactored a function, only calling 1 other function
Theis-Mathiassen 7b82b9e
chore: set LastMoveTime to zero for new shards
AndreasHolt daf4aa4
Merge branches 'heartbeat-shard-statistics' and 'heartbeat-shard-stat…
AndreasHolt 51e9480
fix: event type
AndreasHolt 90cfc58
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen 8daa183
chore: removed unused test helper functions causing build errors
Theis-Mathiassen c03c9b3
chore: consistent naming
AndreasHolt 4aa7ab2
Merge branch 'heartbeat-shard-statistics' of github.com:AndreasHolt/c…
AndreasHolt 8938199
chore: return error directly, reference ewma as smoothed load
AndreasHolt 8ae5baa
chore: Removed no longer needed statistics from test, and magic number
Theis-Mathiassen 2a7e86d
Merge branch 'heartbeat-shard-statistics' of github.com:AndreasHolt/c…
Theis-Mathiassen 1558cd4
chore: moved large switch case into separate function
Theis-Mathiassen 5a9404c
chore: refactored GetExecutorStatistics, fixed some concurrency probl…
Theis-Mathiassen afd2755
chore: moved statistics relevant data to separate struct
Theis-Mathiassen fef9cb8
chore: moved and renamed ewmasmoothload calculation
Theis-Mathiassen aa9553e
chore: renamed mutable variable to something more descriptive, and ma…
Theis-Mathiassen 9e944e5
chore: returning error from applyStatistics as we now treat statistic…
Theis-Mathiassen 718c161
chore: responding on applyShardStatistics now returning error
Theis-Mathiassen b38fa88
chore: continues best effort to update statistics, and return multipl…
Theis-Mathiassen 3f0e893
chore: renamed recordShardStatistics in order to reflect what is happ…
Theis-Mathiassen 0ae823b
chore: moved the load check to calculate smoothload function
Theis-Mathiassen 4f649dd
chore: extract statistic update from etcdstore
Theis-Mathiassen eba5943
chore: added a timesource to namespaceShardToExecutor and ShardToExec…
Theis-Mathiassen e9461bf
chore: refactored refreshExecutorState to adhere closer to MVC archit…
Theis-Mathiassen 2e51154
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen dff7f07
chore: kept the lock while cloning, and moved right before ok created
Theis-Mathiassen 4625397
fix: changed the way we wait using timesource in tests
Theis-Mathiassen ecbab71
fix: changed some time.Now to use mocktime source
Theis-Mathiassen fb58ce6
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen 0e783e0
fix: removed duplicate timesource
Theis-Mathiassen 465c722
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen 7f3b9a5
chore: moved CalculateSmoothedLoad out of executor store
Theis-Mathiassen 83af565
chore: added alias to metadata
Theis-Mathiassen 441bdd2
chore: refactored GetExecutorStatistics
Theis-Mathiassen abcb6d0
chore: added error logging statements to parse executor key
Theis-Mathiassen f7c9d77
chore: removed functions only used once
Theis-Mathiassen 671661c
chore: simplified return in RecordHeartbeat
Theis-Mathiassen 20456d6
chore: refactored calcUpdatedStatistics
Theis-Mathiassen 92fafe5
chore: fixed duplicate error messages
Theis-Mathiassen 38cf3d9
chore: added logging to parseExecutorData
Theis-Mathiassen 5d3b545
chore: refactored executorData to be for a single executor
Theis-Mathiassen 09a4a40
chore: added some spacing
Theis-Mathiassen 260af7e
feat: added helper functions for namespaceExecutorStatistics
Theis-Mathiassen 6db1110
chore: refactored introducing maps.clone
Theis-Mathiassen 537dab9
chore: refactored switch in watch in namespaceshardcache
Theis-Mathiassen 7e93d0d
chore: made reason for deleting statistics more clear in handleExecut…
Theis-Mathiassen 457997a
chore: refactored namespaceShardsCache
Theis-Mathiassen c5bb576
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen 3fdc134
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen d3e660e
fix: tests failing
AndreasHolt 4389eab
fix: same fix but for shardcache
AndreasHolt c40dac8
Merge remote-tracking branch 'origin/master' into heartbeat-shard-sta…
AndreasHolt c6e5cfe
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen f4fab6b
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen a874d8d
fix: test match functionality, and watch error not checked before pro…
Theis-Mathiassen f83952e
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen 8142dab
fix: initial write of statistics would fail
Theis-Mathiassen fc8f9fb
fix: performance holding locks for less time and bug where executorSt…
Theis-Mathiassen 4063c59
fix: properly return executor not found without wrapper to satisfy test
Theis-Mathiassen 3847095
fix: correct handling of executor not found, and more useful error me…
Theis-Mathiassen 3550766
Merge branch 'master' into heartbeat-shard-statistics
Theis-Mathiassen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,22 @@ | ||
| package statistics | ||
|
|
||
| import ( | ||
| "math" | ||
| "time" | ||
| ) | ||
|
|
||
| func CalculateSmoothedLoad(prev, current float64, lastUpdate, now time.Time) float64 { | ||
| if math.IsNaN(current) || math.IsInf(current, 0) { | ||
| current = 0 | ||
| } | ||
| const tau = 30 * time.Second // smaller = more responsive, larger = smoother | ||
| if lastUpdate.IsZero() || tau <= 0 { | ||
| return current | ||
| } | ||
| if now.Before(lastUpdate) { | ||
| return current | ||
| } | ||
| dt := now.Sub(lastUpdate) | ||
| alpha := 1 - math.Exp(-dt.Seconds()/tau.Seconds()) | ||
| return (1-alpha)*prev + alpha*current | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.