[go-nuts] Re: good practice or premature optimization

2024-10-10 Thread tapi...@gmail.com
On Thursday, October 10, 2024 at 11:51:02 AM UTC+8 Nico Braun wrote: Hi, recently I became very self aware of potential performance implications my code might have. In go there are a few key concepts, like escape analysis and bound checks. If you check the standard library, you can see it was

Re: [go-nuts] Why isn't the memory model part of the spec?

2024-10-10 Thread Kurtis Rader
On Wed, Oct 9, 2024 at 11:30 PM will@gmail.com wrote: > It seems required to understand how Go programs work. > > If the memory model was never written, or is omitted from an > implementation, would the concurrency features still be reliable and useful? > > In addition to Ian's reply that peo

Re: [go-nuts] Alignment guarantees of heap allocations

2024-10-10 Thread Robert Engels
That’s what I was thinking. Thanks for providing the details. Rule of thumb - if you’re trying to do something and you’re the only one that’s trying it - you’re probably doing something wrong - or at least there is a much easier way. On Oct 10, 2024, at 6:31 PM, 'Keith Randall' via golang-nuts wro

Re: [go-nuts] Alignment guarantees of heap allocations

2024-10-10 Thread 'Keith Randall' via golang-nuts
type Variable struct { *atomic.Uint64 m *Memory } I agree that if you have a finalizer on a Variable that unmaps m, and you've given out a reference to the internal Uint64 to callers, then you can get in a situation where the Variable is dead, its finalizer is run, and the memory is unmapped wh

Re: [go-nuts] Are there alternatives to lower & upper bound or partition_point

2024-10-10 Thread robert engels
Check out https://pkg.go.dev/github.com/liyue201/gostl@v1.2.0/algorithm/sort but you could just as easily write those functions - they’re fairly trivial. Almost all of the C++ STL is implemented. > On Oct 10, 2024, at 3:50 PM,

Re: [go-nuts] Are there alternatives to lower & upper bound or partition_point

2024-10-10 Thread Ian Lance Taylor
On Thu, Oct 10, 2024 at 2:01 PM 'lijh8' via golang-nuts wrote: > > Are there alternatives to lower & upper bound or partition_point > > Suppose there duplicate entries in a slice. > I need to use a loop to find out the upper bound on a sorted slice. > > Are there something similar to c++ lower_bou

[go-nuts] Are there alternatives to lower & upper bound or partition_point

2024-10-10 Thread 'lijh8' via golang-nuts
Are there alternatives to lower & upper bound or partition_point  Suppose there duplicate entries in a slice. I need to use a loop to find out the upper bound on a sorted slice. Are there something similar to c++ lower_bound, upper_bound, partition_point? Thanks ``` package main import

Re: [go-nuts] Alignment guarantees of heap allocations

2024-10-10 Thread Robert Engels
I think you had a bug in your Memory implementation. That is the correct way to implement and it’s straightforward. Not sure why you ran into a problem. > On Oct 10, 2024, at 9:31 AM, 'Timo Beckers' via golang-nuts > wrote: > > On Thu, 10 Oct 2024 at 14:48, Jan Mercl <0xj...@gmail.com> wrote

Re: [go-nuts] Why isn't the memory model part of the spec?

2024-10-10 Thread Robert Engels
The memory model is very important when writing lock free concurrent structures - especially cross platform. It “worked” because the behavior was what most people would expect but I suspect there were lots of good around making it work and verifying when porting to different architectures. >

[go-nuts] Questions around http server closeIdleConns

2024-10-10 Thread Danny Shemesh
Hello everyone, I came across a behavior while debugging an http server graceful shutdown which made wonder: 1. As a mitigation to this issue: https://github.com/golang/go/issues/22682 We've added the following check to `closeIdleConns`: ``` + // Issue 22682: treat StateNew connections as if + //

Re: [go-nuts] Why isn't the memory model part of the spec?

2024-10-10 Thread Ian Lance Taylor
On Wed, Oct 9, 2024 at 11:30 PM will@gmail.com wrote: > > It seems required to understand how Go programs work. > > If the memory model was never written, or is omitted from an implementation, > would the concurrency features still be reliable and useful? People were able to write concurrent

Re: [go-nuts] Alignment guarantees of heap allocations

2024-10-10 Thread 'Timo Beckers' via golang-nuts
On Thu, 10 Oct 2024 at 14:48, Jan Mercl <0xj...@gmail.com> wrote: > > On Thu, Oct 10, 2024 at 2:23 PM 'Timo Beckers' via golang-nuts > wrote: > > > I've been searching around for some info or existing conversations around > > this topic, but that hasn't turned up anything useful so far. I had a

Re: [go-nuts] Alignment guarantees of heap allocations

2024-10-10 Thread 'Timo Beckers' via golang-nuts
On Thu, 10 Oct 2024 at 14:34, Robert Engels wrote: > > I’m not going to tell you how bad an idea it is… > > But I would like to ask ”why”? Why not just map the address using mmap - why > does it need to be in the heap memory space? Ha! I had a feeling someone would bite. :) The full explanation

Re: [go-nuts] Alignment guarantees of heap allocations

2024-10-10 Thread Jan Mercl
On Thu, Oct 10, 2024 at 2:23 PM 'Timo Beckers' via golang-nuts wrote: > I've been searching around for some info or existing conversations around > this topic, but that hasn't turned up anything useful so far. I had a > question around some implicit behaviour of Go's heap allocator. >From the

Re: [go-nuts] Why isn't the memory model part of the spec?

2024-10-10 Thread Marvin Renich
* Kurtis Rader [241010 03:05]: > On Wed, Oct 9, 2024 at 11:30 PM will@gmail.com > wrote: > > > It seems required to understand how Go programs work. > > > > If the memory model was never written, or is omitted from an > > implementation, would the concurrency features still be reliable and u

Re: [go-nuts] Alignment guarantees of heap allocations

2024-10-10 Thread Robert Engels
I’m not going to tell you how bad an idea it is… But I would like to ask ”why”? Why not just map the address using mmap - why does it need to be in the heap memory space?On Oct 10, 2024, at 7:23 AM, 'Timo Beckers' via golang-nuts wrote:Hello,I've been searching around for some info or existing co

[go-nuts] Alignment guarantees of heap allocations

2024-10-10 Thread 'Timo Beckers' via golang-nuts
Hello, I've been searching around for some info or existing conversations around this topic, but that hasn't turned up anything useful so far. I had a question around some implicit behaviour of Go's heap allocator. I'm working on implementing BPF map operations through direct shared memory acc

Re: [go-nuts] Is "When in doubt, use a pointer receiver" misleading advice?

2024-10-10 Thread Tobias Klausmann
Hi! On Wed, 09 Oct 2024, Ken Lee wrote: > On Tuesday 14 November 2023 at 7:23:44 am UTC+8 Oliver Lowe wrote: > > > > I'd be curious to hear thoughts on this topic. > > > > There was a fun talk at GopherConAU just a few days ago: "What's > > The Point? A Guide To Using Pointers Without Panicking"

Re: [go-nuts] Why isn't the memory model part of the spec?

2024-10-10 Thread Kurtis Rader
On Wed, Oct 9, 2024 at 11:30 PM will@gmail.com wrote: > It seems required to understand how Go programs work. > > If the memory model was never written, or is omitted from an > implementation, would the concurrency features still be reliable and useful? > The memory model is part of the Go s