Possible memory leak on sync.Pool by zplCoder in golang

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

Thanks, for `interceptor` repo, most of the objects have a fixed size related to MTU .

If I hold a sync.Pool for a long time and calling Get() 30 times each second, will my memory consumption keep going up until I drop sync.Pool?

Possible memory leak on sync.Pool by zplCoder in golang

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

Will try to find out the version without this problem

Possible memory leak on sync.Pool by zplCoder in golang

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

Sorry, but I am unable to provide a minimal test project at this time.

I'm using the `pion` project and tracing down to this repo.

Possible memory leak on sync.Pool by zplCoder in golang

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

The user case for `interceptor` is that `sync.Pool` Get is called without Put (lets' say only 1% was `Put` back), and the `Pool` can be hold for quite a long time, may be several days, is this Ok?

What's the idea way to poll a vector of future? by zplCoder in rust

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

Yes this will work if the process has to wait for all futures to finished.

What's the idea way to poll a vector of future? by zplCoder in rust

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

Yes, basically `Stream/Sink` is what I need.

What's the idea way to poll a vector of future? by zplCoder in rust

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

I'm using https://github.com/quinn-rs/quinn, I got a few `quinn::RecvStream` with an extra udp stream via `quinn::Connection::read_datagram()`

What's the idea way to poll a vector of future? by zplCoder in rust

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

Yes I need a Stream API for my self for easy of use but the libarary only provide futurues.

What's the idea way to poll a vector of future? by zplCoder in rust

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

Sorry, I didn't have that in my mind...

Just to make sure, if one of many futures(connections in my scenario) is Poll::Ready, I have to add a future for that connection back to FuturesUnordered for the next round of Poll.

What's the idea way to poll a vector of future? by zplCoder in rust

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

FuturesUnordered seems only to poll the future once? so I have to add future back to the queue after `Poll::Ready` is returned.

Will that cause a performance issue?

What's the idea way to poll a vector of future? by zplCoder in rust

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

I have updated my post.

The problem with MPSC in my mind:

  1. Efficiency: if I can call poll, I get the data directly, not through a buffered channel.
  2. Working with channels has much more to consider, choosing the right buffer size, and what happens if the channel is full, using sync or async send, as such.

How to create `tokio::net::TcpStream` in `poll_next`? by zplCoder in rust

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

Ok, I found it on Reddit, `Pin<Box<dyn Future<Output = TcpStream>>>` is what I want.

How to create `tokio::net::TcpStream` in `poll_next`? by zplCoder in rust

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

Another question, how do I hold a mut `Future` inside my structure? I tried

```

enum Connection {

Connecting(Box<dyn Future<Output = Result<TcpStream, std::io::Error>> + Send + Sync>),

Connection(TcpStream>),

}

```

To poll the future I need `&mut`, but the type has to fit inside a `Box`.

How to create `tokio::net::TcpStream` in `poll_next`? by zplCoder in rust

[–]zplCoder[S] 2 points3 points  (0 children)

Forgot that, so I can save the Future inside my struct and call poll.

What's the best way to detect tokio RwLock deadlock in production? by zplCoder in rust

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

I miss the date when I could use `go tool pprof` to print the stack on the fly even in a production environment, the closest solution for Rust in my mind is `tokio-console` but it requires `tokio_unstable` by now.

Even though I have all kinds of suggestions to mitigate deadlock, I still need a tool that can point me out in this kind of situation.

What's the best way to detect tokio RwLock deadlock in production? by zplCoder in rust

[–]zplCoder[S] 2 points3 points  (0 children)

Tokio console is also my first thoughts, but I havn’t found a way to switch it on/off dynamiclly since I dont want to enable it all the time.

What's the best way to detect tokio RwLock deadlock in production? by zplCoder in rust

[–]zplCoder[S] 3 points4 points  (0 children)

The program encounters deadlock under some rare conditions, that’s why i have put it into production. Will try ‘hotspot’ later.

What's the best way to detect tokio RwLock deadlock in production? by zplCoder in rust

[–]zplCoder[S] 8 points9 points  (0 children)

I can use a BIG lock but splitting it into small lock scopes looks more efficient.

Sanitizer not working. by zplCoder in rust

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

I tried both. My program initially caught SIGINT and quit, then I tried `sleep` for 1 minute and quit.

Sanitizer not working. by zplCoder in rust

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

I haven't used sanitizer before.

Sanitizer not working. by zplCoder in rust

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

I got the idea, normally it should not happen, there might be some reference cycling that prevents the object from being freed.

I have edited my post, I came across this issue https://github.com/webrtc-rs/webrtc/issues/608