-
Notifications
You must be signed in to change notification settings - Fork 8
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
Refactor Fetch State to allow dynamically manage partitions #405
Changes from 4 commits
3f77d7a
938903c
2ca07c4
118b5c6
b584c87
4bd1f0d
7de0989
2b496fb
7598773
013d460
f009dd0
b87877a
10fdcd9
efb8205
c4be087
d884bf1
db7d537
17adadb
8001d74
d77f63b
d624d6a
fa46f2b
528fb11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,7 +396,7 @@ type batchRes = { | |
let createBatch = (self: t, ~maxBatchSize: int, ~onlyBelowReorgThreshold: bool) => { | ||
let refTime = Hrtime.makeTimer() | ||
|
||
let {arbitraryEventQueue, chainFetchers} = self | ||
let {arbitraryEventQueue} = self | ||
//Make a copy of the queues and fetch states since we are going to mutate them | ||
let arbitraryEventQueue = arbitraryEventQueue->Array.copy | ||
let fetchStatesMap = self->getFetchStateWithData(~shouldDeepCopy=true) | ||
|
@@ -409,15 +409,23 @@ let createBatch = (self: t, ~maxBatchSize: int, ~onlyBelowReorgThreshold: bool) | |
~onlyBelowReorgThreshold, | ||
) | ||
|
||
// Needed to recalculate the computed queue sizes | ||
let fetchStatesMap = fetchStatesMap->ChainMap.map(v => { | ||
{ | ||
...v, | ||
partitionedFetchState: v.partitionedFetchState->PartitionedFetchState.syncStateOnQueueUpdate, | ||
} | ||
}) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should be done inside getFetchStateWithData function on the shouldDeepCopy flag or with a different flag. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. During There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see, well what should probably happen is the popItem function should decrement the queue size. But all good |
||
let batchSize = batch->Array.length | ||
|
||
let val = if batchSize > 0 { | ||
let fetchedEventsBuffer = | ||
chainFetchers | ||
->ChainMap.values | ||
->Array.map(fetcher => ( | ||
fetcher.chainConfig.chain->ChainMap.Chain.toString, | ||
fetcher.partitionedFetchState->PartitionedFetchState.queueSize, | ||
fetchStatesMap | ||
->ChainMap.entries | ||
->Array.map(((chain, v)) => ( | ||
chain->ChainMap.Chain.toString, | ||
v.partitionedFetchState->PartitionedFetchState.queueSize, | ||
)) | ||
->Array.concat([("arbitrary", self.arbitraryEventQueue->Array.length)]) | ||
->Js.Dict.fromArray | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this field? Or add todo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do in the next PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool just don't want to forget about it 👍🏼