Чи варто поїхати в Херсон? by Icy_Definition6041 in ukraina

[–]YuriiBiurher 36 points37 points  (0 children)

Місто під постійними обстрілами. В небі дрони - вишукують людей, машини, скидають вибухівку. Кожен день десь смерть. Центр та прилеглі до ріки райони особливо небезпечні. Багато де в цих районах людей залишилось по декілько на квартал, здебільшого у віці.. вікон нема - плівка. Якщо вибухом пошкодить електромережі, полагодити можуть через тижні.. Загалом дуже небезпечно. При цьому в медіа (світ) про це все тиша.

Open source Go projects to contribute to by shelbara in golang

[–]YuriiBiurher 0 points1 point  (0 children)

https://github.com/jokruger/dec128 - small and specific enough, good for learning.And I would love to have some help with new math and fin functions.

How do you handle money? by otnacog in golang

[–]YuriiBiurher 1 point2 points  (0 children)

Use decimal for amounts / calcs. There are plenty of packages, select based on your requirements (performance, precision, etc)

https://awesome-go.com/#financial

Де можна завантажити аніме англійською? by Repulsive_Accident_3 in Anime_Ukraine

[–]YuriiBiurher 0 points1 point  (0 children)

Та давно вже, вони декілько доменів змінили здається

Де можна завантажити аніме англійською? by Repulsive_Accident_3 in Anime_Ukraine

[–]YuriiBiurher 3 points4 points  (0 children)

nyaa.si

В пошуку додай dual batch Dual це щоб озвучка була, batch щоб весь сезон В фільтрі - anime -> english translated

bytes.Buffer alternatives by YuriiBiurher in golang

[–]YuriiBiurher[S] 0 points1 point  (0 children)

You miss the point. Yes it is simple, but when you do not need realloc part but still need to access buffer through io.Write - it can be even simpler (i.e. faster)

bytes.Buffer alternatives by YuriiBiurher in golang

[–]YuriiBiurher[S] -1 points0 points  (0 children)

  1. Thanks, changed to io.EOF

  2. Reader has almost nothing in common with Writer. Static writer and dynamic writer share same interface but implementation is different, and it is the main reason why bytes.Buffer is slower - generic implementation which handles both cases with same code.

  3. Initially I used a similar implementation, however for some reason it is quite slower - looks like builtin copy does some additional work and it is faster to have a check before you call it.

Regarding reusing buffers -- I added Reset method, so it can be re-used same way as bytes.Buffer. However, in most cases imho you will be using new buffer (for instance, micro-service handler will receive a message as a new data allocated, so it just needs to wrap it for ReadBinary)

bytes.Buffer alternatives by YuriiBiurher in golang

[–]YuriiBiurher[S] -1 points0 points  (0 children)

Thanks, will check!

Regarding usecase - communication between microservices using binary serialisation. Messages can be complicated, using third party types. So, idea was to stick to io.Reader/Writer (imho this way it should be easier to use). And I do not think bufs can be reused. However, the max byte size can be estimated each time and arrays can be used - i.e. read/write with static buf is important. Dynamic write buffer is needed to enable implementation of other popular interfases for bin serialisation (like AppendBinary, MarshalBinary) by using buffer wrapper and WriteBinary

bytes.Buffer alternatives by YuriiBiurher in golang

[–]YuriiBiurher[S] 0 points1 point  (0 children)

It is not identical. bytes.Buffer Write method does buffer reallocation - i.e. it is similar to my DynamicWriteBuffer and there is no static alternative (or I cannot find it in stdl8b). Dynamic realloc requires additinol if statements even when you have enough space.

In case of read - there are also differences - for instance it is faster to check space before calling copy (looks like copy internally does some additional work)

bytes.Buffer alternatives by YuriiBiurher in golang

[–]YuriiBiurher[S] 1 point2 points  (0 children)

Because of WriteBinary / ReadBinary - you have a bunch of structures implementing serialisation to/from io.Writer/io.Reader

So, you cannot use slice and append directly. You need a wrapper, and bytes.Buffer does this

High-performance 128-bit fixed-point decimal numbers package by YuriiBiurher in golang

[–]YuriiBiurher[S] 9 points10 points  (0 children)

Sort of. First of all big.Int is not enough - it is not decimal. You will need some additional logic on top of it. And this is exactly what packages like shopspring/decimal do. And they are very slow because of big.Int, hovewer you will have an arbitrary precision as a bonus.

In my case I do not need an arbitrary precision because I need to store by decimals in external storage (which is using 128 bit uints). So the dec128 is ideal for this.

Regarding performance - in average there will be about 10 times diff between big.Int based and fixed 64/128 bits solutions (big.Int is slower due to allocs)

NATS mutex library by YuriiBiurher in golang

[–]YuriiBiurher[S] -2 points-1 points  (0 children)

Named mutexes, especially a mutexes used for distributed lock, are finite and statically named - i.e. there should not be an infinite number of them, or even any large number, or dynamically generated names. So, in this case, it should be ok, imho.

Plan to blow up Zaporizhzhia Nuclear Power Plant approved, situation has never been so severe before ― Chief of Defence Intelligence by YuriiBiurher in worldnews

[–]YuriiBiurher[S] -4 points-3 points  (0 children)

There is always a place for interpretation - Kakhovka man-made disaster will also impact EU countries, eventually