This was previously implemented using FFI which has some inherent performance problems. The problem is that FFI allocates the used struct for stat() using malloc and frees with free which causes heavy churn because of this. This could be aleviated by using GC managed memory for this, but combined with how FFI currently works that would mean either having to mature allocate the data or adding new FFI features for allowing a call to be made without going GC independent. Mature allocation isn't something we'd want for stat() calls since stat objects are a perfect example of objects that often only live very short and should be cleaned up quickly. Introducing both GC managed memory for FFI calls using structs and allowing FFI calls to be made without going GC independent so the managed memory doesn't move is a big change, so taking this approach for now is easier. We should revisit this if we improve FFI to make doing this with FFI easier / possible. Another tricky part about stat() is how it binds regarding 64 bit filesystems. It uses macro's for that if you compile your app, so we had to have helpers for this already. And now for the performance numbers of this change. Before: === bin/rbx === File.stat 286796.1 (±2.7%) i/s - 1447040 in 5.049272s After: === bin/rbx === File.stat 722130.3 (±2.0%) i/s - 3633256 in 5.033514s
This allows us to know when we have tzname available as a fallback to finding the timezone name for platforms that don't have tm.tm_zone.
Signed-off-by: Brian Ford <firstname.lastname@example.org>