erlang-lager / lager

A logging framework for Erlang/OTP
Apache License 2.0
1.13k stars 455 forks source link

replace io_lib:format #544

Closed SisMaker closed 3 years ago

SisMaker commented 3 years ago

Hi, I read the code of this project, and I found that the function used for term formatting is io_lib:format. The implementation of this function is not very efficient. It uses list to process intermediate processes and results. If use binary/iolist, the effect will be very good. so I encapsulated a format term function that uses the bianry/iolist version. This project may be beneficial, if you are interested, you can look at this: https://github.com/ErlGameWorld/eFmt There may be some modifications to it, but suggestions on how to make it more efficient are most welcome

paulo-ferraz-oliveira commented 3 years ago

To clarify: is this issue around suggesting lager adopts eFmt as a dep. to get rid of io_lib:format? Or for lager to find an alternative solution to io_lib:format (by e.g. importing your code)?

(I think that if there's a performance issue with io_lib it can/should be solved at the Erlang/OTP level)

SisMaker commented 3 years ago

To clarify: is this issue around suggesting lager adopts eFmt as a dep. to get rid of io_lib:format? Or for lager to find an alternative solution to io_lib:format (by e.g. importing your code)?

(I think that if there's a performance issue with io_lib it can/should be solved at the Erlang/OTP level)

Discusses an alternative to io_lib:format. Io_lib:format is not an efficient way to format terms, and it is even worse if it is a large term.I wanted the process of formatting term to be more efficient so I wrote eFmt. and other To see if anyone is interested in this, we can optimize eFmt together.