Skip to content

Commit

Permalink
Fix: use 'open files' soft limit to preallocate arena
Browse files Browse the repository at this point in the history
The hard limit can sometimes be be very high (e.g. 1 billion) and trying
to preallocate that much virtual memory is failing. Let's use the soft
limit for starters, then we can revisit the problem by allocating the
arena into blocks instead (no upper limit at the expense of a bounds
check).
  • Loading branch information
ysbaddaden committed Sep 30, 2024
1 parent 15093e1 commit 1bd58a2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/crystal/system/unix/evented/event_loop.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module Crystal::Evented
if LibC.getrlimit(LibC::RLIMIT_NOFILE, out rlimit) == -1
raise RuntimeError.from_errno("getrlimit(RLIMIT_NOFILE)")
end
rlimit.rlim_max.clamp(..Int32::MAX).to_i32!
rlimit.rlim_cur.clamp(..Int32::MAX).to_i32!
end
end

Expand Down

0 comments on commit 1bd58a2

Please sign in to comment.