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

Update queue with using deque & Update requirements #2428

Merged
merged 10 commits into from
Nov 4, 2022

Conversation

GLGDLY
Copy link
Contributor

@GLGDLY GLGDLY commented Oct 11, 2022

Description

The performance of queue instance might be improved with the use of double ended queue and .popleft(), rather than the list used currently.

Also, for the requirements part, websockets with version<=9.1 would raise TypeError: WebSocketCommonProtocol.__init__() got an unexpected keyword argument 'logger', so it would be better to ensure its version to be >=10.0.

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

websockets with version <=9.1 with raise TypeError: WebSocketCommonProtocol.__init__() got an unexpected keyword argument 'logger'
@GLGDLY GLGDLY changed the title Update queue with using deque Update queue with using deque & Update requirements Oct 11, 2022
@freddyaboulton
Copy link
Collaborator

Thanks @GLGDLY ! We'll test this this week to compare performance with the current queue implementation.

@GLGDLY
Copy link
Contributor Author

GLGDLY commented Oct 11, 2022

Thanks @GLGDLY ! We'll test this this week to compare performance with the current queue implementation.

For my own massive test considering append, pop, remove and iterate first few items, there is likely to be a 30-40% performance improve comparing deque and list operations. It would be great if you can do some more tests based on actual usage with it, thank you!

@GLGDLY
Copy link
Contributor Author

GLGDLY commented Oct 18, 2022

seems like there are some conflicts now, have you guys test about this deque part? If it is ok then I might resolve the conflicts later @freddyaboulton

@freddyaboulton
Copy link
Collaborator

Hi @GLGDLY ! Haven't had a chance to test yet. We also want to get #2218 merged which may cause some additional conflicts. I'd suggest we wait until that's merged!

@GLGDLY
Copy link
Contributor Author

GLGDLY commented Oct 18, 2022

Hi @GLGDLY ! Haven't had a chance to test yet. We also want to get #2218 merged which may cause some additional conflicts. I'd suggest we wait until that's merged!

oh I see, as I have some more stuffs want to discuss and maybe make some more prs, which is not quite related to this pr, so is wondering what's the condition here lol

@freddyaboulton
Copy link
Collaborator

What do you mean by condition @GLGDLY ?

@GLGDLY
Copy link
Contributor Author

GLGDLY commented Oct 18, 2022

What do you mean by condition @GLGDLY ?

state? status? I don't quite know if I have used a correct wording🤔

@freddyaboulton
Copy link
Collaborator

Ah got it! We should be able to review this later this week. Feel free to submit other issues/PRs that are unrelated though! It's just that I know the queue will go through some changes this week (#2218 #2452) so I didn't want you to waste your time addressing changes yet 😄

@GLGDLY
Copy link
Contributor Author

GLGDLY commented Oct 18, 2022

Ah got it! We should be able to review this later this week. Feel free to submit other issues/PRs that are unrelated though! It's just that I know the queue will go through some changes this week (#2218 #2452) so I didn't want you to waste your time addressing changes yet 😄

ok thanks, I may come and see later😊

@freddyaboulton
Copy link
Collaborator

Hi @GLGDLY ! If you rebase this pr, we can review it! Thank you

@GLGDLY GLGDLY reopened this Nov 3, 2022
@GLGDLY
Copy link
Contributor Author

GLGDLY commented Nov 3, 2022

Hi @GLGDLY ! If you rebase this pr, we can review it! Thank you

@freddyaboulton it is now rebased, thank you

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @GLGDLY !

I tested this branch against version 3.9 with our queue batch benchmark and there aren't any noticeable regressions in performance.

Gradio 3.9

Input type Average time to complete prediction over 1000 requests
Audio 1.1506862538333997
Image 0.9021098742118249
Text 0.8479320884290324
Video 2.458217331471334

This branch

Input type Average time to complete prediction over 1000 requests
Audio 1.1911795553514513
Image 0.9411118013017318
Text 0.9387184648371455
Video 2.373436844774655

I tested locally as well and the time are very comparable.

The demos are deployed here and they look good to me: https://huggingface.co/spaces/gradio-pr-deploys/pr-2606-all-demos

Any comments before we merge this in @abidlabs ?

return None
self.event_queue.append(event)
return len(self.event_queue) - 1
return queue_len
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we keep this as len(self.event_queue) - 1 please?

@abidlabs
Copy link
Member

abidlabs commented Nov 4, 2022

Thanks for benchmarking @freddyaboulton! I was hoping that there would be a more meaningful improvement, but I'm fine with accepting this PR since a deque does seem like the appropriate structure to use here.

@freddyaboulton
Copy link
Collaborator

Thank you @GLGDLY !

@freddyaboulton freddyaboulton merged commit b1cc5be into gradio-app:main Nov 4, 2022
@GLGDLY
Copy link
Contributor Author

GLGDLY commented Nov 4, 2022

Thank you @GLGDLY !

Ok thank you😄

GLGDLY added a commit to GLGDLY/gradio that referenced this pull request Nov 6, 2022
fix wrong position in changlog from the last pr gradio-app#2428 also
@GLGDLY GLGDLY mentioned this pull request Nov 6, 2022
7 tasks
freddyaboulton added a commit that referenced this pull request Nov 9, 2022
* Update queue.py

* Update queue.py

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update queue.py

* Update requirements.txt

websockets with version <=9.1 with raise TypeError: WebSocketCommonProtocol.__init__() got an unexpected keyword argument 'logger'

* fix issues after rebase

* feat Allow auth with using queue

* remove unused imports

* Update CHANGELOG.md

fix wrong position in changlog from the last pr #2428 also

* revert test_queue_enabled_for_fn that is changed due to unintended mistake

* remove comment

* update tests and merge main thread

Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
Co-authored-by: Ali Abid <aabid94@gmail.com>
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

Successfully merging this pull request may close these issues.

None yet

3 participants