Skip to content

Conversation

@vpandiarajan20
Copy link
Member

@vpandiarajan20 vpandiarajan20 commented Nov 3, 2025

Was working on something adjacent and was confused by the additional thread, decided to add a quick fix.

Times for downloading a 3,036 dataset

Before:
go run cli/viam/main.go dataset export --destination=tmp/tmp   7.08s user 20.58s system 7% cpu 5:46.01 total
After:
go run cli/viam/main.go dataset export --destination=tmp/tmp   6.78s user 19.08s system 10% cpu 4:01.11 total

This isn't definitive proof of a speed up since this is just one trial and I can test more if necessary, but this is also a readability improvement and removes the unprotected done variable.

Verified appropriate behavior on random error.

Please lmk if the batching was there for a reason that I've overlooked, it doesn't seem to preserve order upon first glance so not sure why it's there.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Nov 3, 2025
var wg sync.WaitGroup

// In one routine, get all IDs matching the filter and pass them into the ids channel.
wg.Add(1)
Copy link
Member Author

Choose a reason for hiding this comment

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

I also don't think this waitGroup is necessary, but good programming practices maybe?

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Nov 3, 2025
@vpandiarajan20 vpandiarajan20 marked this pull request as ready for review November 4, 2025 21:35
}()
}()
}
downloadWG.Wait()
Copy link
Member

Choose a reason for hiding this comment

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

Should this go after wg.Wait?

Copy link
Member Author

Choose a reason for hiding this comment

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

done!

err := actionOnBinaryData(id)
if err != nil {
errs <- err
cancel()
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 want to return here? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I think the original code's count was off by one!

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test This pull request is marked safe to test from a trusted zone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants