February 06, 2022
On Sunday, 6 February 2022 at 18:33:59 UTC, Temtaime wrote:
> Windows has its own API to mmap files. There's no need to reinvent the wheel, phobos MmFile works for me without any problems.
> Maybe there's no flush function, but for my use cases it's not so critical.

Yeah, I'm really glad that it works for you but I will have to create a library for my compiler so there is a need to properly learn how things work so I'll know what I'm doing when the times comes. So yeah...
February 06, 2022
On 2/6/22 10:14, rempas wrote:

> "mmap" is a system call that doesn't exist (natively) on Windows.

Yes. I misspoke: What I meant was std.mmfile handles the differences automatically between systems.

Ali

February 06, 2022
On Sunday, 6 February 2022 at 18:53:13 UTC, Ali Çehreli wrote:
> Yes. I misspoke: What I meant was std.mmfile handles the differences automatically between systems.
>
> Ali

Cool! That what I would expect from a library tbh so I'm glad it works like that!
February 06, 2022
On Sun, Feb 06, 2022 at 06:47:45PM +0000, rempas via Digitalmars-d wrote:
> On Sunday, 6 February 2022 at 18:33:59 UTC, Temtaime wrote:
> > Windows has its own API to mmap files. There's no need to reinvent the wheel, phobos MmFile works for me without any problems.  Maybe there's no flush function, but for my use cases it's not so critical.
> 
> Yeah, I'm really glad that it works for you but I will have to create a library for my compiler so there is a need to properly learn how things work so I'll know what I'm doing when the times comes. So yeah...

Just read the Phobos source code for std.mmfile. Phobos code is very readable compared to most typical standard libraries.


T

-- 
Turning your clock 15 minutes ahead won't cure lateness---you're just making time go faster!
February 06, 2022
On Sunday, 6 February 2022 at 20:12:39 UTC, H. S. Teoh wrote:
>
> Just read the Phobos source code for std.mmfile. Phobos code is very readable compared to most typical standard libraries.
>

Phobos/druntime is like an #ifdef hell but with version instead.
February 07, 2022
On Sunday, 6 February 2022 at 20:12:39 UTC, H. S. Teoh wrote:
> Just read the Phobos source code for std.mmfile. Phobos code is very readable compared to most typical standard libraries.
>
>
> T

I suppose this goes to what I said that I need to properly learn how things work right? Well I mean, how Windows does it with the system call. I don't think that it is necessary to read the Phobos source code. But regardless, thanks for the suggestion!
February 07, 2022
On Sunday, 6 February 2022 at 20:48:09 UTC, IGotD- wrote:
> Phobos/druntime is like an #ifdef hell but with version instead.

Actually, I personally tried to read some files (like stdio.d and conv.d) and while I didn't found them super user friendly, they are WAY more clear and easy to read then GLIB! I don't know if every libc's header files are like that in every OS and also I'm super super n00b when it comes to reading other people's source code so maybe H. S. Teoh is just better at us at reading code, idk...
February 07, 2022
On Mon, Feb 07, 2022 at 07:16:55AM +0000, rempas via Digitalmars-d wrote:
> On Sunday, 6 February 2022 at 20:48:09 UTC, IGotD- wrote:
> > Phobos/druntime is like an #ifdef hell but with version instead.
> 
> Actually, I personally tried to read some files (like stdio.d and conv.d) and while I didn't found them super user friendly, they are WAY more clear and easy to read then GLIB!

I tried reading GLIB source code once. I will never ever do it again. :-P


> I don't know if every libc's header files are like that in every OS
[...]

If it's in C? Yeah, they all look like that.


T

-- 
Shin: (n.) A device for finding furniture in the dark.
February 08, 2022

On Sunday, 6 February 2022 at 09:40:48 UTC, rempas wrote:

>

This should have probably been posted in the "Learn" section but I thought that it is an advanced topic so maybe people other than me may learn something too. So here we go!

I'm planning to make a change to my program to use "mmap" to the contents of a file rather than "fgetc". This is because I learned that "mmap" can do it faster. The thing is, are there any problems that can occur when using "mmap"? I need to know now because changing this means changing the design of the program and this is not something pleasant to do so I want to be sure that I won't have to change back in the future (where the project will be even bigger).

Will mmap be faster than fgetc? Almost certainly.

Will it be faster than other i/o systems? Possibly not.

for my i/o system iopipe, every array is also an iopipe, so switching between mmap and file i/o is trivial. See my talk in 2017 where I switched to mmap while on stage to show the difference.

IMO, the best way to determine which is better is to try it and measure. Having an i/o system that allows easy switching is helpful.

For sure, depending on your other tasks in your program, improving the file i/o might be insignificant.

-Steve

February 08, 2022

On Tuesday, 8 February 2022 at 03:33:11 UTC, Steven Schveighoffer wrote:

>

On Sunday, 6 February 2022 at 09:40:48 UTC, rempas wrote:

>

[...]

Will mmap be faster than fgetc? Almost certainly.

Will it be faster than other i/o systems? Possibly not.

for my i/o system iopipe, every array is also an iopipe, so switching between mmap and file i/o is trivial. See my talk in 2017 where I switched to mmap while on stage to show the difference.

IMO, the best way to determine which is better is to try it and measure. Having an i/o system that allows easy switching is helpful.

For sure, depending on your other tasks in your program, improving the file i/o might be insignificant.

-Steve

+1 iopipe !