1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-10-17 14:01:01 +00:00

Use low-level IO#syswrite instead of IO#write in File adapter

Since

1. we are using binmode and do not expect any conversation of newlines
   or encodings to take place, and
2. we are only writing to the open file when we have squired the mutex
   of the adapter instance

we can safely use the syswrite method to write logs. In the end, this
uses the same low-level syscall as `IO#write` but with less overhead.
This commit is contained in:
Holger Just 2018-01-26 18:02:07 +01:00
parent 4a012e28cc
commit e805d69d84

View File

@ -129,7 +129,7 @@ module Rackstash
@mutex.synchronize do
auto_reopen
@file.write(line)
@file.syswrite(line)
end
nil
end
@ -180,8 +180,7 @@ module Rackstash
file = ::File.new(
filename,
::File::WRONLY | ::File::APPEND | ::File::CREAT,
external_encoding: Encoding::UTF_8
::File::WRONLY | ::File::APPEND | ::File::CREAT
)
file.binmode
file.sync = true