Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-31 Thread Robert Engels
If you need a “guarantee” in these efforts it is much more complex. You must likely need a real-time OS and interrupt driven code. A general purpose language, os and hardware probably won’t cut it. This of it this way though, if you had 20 cpus to spread the work on, you only need to

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-30 Thread Robert Engels
Pretty much what Kurtis said. Low interval timers usually require specialized constructs if not a real time OS to efficiently (or even at all). > On Jan 30, 2022, at 9:16 PM, envee wrote: > > Thanks, but I am not sure how that reference solves the issue ? > Or are you suggesting that the

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-30 Thread Robert Engels
See https://github.com/golang/go/issues/27707 > On Jan 30, 2022, at 5:50 PM, envee wrote: > > Hi All, > I understand this issue has been discussed in the past, and I have seen a few > comments from Ian and Russ Cox about this topic, but I could not arrive at a > conclusion about how I can

Re: [go-nuts] Why Go allow function with unused arguments?

2022-01-30 Thread Robert Engels
To the ops point, wouldn’t it be better to cause an error for unused parameters unless they use the blank identifier? > On Jan 30, 2022, at 2:09 PM, 'Dan Kortschak' via golang-nuts > wrote: > > On Sun, 2022-01-30 at 12:01 -0800, Kamil Ziemian wrote: >> Hello, >> >> This is a question from

Re: [go-nuts] Re: Drawing millions of images on a bigger canvas

2022-01-24 Thread Robert Engels
Many image formats support tiling so you don’t need to have the entire image in memory (since a very large image is usually scaled or only a portion used at a time). > On Jan 24, 2022, at 10:07 AM, Howard C. Shaw III > wrote: > >  > One more options to add to Tamás' suggestions - due to

Re: [go-nuts] profiling help

2022-01-12 Thread robert engels
Are you certain that the requests aren’t super short - so all you are measuring is the runtime startup time / and the overhead of parsing the CGI “protocol". This is not insignificant. CGI really only works well for long requests IMO. > On Jan 12, 2022, at 5:29 PM, Steve Roth wrote: > > Thank

Re: [go-nuts] Generic member of recursive struct

2021-12-20 Thread Robert Engels
This is a task for a parser - and the parser can be type safe -but the constraints for something as complex as html aren’t typically expressed in types but rather bnf or similar. You can look at the Java html renderer/parser and it uses type safe nodes but it still has a resilient parser

Re: [go-nuts] Generic member of recursive struct

2021-12-20 Thread Robert Engels
You create structs like StringNode and HtmlNode that implement the common needed operations. Imagine a Render() method for a string you convert to html, for an html node you render recursively. Or similar. If an HtmlNode is not a leaf node it needs recursive operations. > On Dec 20, 2021,

Re: [go-nuts] Generic member of recursive struct

2021-12-20 Thread Robert Engels
You should use interfaces and a “node” type. > On Dec 20, 2021, at 12:07 PM, Michael Ellis wrote: > > >Just to be clear, the way I understood you is that you want HtmlTree.C to > be a slice which has elements which can each either be a string or an > *HtmlTree - i.e. you want these to be

Re: [go-nuts] Why, oh why, do people do this? Things that annoy me in Go code.

2021-12-09 Thread Robert Engels
5 is a best practice when you having multiple implementations written in different languages - especially when developed independently. > On Dec 9, 2021, at 6:10 AM, Amnon wrote: > > 1) Long functions that go on forever and contain long lambdas and 8 levels > of indentation. > > 2) Long

Re: [go-nuts] Go http/2 implementation is x5 less per performant than http/1.1

2021-11-19 Thread robert engels
ready use the replace directive for but this doesn't for the net/http > h2_bundle thing. see https://www.youtube.com/watch?v=FARQMJndUn0=814s > <https://www.youtube.com/watch?v=FARQMJndUn0=814s> > > > Le ven. 19 nov. 2021 à 18:33, Robert Engels <mailto:reng...@i

Re: [go-nuts] Go http/2 implementation is x5 less per performant than http/1.1

2021-11-19 Thread Robert Engels
t;>>> Java client: 720 MB/s >>>> curl: 800 M/s >>>> >>>> Using Go server using 256k client max frame size: >>>> >>>> Go client: 2350 MB/s >>>> Java client: 2800 MB/s >>>> h2load: 4300 MB/s >>&g

Re: [go-nuts] atomic.Value : inconsistent types

2021-11-16 Thread Robert Engels
I believe your code is broken. You need to use a lock when checking and making the switch (see double locking problem) or there would be no need to use atomics. If you run it under the race detector I am guessing it will fail. > On Nov 16, 2021, at 6:25 AM, Stephen Illingworth > wrote: >

Re: [go-nuts] Amateur question: when you should use runes?

2021-11-15 Thread Robert Engels
When your string contains Unicode characters dealing with it as individual bytes is difficult. When using runes with range - each index is a “Unicode character” (which may be multiple bytes) - which is easy to use. See go.dev/blog/strings > On Nov 15, 2021, at 12:00 PM, Kamil Ziemian

Re: [go-nuts] Go http/2 implementation is x5 less per performant than http/1.1

2021-11-15 Thread Robert Engels
gt; h2load: 4300 MB/s >> >> Using Java server using 256k client max frame size: >> >> Go client: 2900 MB/s >> Java client: 2800 MB/s >> h2load: 3750 MB/s >> >> For h2load, I needed to create a PR to allow the frame size to be set, see >>

Re: [go-nuts] Go http/2 implementation is x5 less per performant than http/1.1

2021-11-13 Thread robert engels
size to be set, see https://github.com/nghttp2/nghttp2/pull/1640 > On Nov 10, 2021, at 7:04 PM, robert engels wrote: > > No worries. I updated the issue and the CL. I will comment in the CL with a > few more details. > >> On Nov 10, 2021, at 2:30 PM, Andrey T.

Re: [go-nuts] darwin syscall performance?

2021-11-13 Thread robert engels
Sorry, I meant to send this on the http2 thread - and I also sent prematurely :( > On Nov 13, 2021, at 2:11 PM, robert engels wrote: > > As another data point, I decided to test a few implementations of http2 > downloads on OSX. > > Using a Go server with default frame s

Re: [go-nuts] darwin syscall performance?

2021-11-13 Thread robert engels
:) But there also seems to be an opportunity to improve the Go http2 client performance. > On Nov 10, 2021, at 8:33 PM, Ian Lance Taylor wrote: > > On Wed, Nov 10, 2021 at 5:29 PM robert engels <mailto:reng...@ix.netcom.com>> wrote: > Hi, > > While investiga

Re: [go-nuts] Is this a known problem?

2021-11-12 Thread Robert Engels
I think all of this will probably be handled with wrapper collections types and the iterator pattern. Generics should make this easy. It would be great is range supported this but it seems doubtful. > On Nov 12, 2021, at 10:37 AM, 'Axel Wagner' via golang-nuts > wrote: > >  > It is still

Re: [go-nuts] Go http/2 implementation is x5 less per performant than http/1.1

2021-11-10 Thread robert engels
e shot requests like: >> >> if useH2C { >>rt = { >> AllowHTTP: true, >> DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) >> { >> return dialer.Dial(network, addr) >> }, >> MaxFrameSize: 1024*2

Re: [go-nuts] Go http/2 implementation is x5 less per performant than http/1.1

2021-11-10 Thread robert engels
r.Dial(network, addr) > }, > MaxFrameSize: 1024*256, >} > } > > var body io.ReadCloser = http.NoBody > > req, err := http.NewRequestWithContext(ctx, "GET", url, body) > if err != nil { >return err > } > > resp, err := rt.RoundTri

Re: [go-nuts] Go http/2 implementation is x5 less per performant than http/1.1

2021-11-09 Thread robert engels
24*256, } } var body io.ReadCloser = http.NoBody req, err := http.NewRequestWithContext(ctx, "GET", url, body) if err != nil { return err } resp, err := rt.RoundTrip(req) > On Nov 9, 2021, at 3:31 PM, Robert Engels wrote: > > To be clear, I have no plans to submit a Cl to

Re: [go-nuts] Go http/2 implementation is x5 less per performant than http/1.1

2021-11-09 Thread Robert Engels
To be clear, I have no plans to submit a Cl to improve this at this time. It would require some api changes to implement properly. > On Nov 9, 2021, at 12:19 PM, Kirth Gersen wrote: > > Great ! > > > I made some local mods to the net library, increasing the frame size to > > 256k, and the

Re: [go-nuts] Go http/2 implementation is x5 less per performant than http/1.1

2021-11-09 Thread robert engels
I did a review of the codebase. Http2 is a multiplexed protocol with independent streams. The Go implementation uses a common reader thread/routine to read all of the connection content, and then demuxes the streams and passes the data via pipes to the stream readers. This multithreaded nature

Re: [go-nuts] Golang JPEG2000 implementation / Gauging community interest in supporting it?

2021-11-05 Thread Robert Engels
There are several open source Java encoder/decoder libraries. These can be translated pretty easily to Go. > On Nov 5, 2021, at 3:19 PM, 'Dan Kortschak' via golang-nuts > wrote: > > On Wed, 2021-11-03 at 18:50 -0700, Adam Koszek wrote: >> Hello, >> >> We (Segmed.ai) are processing a lot of

Re: [go-nuts] Sleep causes a tenfold difference in time interval

2021-11-04 Thread Robert Engels
Because when you sleep you deschedule the process/thread by the OS - and so the cached code and data needs to be reloaded so operations aren’t slower until then. > On Nov 4, 2021, at 11:19 AM, 尚义龙 wrote: > >  > I was doing pressure testing in my project and found a large gap in the time >

Re: [go-nuts] Does GC pause affect non-go threads spawned by CGo?

2021-10-25 Thread Robert Engels
No, unless they call back into Go. > On Oct 25, 2021, at 10:43 AM, Amir DER wrote: > > Does GC pause affect non-go threads spawned by CGo? > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop

Re: [go-nuts] testing if strconv.Quote() would do change a string, without calling it

2021-10-13 Thread Robert Engels
I was thinking the other way. If !IsPrint() then strconv.Quote() > On Oct 13, 2021, at 6:24 PM, Tim Hockin wrote: > >  > ` IsPrint(r) || r == '\\' || r == '"' ` passes tests. I need to build > confidence in that, though :) Thanks. > >> On Wed, Oct 13, 2021 at

Re: [go-nuts] testing if strconv.Quote() would do change a string, without calling it

2021-10-13 Thread Robert Engels
A simple loop calling IsPrint is your best bet. You could then have a custom implementation of Quote that started at a specified index. > On Oct 13, 2021, at 5:46 PM, 'Tim Hockin' via golang-nuts > wrote: > > Is there any ready-built function that can tell me whether `strconv.Quote()` >

Re: [go-nuts] Can generics help me make my library safer?

2021-10-06 Thread Robert Engels
I think you can only do that if you make sql parsing a first class language feature - or you need to construct the query using a syntax tree of clauses which is a PITA. Sometimes a hybrid approach - not a full orm - but an sql helper works best so sql.Query(table name, field list, where

Re: [go-nuts] Can generics help me make my library safer?

2021-10-06 Thread Robert Engels
Personally, I think this is overkill (the entire concept not the rog solution) Even with static checking there is no way to ensure that tablex has the needed fields. Even if you could check this at compile time - it might be different at runtime. I don’t think the juice is worth the squeeze.

Re: [go-nuts] how atomic instruction work?

2021-09-21 Thread robert engels
This may be of interest to you: https://github.com/golang/go/issues/5045 > On Sep 21, 2021, at 4:17 PM, Ian Lance Taylor wrote: > > On Tue, Sep 21, 2021 at 12:54 PM xie cui > wrote: >> >> >>

Re: [go-nuts] The right way for golang binary to reduce iTLB cache miss

2021-09-18 Thread robert engels
I can’t imagine the app has 34 mb of code in the hot path where this would matter - so I assume the application is partitioned with various Go routines doing a “type” of work. Which encounters a problem with the Go design. You can’t partition Go routines, and you can’t set cpu/core affinity

Re: [go-nuts] The right way for golang binary to reduce iTLB cache miss

2021-09-18 Thread robert engels
I will add that over aggressive inlining can cause this - it explodes the binary size. > On Sep 18, 2021, at 7:37 AM, Jesper Louis Andersen > wrote: > > On Fri, Sep 17, 2021 at 11:09 AM rmfr > wrote: > One of our Golang applications has a very huge binary

Re: [go-nuts] Re: The right way for golang binary to reduce iTLB cache miss

2021-09-17 Thread Robert Engels
This is the icache or code - not the data the code is accessing. > On Sep 17, 2021, at 8:12 AM, peterGo wrote: > >  > rmfr, > > What is your data, what is its structure, and what are the access paths and > frequencies? > > Your data is unlikely to be a randomly accessed blob of bits. Is

Re: [go-nuts] Creating a MQTT library

2021-09-16 Thread Robert Engels
The advantage of Go is to be able to use millions of blocking Go routines. Synchronous programming is much easier than async - especially for streaming protocols. > On Sep 16, 2021, at 4:17 PM, yba...@gmail.com wrote: > > Hello everyone, > > I am trying to design a new library to

Re: [go-nuts] Re: Debugging "fatal: morestack on gsignal"

2021-09-13 Thread Robert Engels
If the C code overruns a stack allocated variable couldn’t it easily corrupt the saved registers ? > On Sep 9, 2021, at 2:14 PM, Ian Lance Taylor wrote: > > On Thu, Sep 9, 2021 at 10:29 AM Varun V wrote: >> >> @Brian, We did not try that as the issue is happening with go 1.13.7 as well > >

Re: [go-nuts] Profiling goroutines

2021-09-03 Thread Robert Engels
Check out github.com/robaho/go-analyzer. It has some nice enhancements for dealing with highly concurrent programs. > On Sep 3, 2021, at 3:20 PM, Peter Bočan wrote: > > Hey guys, > > I am trying to get a full picture using a pprof of a highly paralelised > binary (read many goroutines

Re: [go-nuts] Re: Logging libraries and standard library compatibility

2021-08-31 Thread Robert Engels
aha wrote: > > On Tue, Aug 31, 2021 at 9:46 PM Robert Engels wrote: >> >> The io.Writer is too low level to be useful. Imagine a logger that wants to >> send an sms on severe errors only. >> >> The best solution is to declare your own logger interface - but si

Re: [go-nuts] Re: Logging libraries and standard library compatibility

2021-08-31 Thread Robert Engels
The io.Writer is too low level to be useful. Imagine a logger that wants to send an sms on severe errors only. The best solution is to declare your own logger interface - but similar to the collections discussion it would better if the stdlib declared an ILogger interface (or similar) > On

Re: [go-nuts] Source links on cs.opensource.google are slow (links for stdlib on pkg.go.dev)

2021-08-25 Thread Robert Engels
Every site you access probably uses Google analytics or something similar. It is often used to understand usage patterns, site design, etc. > On Aug 25, 2021, at 10:00 PM, Ben Hoyt wrote: > >  > > I'm in Santa Clara, CA. Just a handful of miles away from Google > > headquarters. > > Your

Re: [go-nuts] unsafe string to []byte

2021-08-03 Thread Robert Engels
That’s cool. I don’t think most libraries using unsafe go to that level of detail or scrutiny - which can be the source of a lot of subtle failures. > On Aug 3, 2021, at 3:35 PM, 'Bryan C. Mills' via golang-nuts > wrote: > > For what it's worth, my unsafeslice.OfString makes a best effort

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-29 Thread Robert Engels
I don’t like the “solves the problem of your test running fine in isolation but fails when run in concert with other tests”. If you have that problem you have poorly written tests. > On Jul 29, 2021, at 2:05 PM, Andrew Werner wrote: > >  > Another choice to throw into the mix is >

Re: [go-nuts] unsafe string to []byte

2021-07-27 Thread Robert Engels
Agreed. If a Go library uses unsafe I avoid it. > On Jul 27, 2021, at 9:54 AM, 'Axel Wagner' via golang-nuts > wrote: > >  >> On Tue, Jul 27, 2021 at 4:15 PM Steve Roth wrote: > >> The implementation of io.WriteString appears to allocate a new byte slice >> and copy the string into it: >>

Re: [go-nuts] Re: Out of memory using golang.org/x/tools/go/packages

2021-07-21 Thread Robert Engels
Maybe the object itself has circular references - so it fails at the first level. > On Jul 21, 2021, at 11:25 AM, Brian Candler wrote: > > I had a brief look at the code and it doesn't appear to do that. As far as > I can see, it indents as it goes: where you start is the "top" level, and

Re: [go-nuts] Re: Out of memory using golang.org/x/tools/go/packages

2021-07-21 Thread Robert Engels
If it is pretty printing it may need to determine the lowest level for indentation - so a depth first search - causing the entire tree to be traversed and retained before it can output anything. > On Jul 21, 2021, at 9:40 AM, Brian Candler wrote: > > But AFAICT, it should generate output as

Re: [go-nuts] Re: Out of memory using golang.org/x/tools/go/packages

2021-07-21 Thread Robert Engels
Since litter checks for circular references it needs to keep a ref to every object it sees. With a large tree you will run out of memory. > On Jul 21, 2021, at 7:19 AM, jake...@gmail.com wrote: > >  > The first thing I would do is remove the call to litter, and see if that > solved the

Re: [go-nuts] Re: heap space not released by the end of program ?

2021-07-13 Thread Robert Engels
I knew I had seen something on that. :) I guess Go doesn’t need a compacting collector if it can allocate most objects on the stack to avoid fragmentation. > On Jul 13, 2021, at 4:34 AM, Brian Candler wrote: > >  >> On Tuesday, 13 July 2021 at 03:52:24 UTC+1 bai...@gmail.com wrote: >> Hi, I

Re: [go-nuts] heap space not released by the end of program ?

2021-07-12 Thread Robert Engels
RSS is the amount of memory mapped to physical memory. It doesn’t include memory swapped. Still, if GC was releasing pages back to the OS - unmapping the allocated and touched pages - the RSS should decrease. There was a previous thread on if and when GC will release pages back to the OS.

Re: [go-nuts] Re: Stack growing is inefficient

2021-07-01 Thread Robert Engels
If you are doing “anything” which such large objects - doesn’t that dwarf the time to increase the stack? > On Jul 1, 2021, at 9:28 AM, tapi...@gmail.com wrote: > >  > I tried to find a way to initialize the size of the stack of a new created > goroutine in advance to avoid several stack

Re: [go-nuts] Re: How to implement this in golang?

2021-06-29 Thread Robert Engels
With Go you use a Go routine per connection and then you can read in chunks and delay in an imperative style. No need for generators or async. > On Jun 29, 2021, at 10:25 AM, LetGo wrote: > > Thanks for the answer! (: > In python it was straightforward to implement and it works like a charm.

Re: [go-nuts] Go and GPUs

2021-06-25 Thread Robert Engels
Agreed. (Didn’t see your previous message before I sent that). > On Jun 25, 2021, at 9:25 PM, David Riley wrote: > > On Jun 25, 2021, at 10:23 PM, Robert Engels wrote: >> >> There is also a LOT of support for Java and CUDA/OpenCL. You can essentially >> reimplem

Re: [go-nuts] Go and GPUs

2021-06-25 Thread Robert Engels
There is also a LOT of support for Java and CUDA/OpenCL. You can essentially reimplement them Java portion in Go. There are multiple open source projects in this area. Might be a lot easier than starting from scratch. > On Jun 25, 2021, at 8:03 PM, Michael Poole wrote: > > On Fri, Jun 25,

Re: [go-nuts] Go and GPUs

2021-06-25 Thread Robert Engels
Why not develop a Go <> CUDA binding using CGo? > On Jun 25, 2021, at 12:11 PM, Marcin Romaszewicz wrote: > >  > Graphics chips have a lot of proprietary IP, some of which the manufacturers > would like to keep secret. If you see source for one of these drivers, you > will have a good idea

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-22 Thread Robert Engels
With a 500k machine cluster I suggest getting professional Go support - someone experienced in troubleshooting that can sit with you and review the code and configuration to diagnose the issue. Personally it sounds like overallicated machines causing thrashing delays in the context switching.

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-22 Thread Robert Engels
He is stating he has a cloud cluster consisting of 500k machines - each machine runs an agent process - each agent has 7000 Go routines. > On Jun 22, 2021, at 7:07 AM, jake...@gmail.com wrote: > >  > Sorry, now I am completely confused. > >>> So, you have about 500,000 processes running

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-21 Thread Robert Engels
How many processes per machine? It seems like scheduling latency to me. > On Jun 21, 2021, at 6:31 AM, Peter Z wrote: > >  >> So, you have about 500,000 processes running this agent on each machine, and >> each process has around 7,000 gorouines? Is that correct? > > Yes, that's exactly

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-17 Thread Robert Engels
You’re right. Inspecting the code it is internally partitioned by P. I agree that it looks like the pool is being continually created. > On Jun 17, 2021, at 12:18 PM, Ian Lance Taylor wrote: > > On Thu, Jun 17, 2021 at 9:19 AM Peter Z wrote: >> The original post is on stackoverflow >>

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-17 Thread Robert Engels
You probably need multiple pools in and partition them. 500k accessors of a shared lock is going to have contention. github.com/robaho/go-concurrency-test might be helpful. > On Jun 17, 2021, at 11:19 AM, Peter Z wrote: > >  > The original post is on stackoverflow >

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-08 Thread Robert Engels
this doesn’t hold - but if you can write the entire stdlib with this pattern it seems fairly stable. > On Jun 8, 2021, at 5:03 PM, 'Dan Kortschak' via golang-nuts > wrote: > > On Tue, 2021-06-08 at 07:57 -0500, robert engels wrote: >> The following code is works fine from the deve

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-08 Thread robert engels
OK, I will try one more time. The following code is works fine from the developers perspective: https://play.golang.org/p/gC1XsSLvovM The developer says, oh cool, I see this great new 3P library that does background logging - I want to use that instead.

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-07 Thread Robert Engels
Sorry - correct link. I missed the subtle change. > On Jun 7, 2021, at 8:18 PM, Robert Engels wrote: > >  > (I think you pasted the wrong link - that is my code). > > It is not about being unwilling to admit it. Your explanation/reasoning has > not convinced me. >

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-07 Thread Robert Engels
be encouraged - if not it’s a religion not a programming language. > On Jun 7, 2021, at 7:40 PM, Axel Wagner wrote: > >  > > >> On Tue, Jun 8, 2021 at 2:05 AM Robert Engels wrote: >> >> We agree. It needs a pointer receiver to work. The atomic is also needed in &g

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-07 Thread Robert Engels
? > On Jun 7, 2021, at 6:34 PM, Axel Wagner wrote: > >  >> On Tue, Jun 8, 2021 at 1:26 AM Robert Engels wrote: > >> The pattern of a background stats collector is a common one. The atomic is >> required not optional. > > It might be a common pat

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-07 Thread Robert Engels
t 1:05 AM Axel Wagner >> wrote: >>> On Mon, Jun 7, 2021 at 11:42 PM Robert Engels wrote: >> >>> I don’t think that represents the problem fairly. In the non interface case >>> I know I can’t accept a copy so I would declare the method as taking a >

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-07 Thread Robert Engels
it was just my opinion based on my experiences. > On Jun 7, 2021, at 6:05 PM, Axel Wagner wrote: > >  >> On Mon, Jun 7, 2021 at 11:42 PM Robert Engels wrote: > >> I don’t think that represents the problem fairly. In the non interface case >> I know I can’t ac

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-07 Thread Robert Engels
n Mon, Jun 7, 2021 at 7:42 PM Robert Engels wrote: > >> I think that is my point. The methods in the code I shared have a proper >> receiver type based on the requirements of the methods. > > No, they don't. The `Log` method requires a pointer receiver, as it accesses > sta

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-07 Thread Robert Engels
elements after append… All of which I'm fine with as well. > > But FTR, this discussion is definitely off-topic in this thread. And it's > also moot in general: It's not something we can realistically change now. > >> On Mon, Jun 7, 2021 at 3:05 PM Robert Engels wrote: >>  >>

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-07 Thread Robert Engels
There is no good reason that proper behavior should be dependent on understanding best practices. It should help with readability not correctness. Seems to me the compiler or Go Vet should prohibit this - in my review of the stdlib and other projects I can’t see any reason why it doesn’t. >

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread robert engels
For example, the fact that this code is broken is not intuitively obvious for any reader. It requires way too much scrutiny IMO. https://play.golang.org/p/-f73t_Pm7ur > On Jun 6, 2021, at 6:37 AM, Robert Engels wrote: > > For me this is the most inconsistent and obtuse aspect

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread Robert Engels
For me this is the most inconsistent and obtuse aspect of the Go language. It seems it would always be saner to treat interfaces as pointers. Which would mean if they had non pointer receiver methods might force more objects to be allocated on the heap - but it would prevent a lot of

Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-04 Thread Robert Engels
ri, Jun 4, 2021 at 5:23 AM Robert Engels wrote: >> >> I was referring to the “special cases” in this section >> https://golang.org/cmd/cgo/ - wouldn’t all of these uintptr be stable? > > The cgo tool gets special treatment: each cgo call is permitted to pin > a know

Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-04 Thread Robert Engels
I was referring to the “special cases” in this section https://golang.org/cmd/cgo/ - wouldn’t all of these uintptr be stable? > On Jun 4, 2021, at 12:25 AM, Ian Lance Taylor wrote: > > On Thu, Jun 3, 2021 at 9:13 PM Robert Engels wrote: >> >> Doesn’t that depend on wh

Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-03 Thread Robert Engels
Doesn’t that depend on what the uintptr refers to? Eg if it was allocated off heap to begin with then it should be stable and computing a hash on it is valid. > On Jun 3, 2021, at 9:42 AM, 'Axel Wagner' via golang-nuts > wrote: > >  >> On Thu, Jun 3, 2021 at 4:19 PM christoph...@gmail.com

Re: [go-nuts] Re: The last line makes the variable y escape. But should it?

2021-06-01 Thread Robert Engels
Whenever you take the address of something the compiler is going to have a hard time with escape analysis due to aliasing. Especially with a complex function like println with varadic args. > On Jun 1, 2021, at 11:55 AM, 'Axel Wagner' via golang-nuts > wrote: > >  > "escape" as in "the

Re: [go-nuts] I think I found a bug?

2021-05-26 Thread Robert Engels
A slice is not an array. Words to live by. > On May 26, 2021, at 7:37 PM, Kurtis Rader wrote: > >  > It's more likely you've misunderstood how slices work. From > https://golang.org/ref/spec#Slice_types: > > > A slice is a descriptor for a contiguous segment of an underlying array and > >

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-15 Thread Robert Engels
Robert :) > On May 15, 2021, at 3:48 AM, Øyvind Teig wrote: > > Thanks, rog. I appreciate this! Even if I cant' stop thinking that a "pri" > would have been sligtly more elegant. But you shall be praised for the try! I > wont' take the time to fine read the code, though... > > ..Aside:

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-12 Thread robert engels
Here is a simple priority select implementation using unbuffered channels. https://play.golang.org/p/Hvl0iMr-cFW Uncomment the lines as instructed and you will see that channel A is always picked. What this demonstrates is that ‘priority’ and ‘event

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-06 Thread Robert Engels
To simply this :your request is easily accommodated if all channel state changes and all selects are synchronized. This is easily doable but would crush performance. > On May 6, 2021, at 6:11 PM, Robert Engels wrote: > >  > > >>> On May 6, 2021, at 5:12 PM, 'Axel

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-06 Thread Robert Engels
> On May 6, 2021, at 5:12 PM, 'Axel Wagner' via golang-nuts > wrote: > >  >> On Thu, May 6, 2021 at 11:38 PM Robert Engels wrote: > >> Yes, but barring the nanosecs of a window this is simply implemented as Ian >> wrote with >> >

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-06 Thread Robert Engels
t`, which uses > source order to express priority and under the semantics I'm asking about, > this would always block, because `lo` would never be read. > >> On Thu, May 6, 2021 at 10:05 PM Axel Wagner >> wrote: >> >> >>> On Thu, May 6, 2021 at 9:4

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-06 Thread Robert Engels
not “unblocking a sender” is a dubious endeavor. > On May 6, 2021, at 1:30 PM, 'Axel Wagner' via golang-nuts > wrote: > >  >> On Thu, May 6, 2021 at 8:22 PM Robert Engels wrote: > >> “If lo” means that if the lo channel was read. > > Exactly. To fulfill the requir

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-06 Thread Robert Engels
e.g. the sender was already unblocked. A `select` would not unblock the other > side unless that's the actual branch taken. > >> On Thu, May 6, 2021 at 7:32 PM Robert Engels wrote: >> I already showed you - just change it to >> >> Select hi >> Defaul

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-06 Thread Robert Engels
I already showed you - just change it to Select hi Default: Select hi,lo If lo: Select hi Default : Pass And enqueue the lo if a hi and lo are read. That is all that is needed. > On May 6, 2021, at 10:28 AM, 'Axel Wagner' via golang-nuts > wrote: > >  > > >> On

Re: [go-nuts] Go: pointer bit stealing technique

2021-05-06 Thread Robert Engels
The Java implementation does not use bit stealing - it uses an atomic pointer to an immutable struct - the same can be done in Go. > On May 6, 2021, at 6:16 AM, Vitaly Isaev wrote: > >  > In a well-known book "The Art of Multiprocessor Programming" by Herlihy, > Shavit some of lock-free and

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-05 Thread Robert Engels
To Ian’s point, you can try to synchronize using an external shared or multiple synced clocks - but the error is too great when comparing cpu frequency events. > On May 5, 2021, at 4:34 PM, Bakul Shah wrote: > > On May 5, 2021, at 9:55 AM, Øyvind Teig wrote: >> >> Here is my cognitive test

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-05 Thread Robert Engels
You are over complicating things. Start with simple code based on Ian’s. Still, I think you might be misunderstanding the tug between priority and starvation. It depends on the frequency and latency of events processing. There is no structure/language that can address this. You either drop or

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-03 Thread Robert Engels
Yes, C for instance. It doesn’t print ‘client 2’ because your code is broken. It prints “late arrival” if you remove the sleep. The main program finishes before the go routine runs. > On May 3, 2021, at 2:24 PM, Øyvind Teig wrote: > >> mandag 3. mai 2021 kl. 21:11:48 UTC+2 skrev

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-03 Thread Robert Engels
In most “select” implementations a set of “ready” endpoints is returned. So it is trivial for the reader to prioritize some endpoints over others. Because of the way Go select works it is more difficult - requiring nested selects - and it is more easily implemented using multiple readers and

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread Robert Engels
I already gave you the solution to this. Trust me it works. I did HFT for 7+ years - the algo is well known. > On Apr 29, 2021, at 2:05 PM, Øyvind Teig wrote: > >  >> torsdag 29. april 2021 kl. 20:22:32 UTC+2 skrev rog: > >> I agree with Axel's take here. It seems, Øyvind, that you are

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread robert engels
To clarify, you might never process a low item if a high is always available - but I believe that is what the OP is requesting. It is also fairly trivial to add fairness to this ti always process a low if available every N cycles. > On Apr 29, 2021, at 9:31 AM, robert engels wr

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread robert engels
items. There are no free lunches. But no deadlock. > On Apr 29, 2021, at 9:26 AM, Ian Davis wrote: > > On Thu, 29 Apr 2021, at 3:09 PM, robert engels wrote: >> I will give you the pseudo code: >> >> { // step #1 do select on both >>select high >>

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread robert engels
It needs one other fix, and that is to have a check of the queue and poll high, in case the queue has elements when the method is entered. But if you implement the queue using a buffered channel it is trivial to change the step #1 to handle this (the low and queue channels are mimic the high

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread robert engels
I will give you the pseudo code: { // step #1 do select on both select high select low } if high read: return high else: // we read a low so do a high poll { select high: default: } if high read: enqueue low and return high else: if queue empty:

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread Robert Engels
It is trivial to do a priority select. Check the high priority channel again after getting a low priority value. If the high priority is available enqueue the low value and handle the high. It is also trivial to “delay” the handling to allow more time for high events to arrive if dealing with

Re: [go-nuts] Re: How to do vdso calls in my own code?

2021-04-29 Thread Robert Engels
The point is that if you are timing “so much” that a 1-2 % overhead (so you must have tons of very small operations) matter to throughput - sampling will still capture enough that a representative event will be recorded. Still, optimizing time.Now() is always a good idea but I am guessing much

Re: [go-nuts] Re: How to do vdso calls in my own code?

2021-04-28 Thread Robert Engels
If you are timing so short operations that the overhead is 1-2%, just time every 1000 calls - reduces the overhead to a minimum. Normally makes no difference if the operations are that short. Similar to how benchmarking works - time the total and divide by the number of operations. > On Apr

Re: [go-nuts] Case for Cond.WaitTimeout()

2021-04-13 Thread Robert Engels
Have the channel hold a slice of objects and process them as a batch. Batch in - batch out. Typically unless your traffic is bursty - a faster producer than consumer will either cause blocking, data loss (drops) or failure (oom). > On Apr 13, 2021, at 8:00 AM, Roman Leventov wrote: > >  >

Re: [go-nuts] Re: Releasing a V2 module and interacting with git branches

2021-04-08 Thread Robert Engels
Having a different v2 directory is a bad idea. It is not sustainable. It is a pain because you will have N copies of everything - so backporting bug fixes will be a pain. > On Apr 8, 2021, at 7:07 PM, Martin Atkins wrote: > > I had some experiences with doing this sort of thing for what

Re: [go-nuts] Big variations in benchmarking results ?

2021-04-07 Thread Robert Engels
OSX has a very different scheduler and often many more background processes. Also, you need to ensure you are running on the exact same chipset due to variations in cpu cache sizes and implementations. > On Apr 7, 2021, at 12:27 PM, christoph...@gmail.com > wrote: > > Hello, > > I'm

<    1   2   3   4   5   6   7   8   9   10   >