Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
July 27, 2020 An easy phobos i/o bug to fix | ||||
---|---|---|---|---|
| ||||
If anyone is using windows and std.stdio.File.rawWrite, it's insanely slow. And it's an easy fix. See https://issues.dlang.org/show_bug.cgi?id=7033 I don't use Windows, so I probably won't get around to fixing this. But ping me if you make a PR, I will review it. -Steve |
July 28, 2020 Re: An easy phobos i/o bug to fix | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Monday, 27 July 2020 at 15:19:44 UTC, Steven Schveighoffer wrote:
> If anyone is using windows and std.stdio.File.rawWrite, it's insanely slow. And it's an easy fix. See https://issues.dlang.org/show_bug.cgi?id=7033
>
> I don't use Windows, so I probably won't get around to fixing this. But ping me if you make a PR, I will review it.
>
> -Steve
So, upon opening a File, save the mode into a field, and only execute the current behavior iff the mode isn't binary?
|
July 28, 2020 Re: An easy phobos i/o bug to fix | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Monday, 27 July 2020 at 15:19:44 UTC, Steven Schveighoffer wrote: > I don't use Windows, so I probably won't get around to fixing this. But ping me if you make a PR, I will review it. > > -Steve > This should be an easy change and I'm kind of surprised this has been open for so long. This is the reason why. |
July 28, 2020 Re: An easy phobos i/o bug to fix | ||||
---|---|---|---|---|
| ||||
Posted in reply to starcanopy | On 7/28/20 7:24 PM, starcanopy wrote:
> On Monday, 27 July 2020 at 15:19:44 UTC, Steven Schveighoffer wrote:
>> If anyone is using windows and std.stdio.File.rawWrite, it's insanely slow. And it's an easy fix. See https://issues.dlang.org/show_bug.cgi?id=7033
>>
>> I don't use Windows, so I probably won't get around to fixing this. But ping me if you make a PR, I will review it.
>>
>
> So, upon opening a File, save the mode into a field, and only execute the current behavior iff the mode isn't binary?
Almost! I was thinking to store the current mode, and then only change the mode when needed, including the required flush.
This way, subsequent rawWrite calls are less expensive, even if it was open originally for text mode.
-Steve
|
July 28, 2020 Re: An easy phobos i/o bug to fix | ||||
---|---|---|---|---|
| ||||
Posted in reply to Avrina | On 7/28/20 7:44 PM, Avrina wrote: > On Monday, 27 July 2020 at 15:19:44 UTC, Steven Schveighoffer wrote: >> I don't use Windows, so I probably won't get around to fixing this. But ping me if you make a PR, I will review it. > > >> This should be an easy change and I'm kind of surprised this has been open for so long. > > This is the reason why. > Because I don't use Windows? I'm sure there are a lot who do. Perhaps they don't use rawWrite very much? I would say the likely reason is because people who care about performance don't use std.stdio ;) In any case, it's not a good excuse for such a horrendous performance bug to be there for so long. Ironically, rawWrite should be as fast as possible because you are not rewriting newlines, but instead it eliminates all buffering. -Steve |
July 29, 2020 Re: An easy phobos i/o bug to fix | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Wednesday, 29 July 2020 at 02:18:44 UTC, Steven Schveighoffer wrote:
> On 7/28/20 7:24 PM, starcanopy wrote:
>> On Monday, 27 July 2020 at 15:19:44 UTC, Steven Schveighoffer wrote:
>>> If anyone is using windows and std.stdio.File.rawWrite, it's insanely slow. And it's an easy fix. See https://issues.dlang.org/show_bug.cgi?id=7033
>>>
>>> I don't use Windows, so I probably won't get around to fixing this. But ping me if you make a PR, I will review it.
>>>
>>
>> So, upon opening a File, save the mode into a field, and only execute the current behavior iff the mode isn't binary?
>
> Almost! I was thinking to store the current mode, and then only change the mode when needed, including the required flush.
>
> This way, subsequent rawWrite calls are less expensive, even if it was open originally for text mode.
>
> -Steve
Looks like the contents of the Windows' version needs to be put into an if statement if I'm correctly following you.
version (Windows)
{
import std.algorithm: canFind;
/* currMode is a member of File
I'd imagine, unless the value being assigned to currMode is normalized, canFind or something similar would be preferable over exhaustive checking. */
if (!currMode.canFind("b"))
{
// current behavior
}
}
// write
|
July 29, 2020 Re: An easy phobos i/o bug to fix | ||||
---|---|---|---|---|
| ||||
Posted in reply to starcanopy | On Wednesday, 29 July 2020 at 03:08:43 UTC, starcanopy wrote:
> Looks like the contents of the Windows' version needs to be put into an if statement if I'm correctly following you.
>
> version (Windows)
> {
> import std.algorithm: canFind;
>
> /* currMode is a member of File
> I'd imagine, unless the value being assigned to currMode is normalized, canFind or something similar would be preferable over exhaustive checking. */
> if (!currMode.canFind("b"))
> {
> // current behavior
> }
> }
>
> // write
You could also just have a boolean member, e.g. binaryMode, present in only the Windows compilation that is true iff the mode in which the file was opened specified a binary mode.
|
Copyright © 1999-2021 by the D Language Foundation