Project Snowflake
От: Sharov Россия  
Дата: 27.07.17 17:44
Оценка: 29 (2)
Здравствуйте.

Отсюда:

Garbage collection greatly improves programmer productivity and ensures memory safety. Manual memory management on the other hand often delivers better performance but is typically unsafe and can lead to system crashes or security vulnerabilities. We propose integrating safe manual memory management with garbage collection in the .NET runtime to get the best of both worlds. In our design, programmers can choose between allocating objects in the garbage collected heap or the manual heap. All existing applications run unmodified, and without any performance degradation, using the garbage collected heap. Our programming model for manual memory management is flexible: although objects in the manual heap can have a single owning pointer, we allow deallocation at any program point and concurrent sharing of these objects amongst all the threads in the program. Experimental results from our .NET CoreCLR implementation on real-world applications show substantial performance gains especially in multithreaded scenarios: up to 3x savings in peak working sets and 2x improvements in runtime.


Там 40 страничный pdf, я пока не читал (и не факт что буду), но не осуждаю.
Кодом людям нужно помогать!
Re: Project Snowflake
От: Kolesiki  
Дата: 27.07.17 22:26
Оценка:
Здравствуйте, Sharov, Вы писали:

S>Manual memory management on the other hand often delivers better performance


С какого это перепугу? Выделяется память в обоих случаях одинаково, разница лишь во времени освобождения — вручную можно немного раньше освободить ненужное. В чём тут "better performance"?? (окромя захламления кода delete'ами)
Re[2]: Project Snowflake
От: glap  
Дата: 27.07.17 22:29
Оценка: 7 (1) +1
Здравствуйте, Kolesiki, Вы писали:

K>Здравствуйте, Sharov, Вы писали:


S>>Manual memory management on the other hand often delivers better performance


K>С какого это перепугу? Выделяется память в обоих случаях одинаково, разница лишь во времени освобождения — вручную можно немного раньше освободить ненужное. В чём тут "better performance"?? (окромя захламления кода delete'ами)


В играх актуально. Нельзя полагаться на GC, т.к. высвобождение памяти надо размазывать равномерно по кадрам, а не получать периодически подвисающие кадры.
Но что имеют ввиду авторы под 2x тоже не понял.
Re: Project Snowflake
От: Sinix  
Дата: 28.07.17 05:46
Оценка: 9 (2)
Здравствуйте, Sharov, Вы писали:

S>Там 40 страничный pdf, я пока не читал (и не факт что буду), но не осуждаю.


Идея неплохая, но уже неактуальная. Memory<T> / Span<T> в помощь
P.S. Также см вот это обсуждение как более изящный способ решать те же проблемы.
Отредактировано 28.07.2017 5:51 Sinix . Предыдущая версия .
Re[2]: Project Snowflake
От: Max Mustermann  
Дата: 28.07.17 09:53
Оценка: +1
Здравствуйте, Kolesiki, Вы писали:

S>>Manual memory management on the other hand often delivers better performance

K>С какого это перепугу? Выделяется память в обоих случаях одинаково, разница лишь во времени освобождения — вручную можно немного раньше освободить ненужное. В чём тут "better performance"?? (окромя захламления кода delete'ами)

Например в том, что в "Manual memory management" мы знаем, что именно нужно удалять и не надо искать кто тут живой, а кто — уже не очень.
Вообще проблема "stop-the-world" для GC — она не на пустом месте и не от тотальной криворукости появилась.
Re[2]: Project Snowflake
От: Sharov Россия  
Дата: 28.07.17 11:19
Оценка: +1
Здравствуйте, Sinix, Вы писали:

S>Здравствуйте, Sharov, Вы писали:


S>>Там 40 страничный pdf, я пока не читал (и не факт что буду), но не осуждаю.


S>Идея неплохая, но уже неактуальная. Memory<T> / Span<T> в помощь

S>P.S. Также см вот это обсуждение как более изящный способ решать те же проблемы.

И вправду ребята странные какие-то. Полистал я pdf, но так и не понял, чего они хотели достичь -- выделять в ручную память и шарить ее между потоками, при этом не имея проблем с gc?
Похоже, они и сами не очень понимают:

  много букв

6.4 Migrating away from the GC heap
How does a programmer know which objects should be allocated on the manual heap? Our methodology is
to use a heap pro ling tool (e.g. we have modi ed PerfView, a publicly available tool from Microsoft), to
determine if the GC has a signicant cost, then identify objects of reasonable size that have survived and
have been collected in the older generations, get the stack traces associated with such objects and look for
sensible candidates amongst those with clearly de ned lifetimes.


6.5 Programming model
By-ref style of owners and shields Owners and shields cannot be duplicated on the stack or returned
from arbitrary functions, and hence can only be passed \by-ref", complicating the porting of an application.
For some applications this is not a problem (e.g. System.Linq.Manual) but for others it may require redesign
of APIs and implementation.
Sharing references on the heap A well known limitation of owner-style objects (and unique references
in general) is that sharing of multiple references to the same manual object from the (GC or manual) heap is
not allowed, thus making them unsuitable for data structures with a lot of pointer sharing. Snow
ake allows
shareable pointers to be built around owners. For instance, we have introduced a class called Manual<T>
(as opposed to a struct), that encapsulates an Owner<T> and supports similar methods but can be stored on
the heap and passed to or returned by other functions like every other GC object. In exchange for greater
programming
exibility, object Manual<T> incurs extra space cost per manual object, so calls for a careful
pro le-driven use. Finally, we have also built shareable reference counted objects, RefCount<T>, but we are
considering API extensions in this space as important future work.
Shields on the heap Shields may accidentally escape on the (shared) heap, resulting in complaints in
our C# frontend, predominantly due to the subtle C# implicit boxing feature or closure capture. For other
examples, we may actually prefer to temporarily store a shield on the heap, as long as we can guarantee
that only the very same thread that created that shield will access it and the underlying object (otherwise
the reference to the TLS state is bogus). How to enable this without sacri cing performance is an open
challenging problem.

Finalization and owners When owner objects get abandoned our runtime abandons recursively their
children owner elds. To do this eciently we extend the method table with an explicit run-length encoding
of the o sets that the owner elds exist in an object and use that to eciently scan and abandon. An avenue
for future work is to modify the layout of objects to group together owner elds to improve this scanning,
similarly to what CoreCLR is using for GC pointers. .NET also allows for nalizers, which are functions that
can be called from a separate thread when objects are no longer live. There is design space to be explored
around nalizers for manual objects, e.g. should they be executed by the mutator or scheduled on the GC
nalization thread.
Asynchronous tasks In the async and await [2] popular C# programming model a thread may produce
a value and yield to the scheduler by enqueuing its continuation for later execution. This continuation may
be eventuall executed on a di erent thread. This decoupling of tasks from threads makes the use of the
thread-local shields challenging and it is an open problem of how to allow a task that resumes on a di erent
thread to safely use a shield.



Ну хоть умное слово EBR (Epoch-based reclamation) узнал. И то хорошо.
Кодом людям нужно помогать!
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.