Re: [go-nuts] mutex in slog/handler.go?

2024-05-24 Thread Harris, Andrew
The mutex field of the common handler struct became a pointer-to-mutex at some 
point IIRC - it is currently, so copying should be fine.

Get Outlook for iOS

From: golang-nuts@googlegroups.com  on behalf of 
Eli Lindsey 
Sent: Friday, May 24, 2024 7:18:51 AM
To: Jochen Voss 
Cc: golang-nuts 
Subject: Re: [go-nuts] mutex in slog/handler.go?

Git blame may be helpful, and specifically commit 847d40d6998. It looks like 
code drifted from the comment.

-eli

On May 24, 2024, at 9:25 AM, Jochen Voss  wrote:

Hello,

In the Go standard library, in the file log/slog/handler.go, I found the 
following code:

func (h *commonHandler) clone() *commonHandler {
// We can't use assignment because we can't copy the mutex.
return &commonHandler{
json:  h.json,
opts:  h.opts,
preformattedAttrs: slices.Clip(h.preformattedAttrs),
groupPrefix:   h.groupPrefix,
groups:slices.Clip(h.groups),
nOpenGroups:   h.nOpenGroups,
w: h.w,
mu:h.mu, // mutex shared among all clones of this handler
}
}

The first comment states that "we can't copy the mutex", but then the last line 
seems to copy the mutex anyway.  What is going on here?

Maybe this just an oversight from a time when every hander had its own mutex?  
Or is there something subtle going on here?

Many thanks,
Jochen


--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/153e9898-f17e-44cc-ab2a-8570f916c0c3n%40googlegroups.com.

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/D370602F-6226-4AAC-B3EC-6BA164FEA4F9%40siliconsprawl.com.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/SJ0PR07MB97958715C77D9CCFC2C2C1CFA0F52%40SJ0PR07MB9795.namprd07.prod.outlook.com.


Re: [go-nuts] Low memory utilization when using soft memory limit with GOGC=off

2023-12-05 Thread Harris, Andrew
Might be worth looking into GOMEMLIMIT.

From: golang-nuts@googlegroups.com  on behalf of 
Zhihui Jiang 
Sent: Monday, December 4, 2023 10:05:52 PM
To: golang-nuts 
Subject: [go-nuts] Low memory utilization when using soft memory limit with 
GOGC=off

Hi there,

We are running a large scale recommendation system using Golang and we are 
working on some GC related improvement recently. One of the changes we are 
trying to apply is to use soft memory limit with GOGC=off as suggested here: 
https://github.com/golang/go/issues/48409.

But during our testing, the memory usage never reaches the memory limit we set. 
For example, we have 100GB memory available and we set the memory limit to 
90GB, but the actual memory usage is very low like <50GB. We also observed the 
GC is actually very frequent which cost a lot of CPU time.

We had another tweak to set GOGC to a high value like 200, and the memory usage 
is quite close to the memory limit.

I have two questions here:

  1.  Is it expected behavior that the memory usage is much lower than memory 
limit when GOGC is set to off? From the official doc 
(https://github.com/golang/go/issues/48409), it claims " by setting GOGC=off, 
the Go runtime will always grow the heap to the full memory limit"?
  2.  How is the GC frequency decided when using soft memory limit + GOGC=off? 
Is there some internal defalut value for GOGC in this case to decide when to GC?

Thanks!

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/81d76570-9c09-4583-b900-fcfd19023f28n%40googlegroups.com.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/SJ0PR07MB9795F678F54415A639E77C32A085A%40SJ0PR07MB9795.namprd07.prod.outlook.com.


Re: [go-nuts] Context cancellation: Is it sufficient to make long-running things interruptible?

2022-12-19 Thread Harris, Andrew
The precise ordering of things is a bit non-deterministic at the fringe. If 
precise ordering really matters (maybe for cancelling a stream like this, it 
doesn’t, sometimes it does), a default case in the select statement is really 
useful, and it also matters what DoSomething does.

From: golang-nuts@googlegroups.com  on behalf of 
Torsten Bronger 
Sent: Monday, December 19, 2022 1:52:36 AM
To: golang-nuts@googlegroups.com 
Subject: [go-nuts] Context cancellation: Is it sufficient to make long-running 
things interruptible?

Hallöchen!

The context documentation gives this example:

// Stream generates values with DoSomething and sends them to out
// until DoSomething returns an error or ctx.Done is closed.
func Stream(ctx context.Context, out chan<- Value) error {
for {
v, err := DoSomething(ctx)
if err != nil {
return err
}
select {
case <-ctx.Done():
return ctx.Err()
case out <- v:
}
}
}

What if the channel “out” is drained very efficiently?  Then, an
arbitrary number of loop iterations could happen before a
cancellation is detected, couldn’t it?

I would additionally check for ctx.Err() != nil somewhere in the
loop.  Or is there a reason why this is not necessary?

Regards,
Torsten.

--
Torsten Bronger

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/87zgbj7maj.fsf%40physik.rwth-aachen.de.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CO2PR07MB2583C50EEB5E02993AE86792A0E59%40CO2PR07MB2583.namprd07.prod.outlook.com.


Re: [go-nuts] Method chaining in multiple lines

2022-11-24 Thread Harris, Andrew
Period should be at the end of lines

Call().
Chain().
Done()


Get Outlook for iOS

From: golang-nuts@googlegroups.com  on behalf of 
Denis P 
Sent: Thursday, November 24, 2022 11:45:54 AM
To: golang-nuts 
Subject: [go-nuts] Method chaining in multiple lines

Hi guys,

I am struggling with making my code work in a way that multiple methods called 
in multiline approach. Does any gopher has an answer is there any solution to 
this:
```
type MyStuff struct { }

func CreateMyStuff() MyStuff {}

func (s MyStuff) DoJobOne() MyStuff {}

func (s MyStuff) DoJobTwo() MyStuff {}

...

result := CreateMyStuff()
. DoJobOne() // Error: expected statement, found '.'
. DoJobTwo()

```

I have an error " expected statement, found '.' ".
Is there any workaround?

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/182bae0c-de3f-417e-82bb-07ca3d26e71an%40googlegroups.com.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CO2PR07MB25835FB3F0B4CBFA1D8611EDA00F9%40CO2PR07MB2583.namprd07.prod.outlook.com.


Re: [go-nuts] Re: How to High-pass filter method for well height data

2022-11-23 Thread Harris, Andrew
 You might not need FFT for this problem, although it's a powerful tool that 
would work

The minimal LP/HP filter is very little code, 
https://ccrma.stanford.edu/~jos/filters/Definition_Simplest_Low_Pass.html



From: golang-nuts@googlegroups.com  on behalf of 
pat2...@gmail.com 
Sent: Wednesday, November 23, 2022 3:21:14 PM
To: golang-nuts 
Subject: [go-nuts] Re: How to High-pass filter method for well height data

You want to find a discrete fast fourier transform package.
convolve with a suitable filter, and then inverse the DFFT



--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/281723e4-f401-4f4c-8c51-684c2f13914bn%40googlegroups.com.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CO2PR07MB25831BD5400A7DEBB594FDAAA00C9%40CO2PR07MB2583.namprd07.prod.outlook.com.


Re: [go-nuts] How to resolve error Cannot use 'struct{ width, height float64 }{2.0, 3.0}' (type struct {...}) as the type struct {...}

2022-08-30 Thread Harris, Andrew
I believe anonymous definitions of structs here is the cause. While equivalent, 
each anonymous definition is a distinct type.

Get Outlook for iOS

From: golang-nuts@googlegroups.com  on behalf of 
Richard Whatever 
Sent: Tuesday, August 30, 2022 7:46:47 AM
To: golang-nuts 
Subject: [go-nuts] How to resolve error Cannot use 'struct{ width, height 
float64 }{2.0, 3.0}' (type struct {...}) as the type struct {...}


I'm developing a mvc Golang server.

The model file is as follows:

type Object struct { ... TargetSize struct{ width, height float64 } 
`json:"targetSize"` ... }

The controller file is as follows:

func (c *GetObject) Get() []models.Object { return []models.Object{ {... 
struct{ width, height float64 }{2.0, 3.0}, ... },

I keep on getting the error of "Cannot use 'struct{ width, height float64 
}{2.0, 3.0}' (type struct {...}) as the type struct {...}" and I don't know how 
to resolve this.



--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a6b7d86c-8ed6-4be1-a265-3761f3b8be67n%40googlegroups.com.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CO2PR07MB25839F3A272A2904D18033C7A0799%40CO2PR07MB2583.namprd07.prod.outlook.com.