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

encode时间太长 #4

Open
Heriec opened this issue May 28, 2024 · 0 comments
Open

encode时间太长 #4

Heriec opened this issue May 28, 2024 · 0 comments

Comments

@Heriec
Copy link

Heriec commented May 28, 2024

实测场景:
width:1080
height:1732
frames.length:174
maxColors:255

生成时间为:

encoding to gif: 101045.36010742188 ms

debug结果为:

[modern-gif] palette:generate: 7795.431884765625 ms
[modern-gif] encode: 30711.7099609375 ms

上述两个输出结果为flush内主要流程,encode部分为异步,时间忽略不计。
可以看到两者时间相加与总生成时间有明显差异

将代码拉到本地排查后发现,在worker执行完init后主线程收到data这个时间开始到worker收到主线程的flush消息整个过程时间过长,手动计时约60s
以为是主线程过早发送flush消息导致worker没有及时收到该消息,故本地修改为worker直接执行完流程而不发送多个消息给worker分步完成,结果为:

[modern-gif] palette:generate: 43211.626953125 ms
[modern-gif] encode: 27053.199951171875 ms

可以看到palette:generate部分时间增大了不少,主要不一致部分也在这,不过确实消除了原本的60s,但是encode结果与未修改前几乎不变(因为原本的encode的foreach部分改为了await,该部分时间变长)

所以猜测palette:generate部分导致之前所述的60s worker没收到消息(我是在worker收到消息后直接打印收到消息的结果,之前就是一直不打印怪)不过之前执行palette:generate过程只有8s,这里也有问题

modern-palette也是作者你开发的,是否能解决上述问题并优化encode时间


此外,是否能暴露出worker终止接口

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

No branches or pull requests

1 participant