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

bug: regression: slow to compute name of deeply nested expressions #8432

Closed
1 task done
NickCrews opened this issue Feb 23, 2024 · 2 comments · Fixed by #8445
Closed
1 task done

bug: regression: slow to compute name of deeply nested expressions #8432

NickCrews opened this issue Feb 23, 2024 · 2 comments · Fixed by #8445
Labels
bug Incorrect behavior inside of ibis

Comments

@NickCrews
Copy link
Contributor

What happened?

import ibis

x = ibis.literal(1)
for i in range(100):
    x = x + 1
    # if I hardcode the name, this is instantaneous
    # x = x.name(f"step_{i}")
x

If I ctrl-c this after a few seconds, I see see eg

File ~/code/ibis/ibis/expr/operations/core.py:89, in Value.name(self)
     86 @property
     87 def name(self) -> str:
     88     names = (arg.name for arg in self.__args__ if hasattr(arg, "name"))
---> 89     return f"{self.__class__.__name__}({', '.join(names)})"

File ~/code/ibis/ibis/expr/operations/core.py:88, in <genexpr>(.0)
     86 @property
     87 def name(self) -> str:
---> 88     names = (arg.name for arg in self.__args__ if hasattr(arg, "name"))
     89     return f"{self.__class__.__name__}({', '.join(names)})"

    [... skipping similar frames: <genexpr> at line 88 (97 times), Value.name at line 89 (97 times)]

File ~/code/ibis/ibis/expr/operations/core.py:89, in Value.name(self)
     86 @property
     87 def name(self) -> str:
     88     names = (arg.name for arg in self.__args__ if hasattr(arg, "name"))
---> 89     return f"{self.__class__.__name__}({', '.join(names)})"

File ~/code/ibis/ibis/expr/operations/core.py:88, in <genexpr>(.0)
     86 @property
     87 def name(self) -> str:
---> 88     names = (arg.name for arg in self.__args__ if hasattr(arg, "name"))
     89     return f"{self.__class__.__name__}({', '.join(names)})"

What version of ibis are you using?

main 09b6ada

What backend(s) are you using, if any?

NA

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@NickCrews NickCrews added the bug Incorrect behavior inside of ibis label Feb 23, 2024
@cpcloud
Copy link
Member

cpcloud commented Feb 25, 2024

Thanks!

If this is noticeably slow then it's probably recursing infinitely.

@cpcloud
Copy link
Member

cpcloud commented Feb 25, 2024

Ok, it's not infinite: reducing the number of iterations to 10 returns quickly.

kszucs pushed a commit that referenced this issue Feb 26, 2024
Fixes #8432. In short, the pattern we are using here for accessing
`name` results in exponential growth of attribute accesses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants