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

The v3.4 to v4 migration codemod is unusably slow #3766

Open
umstek opened this issue Nov 19, 2024 · 7 comments
Open

The v3.4 to v4 migration codemod is unusably slow #3766

umstek opened this issue Nov 19, 2024 · 7 comments
Assignees
Labels
ai/codemod bug Something isn't working

Comments

@umstek
Copy link

umstek commented Nov 19, 2024

Description

I have a react project with webpack which is a bit old. However, ai worked without an issue. The only features I'm using are:

experimental_useObject
useCompletion

and there's likely nothing to migrate. But still it takes hours. I waited 4 hours when my machine crashed due to an unrelated issue.

Code example

import { experimental_useObject as useObject } from 'ai/react';
import { useCompletion } from 'ai/react';

AI provider

@ai-sdk/google v1.0.0 (in backend, so unrelated?)

Additional context

Linux 6.8.0-48-generic/Linux 6.8.0-48-generic

@umstek umstek added the bug Something isn't working label Nov 19, 2024
@lgrammel
Copy link
Collaborator

lgrammel commented Nov 19, 2024

If you only use those functions, there is likely nothing to migrate. Can you just try using 4.0 without running the migration?

One thing you may want to change manually is removing the await from streamText / streamObject

@umstek
Copy link
Author

umstek commented Nov 19, 2024

Migration worked for the backend. Everything seems fine so far.

@wong2
Copy link
Contributor

wong2 commented Nov 19, 2024

image

Yes, it's reallly slow

@shaper
Copy link
Contributor

shaper commented Nov 19, 2024

Hi there, thanks for the report and sorry to hear the performance isn't good for your code base. A few things that could help us look into this if you can share:

  • rough scale of codebase size (e.g. XXX KLOC)
  • what kind of machine you're running on (e.g. rough year of Mac laptop, Linux server w/ N cores, ...)
  • cpu load on machine (via top, w, Activity Monitor, etc.)

@umstek
Copy link
Author

umstek commented Nov 20, 2024

@shaper
less than 100KLOC
Ubuntu 24.04 on Core i7-8565U, 16GB RAM (Thinkpad)
I didn't notice any CPU usage due to the codemod running, typically was around 30-40%

@shaper
Copy link
Contributor

shaper commented Nov 20, 2024

@shaper less than 100KLOC Ubuntu 24.04 on Core i7-8565U, 16GB RAM (Thinkpad) I didn't notice any CPU usage due to the codemod running, typically was around 30-40%

Thank you. Do you know whether all of the code was already local, or if some was potentially loading over a network mount?

We have several potential performance improvements in mind and your feedback can help guide what order we approach them in.

@umstek
Copy link
Author

umstek commented Nov 21, 2024

Code was local.

It has ~500 stale branches and 3000 commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/codemod bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants