https://www.boundaryml.com logo
hey i've started seeing this error when
# troubleshooting-will-be-archived-use-help-instead
b
hey i've started seeing this error when i start to scale out my app which is running many async baml calls
Copy code
18:15:11:ERROR:copilot.state.extract: Error updating milestones
Traceback (most recent call last):
baml_client/async_client.py", line 318, in ExtractReminderStatus
baml_client/runtime.py", line 98, in call_function_async
pyo3_async_runtimes.RustPanic: rust future panicked: unknown error
thread 'tokio-runtime-worker' panicked at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/async-io-2.4.1/src/reactor.rs:101:39:
cannot initialize I/O event notification: Os { code: 24, kind: Uncategorized, message: "Too many open files" }
thread 'tokio-runtime-worker' panicked at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/async-io-2.4.1/src/reactor.rs:101:39:
cannot initialize I/O event notification: Os { code: 24, kind: Uncategorized, message: "Too many open files" }
thread 'tokio-runtime-worker' panicked at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/async-io-2.4.1/src/reactor.rs:101:39:
cannot initialize I/O event notification: Os { code: 24, kind: Uncategorized, message: "Too many open files" }
thread 'tokio-runtime-worker' panicked at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/async-io-2.4.1/src/reactor.rs:101:39:
cannot initialize I/O event notification: Os { code: 24, kind: Uncategorized, message: "Too many open files" }
i'm on baml
0.201.0
v
hey! how many thigns are you running in parallel btw?
not sure if this would be helpful
b
yea i can change the ulimit but i fear that it's not going to sovle the root issue
we are running loads and loads of calls in parallel. Hundreds at least
v
on one machine?
it seems to be a tokio limit in rust sadly since rust opens up a file descriptor for every HTTP request it makes. which eventually taps out. the real way to solve this would be for us to run an event queue that limits how many parallel calls actually run in parallel at once regardless of how much you call in parallel in yoru code
b
but is there a chance they arent being closed?
v
i would have to check, but i don't think so
can i get back by saturday evening on this? (if uname is temporarily unblocking you)
can you give me an order of magnitude here so i can try and repro this locally?
b
hey sure thing, i will bump up uname and test heavily tomorrow
order of magnitude would be ~300 calls total being called across different async loops. About 8 active users
v
Ok. Perfect I will try and repro myself and see what happens. Iโ€™ve run a couple hundred in parallel before for some benchmarks via python but we may have had a regression as well. Could you provide some pseudo code and also what kind of machine youโ€™re running on?
a
i think we might just need to reuse the connection pool
b
this was on an ubuntu instance on GCP, specifically a
c4d-highcpu-4 (4 vCPUs, 7 GB Memory)
yea @aaronv (BAML) that would be my guess as well, to have more than 1000 open file descriptors at a time seems like some missing cleanup
in terms of code repro, something like this
Copy code
async def do_predictions(p: Coroutine[Any, Any, T]):
  res = await p
  ...
async def extract_all(elements: list):
  coros = [b.ExtractResume(e) for e in elements)]
   await do_predictions(coros)

async def main():
  while True:
    l1 = [...]
    l2 = [...]
    l3 = [...]
    ...
    l10 = [...]
    await asyncio.gather(*[extract_all(l) for l in [l1, l2, l3, l4, ..., l10]
    await asyncio.sleep(0.1)
something like this
a
testing a fix now
@benepstein which LLM provider do yo uuse?
ok I tried adding a timeout here but im not sure there's a lot i can do -- adding a connection pool can cause things to stall, which worse (due to an issue with the library we use) https://github.com/BoundaryML/baml/pull/2205/files Does the issue go away if you set ulimit to like 10k?
at ec2 we set our ulimit to the max, like 64k
b
I use Gemini on vertex. I can test tomorrow and bump the ulimit
Thanks for looking into it! It hasnโ€™t happened on modal or cloud run, so perhaps those envs have massive ulimits Iโ€™ll check
a
they probably do. 1k is just peanuts for these servers that need to be doing thousands of requests per sec