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.
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
feat: deterministic tasking #85
feat: deterministic tasking #85
Changes from all commits
e9be757
f9aa7ae
4ea71d2
b4a04af
489a213
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This code will need to stay in sync with the fraud-detection code in spark-evaluate. At the same time, I don't expect it to change often. When we do change it, we need to carefully design a migration/deployment path how to update both spark-evaluate and the checker network at the same time. Considering that, I think it's ok to keep this code duplicated between the two GitHub repos (
spark
andspark-evaluate
).Also in spark-evaluate, I'll need to use a more efficient version using
k-closest
module instead ofArray.prototype.sort
. If we wanted to share that code, I would need to place it into a standalone npm package or else inline k-closest module into our codebase, otherwise we won't be able to vendor it here.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.
Does this method produce different results?
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.
It must produce the same results, otherwise the checkers will pick tasks that will not be accepted by spark-evaluate's fraud detection.
I verified this in my PoC by running
Array.prototype.sort
alongsidek-closest
and comparing the results. See here:https://github.com/filecoin-station/spark-evaluate/pull/287/files#diff-0f9e17445925f01057ff062d7d52d2862b081121d6e722cdeda8a2b1ad106ebcR275-R283
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.
Ok, and have you checked if
Array#sort
is too slow forspark-evaluate
?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.
If we can get dependabot to work for this repo, then I think it would be nicest to share this code in a dependency. If not, inlining like this should be the simplest
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.
Yes, of course. I don't remember the exact number, though. It was an order of magnitude slower.
I don't see any easy way how to enable dependabot here, let's keep this inlined for now.
Sure. Would you like me to add a code comment to this file too?
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.
Order of magnitude slower doesn't mean too slow though. Eg if it's 1ms vs 10ms or even 100ms it's probably still not be worth the extra complexity.
I don't think it's necessary since we're going to evolve the algorithm from spark-evaluate and not this repo
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.
The
k-closest
version takes 3-4 seconds to finish. The sort-based version took 1-2 minutes IIRC.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 re-ran the PoC using the Array sort() version. It takes 27.38 seconds to build the list of valid tasks.
The
k-closest
version takes 4 seconds to complete.For perspective: using the current spark-evaluate
main
, the entire dry-run evaluation of a single round takes 4.86 seconds.I thought that increasing the time to evaluate a round from 5 seconds to 33 seconds is not acceptable. However, if you think it's fine, then I am happy to use the Array sort() version in spark-evaluate too.
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.
Blocking the event loop for 33 seconds is super long, and the service will be unresponsive and not receive events. I agree
k-closest
is worth it here :)