FAQ

On Mon, Oct 27, 2014 at 12:48 AM, wrote:
I must create a lot of objects.
My concern is to ease the work of the garbage collector, to avoid frequent
and long pauses.

What is your opinion about the following sentences ?

- Instead of creating 100'000 objects of type T separately, is it better to
create one big array of 100'000 elements [100000]T ?
Most likely yes. But note that in this case scanning of the array
won't be parallelized. It's also highly tied to the next point.
- Each of these objects contains 8 pointers *T to other objects. Is it
better to replace these pointers *T by indices (int) into the array of
objects ?
There is a radical difference between an object with pointer and an
objects w/o pointers at all. The latter is extremely efficient for GC.
So if these pointers are the only pointers in the object, then, yes,
it's worth doing if GC is a problem.

- The frequency of the GC is proportional to the garbage creation rate ? Yes.
- The GC duration is proportional to the total number of pointers used in
all live objects (mark phase), and the number of objects to free (sweep
phase) ?
Depending on what you mean by GC duration. Check out:
https://software.intel.com/en-us/blogs/2014/05/10/debugging-performance-issues-in-go-programs
(Garbage Collector Trace section).



- Each time a pointer is updated by the Go code, is it true that the garbage
collector must do some processing ?
This is currently not true. But will be true in future releases. Also
usually the additional work must be done only if GC is currently in
progress.
- What is the most important, finally:
- avoid creating garbage ?
- avoid creating too many objects ?
- avoid creating too many pointers ?
- avoid code that update pointers with high frequency ?

Creating less garbage for less frequent GCs.
Preferring larger objects w/o pointers for faster GC.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 11 of 13 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 26, '14 at 8:48p
activeOct 27, '14 at 1:27p
posts13
users6
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase