-
-
Notifications
You must be signed in to change notification settings - Fork 176
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 venv scripts #1074
base: master
Are you sure you want to change the base?
update venv scripts #1074
Conversation
@jakob-keller thoughts? this uses another aio-libs module which seems to do what we want |
build_and_sync_requirements.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should make local debugging less painful
for some reason I can't add you as a reviewer |
This comment was marked as resolved.
This comment was marked as resolved.
Good idea. I did not know about that library. Do we understand the performance implications? AFAIK, S3 Express is all about lower latencies. It would be a shame, if that cache added more overhead than necessary. A benchmark would be great. As a user, I would be slightly concerned about adding another dependency: Fewer is better, IMO. In particular, if there is another fairly straightforward solution available as #1073. |
Here's a simple benchmark.py: import asyncio
import functools
import async_lru
async def main(acache, n: int = 1000) -> None:
"""Async main coroutine."""
await asyncio.gather(*(acache("test") for _ in range(n)))
async def noop(_arg: str) -> None:
"""Trivial noop cooroutine."""
@functools.lru_cache(maxsize=100)
def _cache_1073(_arg: str) -> asyncio.Task[None]:
return asyncio.create_task(noop(_arg))
async def cache_1073(_arg: str) -> None:
"""functools.lru_cache wraps asyncio.Tasks - #1073."""
return await _cache_1073(_arg)
@async_lru.alru_cache(maxsize=100)
async def cache_1074(_arg: str) -> None:
"""async-lru based - #1074."""
return await noop(_arg) Run with
vs.
Under CPython 3.11.7 on macOS, #1073 turns out to be slightly faster than #1074: ~10%. That is not significant IMO and should not determine the decision. |
@jakob-keller I don't think #1073 is correct, it's avoiding a needed lock to ensure each lru entry is only awaited once |
IMO any extra effort should be put into speeding up/correcting https://github.com/aio-libs/async-lru. Looking at it I think there are many potential options. external deps aren't great indeed, but at least it's from the same ecosystem (aiolibs) |
If I get some time I'll look into that module, perhaps we can inline something simpler too |
I'm still convinced that both approaches are valid fixes for #1072: see #1073 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR and all its contents. I have added a few comments.
IMO, the "piping" related changes should be in another PR. Would you mind splitting the PR up?
Now I am. Thank you! 🎉 |
thanks for all the investigative work and instructiveness! |
@jakob-keller ok re-engineered based on discussions |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1074 +/- ##
=======================================
Coverage 86.13% 86.13%
=======================================
Files 60 60
Lines 5863 5863
=======================================
Hits 5050 5050
Misses 813 813
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
envsubst < requirements-dev.in > ${scratch_file} | ||
|
||
# also hash setup.py as it has the install_requires and extras | ||
SHA_SUM=$(sha1sum ${scratch_file} setup.py | head -c 40) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sha1sum produces two lines with two items each, which are piped to head which takes the first 40 bytes only. Looking at CI runs, this appears to be fragile and it completely ignores the hash of setup.py.
May I propose this alternative?
cat ${scratch_file} setup.py | sha1sum | awk '{print $1}'
- Concatenate both inputs
- Pipe into sha1sum
- Extract first word (the 40 character hash)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦🏼♂️ thanks, that is a very odd default behavior of sha1sum. I'll re-work
ensures compiled requirements file always match sources used to generate it