Skip to content
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: vm scheduler #10

Merged
merged 6 commits into from
May 7, 2024
Merged

feat: vm scheduler #10

merged 6 commits into from
May 7, 2024

Conversation

WoodenMaiden
Copy link
Contributor

Resolves #9

@WoodenMaiden WoodenMaiden linked an issue Apr 11, 2024 that may be closed by this pull request
@WoodenMaiden WoodenMaiden changed the title feat: redis connection feat: vm scheduler Apr 15, 2024
@WoodenMaiden WoodenMaiden marked this pull request as draft April 15, 2024 07:03
@WoodenMaiden WoodenMaiden self-assigned this Apr 15, 2024
@WoodenMaiden WoodenMaiden force-pushed the 9-vm-scheduler branch 3 times, most recently from 5bdcb96 to 556168e Compare April 16, 2024 14:35
@WoodenMaiden WoodenMaiden marked this pull request as ready for review April 25, 2024 14:23
@WoodenMaiden WoodenMaiden requested review from alexis-langlet and nponsard and removed request for alexis-langlet May 2, 2024 16:53
scheduler/lambdoService.go Show resolved Hide resolved
scheduler/lambdoService.go Show resolved Hide resolved
scheduler/lambdoService.go Show resolved Hide resolved

if returnedCursor != 0 {
// the current sweep did not find anything, we try again
return s.LookForReadyInstance(functionId, returnedCursor)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this is recursive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically in Redis, SCAN allows you to get keys matching a certain pattern just like KEYS would.

While KEYS locks the DB and scans everything in one shot, SCAN gets x keys and returns a cursor, you can then use the returned cursor to your next SCAN call to continue scanning until the returned cursor is 0.

This is why it is recursive, I can refactor it into interative if you want.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I understand
You don't need to put that in an iterative way but if could just add some comments in your code to say what you just explained it would be really nice



// because while does not exists in these lands
for ok, cursor := true, uint64(0) ; ok; ok = (cursor != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe using a for true { if (...) break } would be more understandable ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't understand this line, feels like it could be simpler.



// because while does not exists in these lands
for ok, cursor := true, uint64(0) ; ok; ok = (cursor != 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't understand this line, feels like it could be simpler.

main.go Outdated
}
//Now inject the scheduler into the routes that need it!

err := cronjob.AddFunc("0 */6 * * *", func() { s.FindAndDestroyUnsused() })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a library to do this ?

Sounds like it could be a loop with a sleep in a separate thread (using the go keyword)

return
}

func (s *Scheduler) FindAndDestroyUnsused() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have a comment explaining what this do

Copy link
Contributor

@alexis-langlet alexis-langlet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good to me
Still a bit complicated on some points but it's good and we will add comment next time we work on that part ;)

@WoodenMaiden WoodenMaiden merged commit 03512aa into main May 7, 2024
2 checks passed
WoodenMaiden added a commit that referenced this pull request May 13, 2024
WoodenMaiden added a commit that referenced this pull request May 13, 2024
WoodenMaiden added a commit that referenced this pull request May 14, 2024
WoodenMaiden added a commit that referenced this pull request May 16, 2024
WoodenMaiden added a commit that referenced this pull request May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VM scheduler
3 participants