Re: [go-nuts] Non pointer constraint for generic func

2024-11-13 Thread Ben Hoyt
Ah yes, that does help, thanks. I've read that essay in the past, but it was a good re-read! On Thu, 14 Nov 2024 at 11:24, Ian Lance Taylor wrote: > On Wed, Nov 13, 2024 at 1:28 PM ben...@gmail.com > wrote: > > > > > Personally I mostly think that is OK. One of the guidelines that Go > > > foll

Re: [go-nuts] Non pointer constraint for generic func

2024-11-13 Thread Ian Lance Taylor
On Wed, Nov 13, 2024 at 1:28 PM ben...@gmail.com wrote: > > > Personally I mostly think that is OK. One of the guidelines that Go > > follows is to encourage people to write code rather than write types. > > To me this falls into writing types. > > > I'm intrigued by this concept, but I don't real

Re: [go-nuts] Non pointer constraint for generic func

2024-11-13 Thread Elad Gavra
Thanks. I was about to reply with why I think we need it and then realized that my case does not justify it. All I needed is a constraint that restricts to a set of known types which is available using the or op. On Wed, Nov 13, 2024, 19:23 Ian Lance Taylor wrote: > On Wed, Nov 13, 2024 at 8:59

Re: [go-nuts] Non pointer constraint for generic func

2024-11-13 Thread ben...@gmail.com
Personally I mostly think that is OK. One of the guidelines that Go follows is to encourage people to write code rather than write types. To me this falls into writing types. I'm intrigued by this concept, but I don't really know what it means. I've seen your (Ian's) similar comments at htt

Re: [go-nuts] Re: runtime/pprof - pausing CPU profiling

2024-11-13 Thread Rhys Hiltner
There are a few options for post-processing, all within the set of supported Go APIs. One is to use the `-focus` flag of `go tool pprof` so it only displays samples that match a particular call stack. If the code to be profiled is in a single function, that might be all you need. Another is to set

Re: [go-nuts] Non pointer constraint for generic func

2024-11-13 Thread Ian Lance Taylor
On Wed, Nov 13, 2024 at 8:59 AM Elad Gavra wrote: > > I would like to create a non-pointer constraint for a generic function. > For example: > ``` > func F[T NonPtr](p T) { > // do something with p > } > ``` > Such that > ``` > F(MyStruct{}) // allowed > F(&MyStruct{}) // disallowed, compile time

[go-nuts] Non pointer constraint for generic func

2024-11-13 Thread Elad Gavra
Hi, I would like to create a non-pointer constraint for a generic function. For example: ``` func F[T NonPtr](p T) { // do something with p } ``` Such that ``` F(MyStruct{}) // allowed F(&MyStruct{}) // disallowed, compile time ``` I'm aiming to ensure, in compile-time, that a generic function, whi

Re: [go-nuts] Re: runtime/pprof - pausing CPU profiling

2024-11-13 Thread Ian Lance Taylor
On Wed, Nov 13, 2024, 5:31 AM Jason E. Aten wrote: > All good. I still think that the hack of blocking and restoring the > runtime's SIGPROF signal > handler might actually work though. It might not work. But if it does, it > is almost > exactly what you were looking for. > > Ian or others more

[go-nuts] package to hash any comparable type

2024-11-13 Thread Gorka Guardiola
Hi, I wrote a package to hash any comparable type: https://pkg.go.dev/gitlab.eif.urjc.es/paurea/dohash In contrast to https://github.com/dolthub/maphash it can use any hash function (as long as it implements hash.Hash64) and it does not depend on any internal detail of the runtime. It works by i

Re: [go-nuts] Re: runtime/pprof - pausing CPU profiling

2024-11-13 Thread Jason E. Aten
(On gopherslack, the #darkarts folks are performance oriented) On Wed, Nov 13, 2024 at 1:30 PM Jason E. Aten wrote: > All good. I still think that the hack of blocking and restoring the > runtime's SIGPROF signal > handler might actually work though. It might not work. But if it does, it >

Re: [go-nuts] Re: runtime/pprof - pausing CPU profiling

2024-11-13 Thread Jason E. Aten
All good. I still think that the hack of blocking and restoring the runtime's SIGPROF signal handler might actually work though. It might not work. But if it does, it is almost exactly what you were looking for. Ian or others more knowledgeable myself might be able to advise better if it _should_

Re: [go-nuts] Re: runtime/pprof - pausing CPU profiling

2024-11-13 Thread Stephen Illingworth
On Wednesday 13 November 2024 at 12:02:12 UTC Jason E. Aten wrote: > I've tried but this unfortunately, the Start and Stop processes are too expensive and really require writing to a different file for every stop. The nature of the program means I need to do the Start/Stop process 60+ times per

Re: [go-nuts] Re: runtime/pprof - pausing CPU profiling

2024-11-13 Thread Jason E. Aten
> I've tried but this unfortunately, the Start and Stop processes are too expensive and really require writing to a different file for every stop. The nature of the program means I need to do the Start/Stop process 60+ times per second, so it would generate a lot of files and be very slow on top.

[go-nuts] Re: runtime/pprof - pausing CPU profiling

2024-11-13 Thread Stephen Illingworth
Thank's Jason. These are all good ideas: On Wednesday 13 November 2024 at 02:06:56 UTC Jason E. Aten wrote: Idea 0: Can you just click on the graphviz boxes in the pprof http page for your section and then just show the source for only those? Might give you a quick idea of which are the hottest

Re: [go-nuts] Re: runtime/pprof - pausing CPU profiling

2024-11-13 Thread Stephen Illingworth
On Wednesday 13 November 2024 at 06:05:36 UTC scott beeker wrote: 2. **Start Profiling**: Use `pprof.StartCPUProfile(file)` to start profiling, where `file` is an `os.File` object to write the profile data. 3. **Restrict Profiling**: Place `pprof.StartCPUProfile()` before the code section you w