Open gerritsangel opened 2 years ago
Hi! Could I ask if you've run any tests to see what the performance hit is like?
I've run some quick tests (code further below) and it seems like:
bench
gives about a 90% increase in time takenWith different opt-levels:
It seems that the purpose of the function is to create the buffer from which we wish to read. Hence, regardless of how many times the function is called, the time spent zero-initializing would scale with the amount of data being read (whether that be streaming and calling this function multiple times, or as one big chunk, calling this function on one large piece of data). Depending on the particular use case of the user, I worry that such a performance hit might indeed be impactful. (Do correct me if I'm wrong, though.)
I've discussed within my org and we're thinking of a few possible ways to proceed:
unsafe
to avoid breaking interface)What do you / anyone else think?
This fixes the possible undefined behaviour in
Reader::from_reader()
(See #186 ).This causes a small runtime overhead due to the explicit initialization, but as far as I understood this method is only called by the user explicitly, so it may not matter so much.