Skip to content

Conversation

aelavender
Copy link
Contributor

Summary:
Minor optimisation opportunity that I noticed when poking around in here.

_step_requires_iterator uses the inspect module to look at type hints. This is somewhat expensive (tens of microseconds), so you probably don't want to recalculate it on every batch. It should be constant, so we can calculate it once during init.

Alternatively, we could stick a funcutils.cache decorator on _step_requires_iterator. That has its pros and cons, LMK if you think it's better.

Reviewed By: galrotem

Differential Revision: D80776986

@meta-cla meta-cla bot added the cla signed label Aug 22, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80776986

Summary:

Minor optimisation opportunity that I noticed when poking around in here.

`_step_requires_iterator` uses the `inspect` module to look at type hints.  This is somewhat expensive (tens of microseconds), so you probably don't want to recalculate it on every batch.  It should be constant, so we can calculate it once during init.

Alternatively, we could stick a `funcutils.cache` decorator on `_step_requires_iterator`.  That has its pros and cons, LMK if you think it's better.

Reviewed By: galrotem

Differential Revision: D80776986
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80776986

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants