[
https://issues.apache.org/jira/browse/YUNIKORN-1713?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17730953#comment-17730953
]
Peter Bacsko commented on YUNIKORN-1713:
----------------------------------------
I'm abandoning this ticket because it's better using pointers instead of value
copying. Although the latter is preferred to avoid unnecessary heap
allocations, the new EventRecord will embed a Resource type which will be a
pointer, so a full value-copy semantics will not be possible.
There's also a comment on Github under
[https://github.com/golang/protobuf/issues/1225:]
_"We consistently represent proto messages as a pointer to a Go struct. A
*Person is a proto.Message, but a Person is not._
_It is not, in general, safe to copy a proto message by value. Messages often
contain a mutex, which cannot be copied. In the latest version of the code
generator, messages embed a pragma.DoNotCopy to discourage shallow copies."_
> Pass EventRecord as value instead of pointer
> --------------------------------------------
>
> Key: YUNIKORN-1713
> URL: https://issues.apache.org/jira/browse/YUNIKORN-1713
> Project: Apache YuniKorn
> Issue Type: Sub-task
> Components: core - scheduler
> Reporter: Peter Bacsko
> Assignee: Peter Bacsko
> Priority: Major
>
> Currently, we're passing around {{si.EventRecord}} objects as a pointer to a
> value. The idea is that by keeping just a single value in memory, we reduce
> copying. However, this causes heap allocations, which puts pressure on the
> GC, plus dereferencing also has costs.
> Also, modification to a structure is reflected in the original object. We
> rarely want this without adequate locking.
> Since this is a simple struct that is based on a protobuf definition, we
> should abandon heavy pointer usage and just pass it as value.
> See a relevant benchmark about passing struct as value vs pointer:
> https://medium.com/a-journey-with-go/go-should-i-use-a-pointer-instead-of-a-copy-of-my-struct-44b43b104963
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]