Re: Reimplementing software building blocks like malloc and free in D
On Sunday, 12 August 2018 at 11:37:54 UTC, Mike Parker wrote: On Sunday, 12 August 2018 at 11:23:55 UTC, Aruna Maurya wrote: So I'll be taking Eugene's code as reference to try and implement malloc free and realloc in dlang. Be sure to send your proposal in by August 15! Yes. Definitely!I'll do my best!
Re: Reimplementing software building blocks like malloc and free in D
On Sunday, 12 August 2018 at 08:34:46 UTC, Mike Franklin wrote: On Sunday, 12 August 2018 at 07:00:30 UTC, Eugene Wissner wrote: [...] Inline ASM is a feature of D, so "idiomatic D" includes assembly implementations. Where D shines here is with it's metaprogramming capabilities and the ability to select an implementation at compile-time or compose implementations. See https://github.com/JinShil/memcpyD/blob/master/memcpyd.d There you will that the compiler selects an implementation based on size in powers of 2. Sizes that aren't powers of 2 can be composed of the powers of 2 implementations. For example a 6 byte implementation would be comprised of a 4-byte implementation plus a the 2 byte implementation. [...] So I'll be taking Eugene's code as reference to try and implement malloc free and realloc in dlang.
Re: Reimplementing software building blocks like malloc and free in D
On Sunday, 12 August 2018 at 05:24:56 UTC, Mike Franklin wrote: On Sunday, 12 August 2018 at 04:16:24 UTC, Aruna Maurya wrote: [...] I'd say there is only 1 requirement: implementing `malloc`, `realloc`, and `free` in idiomatic D without any dependencies on other libraries from other languages. [...] Also what about other implementations like memset or memcmp. Have they been implemented or require work from scratch? But, how does it perform? In order to make the case for using these D implementations in druntime, we'll have to gather some metrics on the implementations in terms of performance, memory fragmentation, etc. and ensure they are on par with the C standard library implementations or alternative implementations like jemalloc and tcmalloc? [...] So the only option to implement the above is to go through Eugene's code, take some measurements and see if it can be improved. Perhaps the D implementations can be enhanced to provide compile-time or runtime tuning parameters to achieve better performance in different use cases. [...] That's totally okay. Your every comment is making the idea more clearer! [...]
Re: Reimplementing software building blocks like malloc and free in D
On Saturday, 11 August 2018 at 20:15:06 UTC, Mike Franklin wrote: On Saturday, 11 August 2018 at 18:59:00 UTC, Aruna Maurya wrote: [...] The compiler recognizes certain expressions and lowers them to functions in the D runtime that we call runtime hooks. See https://wiki.dlang.org/Runtime_Hooks for an unmaintained, but still relevant, list of some of them. [...] So there are essentially two requirements here. Building the memory management functionalities from scratch in idiomatic D and implementing the existing runtime hooks as templates. The latter isn't quite a part of the idea as mentioned on the page. Also I see in one of the above replies that malloc and free have been already implemented. So is that off the shelf or still available for implementation? [...] Thanks for the resource! Will go through it and get back in case of any doubts. [...]
Reimplementing software building blocks like malloc and free in D
Hello all! I am a Computer Science undergraduate student. Currently a junior, I find the idea of 're-implementing software building blocks like malloc and free in D' listed in the wiki page of SAOC(Symmetry Autumn of Code) quite interesting. I don't have experience of coding in D however, I have 4 years of coding in C++ and have a good hold on pointers and the standard template library. I have also successfully completed a course of Operating Systems and Data Structures in my 4th semester. I believe I can pick up D in due course of time. I had few queries regarding the same and would be glad if anyone could pitch in to help me out. 1. If it would have been C++, the above can be implemented by using the mmap() syscall to allocate memory from the heap. However, something that I am not able to understand in the idea description is 'runtime hooks'. 2. Also as far as I can understand, this idea is about implementing the above from scratch, and not tweaking the existing codebase. Do let me know if I am wrong. Thank you for your time!