Andrew Otto
03/13/2023, 1:57 PMDian Fu
03/14/2023, 2:29 AMAndrew Otto
03/14/2023, 8:21 AMfunc we are calling in the ProcessFunction. And this is the full ProcessFunction we apply the datastream to.Andrew Otto
03/14/2023, 8:21 AMAndrew Otto
03/14/2023, 8:24 AMDian Fu
03/14/2023, 2:19 PMtaskmanager.memory.managed.fraction: 0.4 (default)
taskmanager.memory.managed.consumer-weights: OPERATOR:70,STATE_BACKEND:70,PYTHON:30 (default)
jobmanager.memory.jvm-overhead.fraction: 0.1 (default)Andrew Otto
03/14/2023, 3:38 PMDian Fu
03/15/2023, 2:49 AMWe are also going to try an async python http client, but i’m not really sure how that fits in with Flink, since PyFlink doesn’t itself support Async IO operatorsThis is still not supported (We are planning to provide support for this in Flink 1.18). For now, if you could torrent losing some records during job failover, you could try to use async http client to retrieve record inside
FlatMapFunction of datastream.flat_map(FlatMapFunction) , the flat_map of FlatMapFunction may look like the following:
• perform async http client operations for the newly incoming record
• check if the previous results are already available and return them if available
The side effects of this approach:
• During failover, in-complete records will be discardedGabriele Modena
03/19/2023, 12:45 PMpython.fn-execution.arrow.batch.sizeGabriele Modena
03/19/2023, 12:54 PMpython.profile.enabled) and was able to identify some hot paths that do correlate to memory allocation (SerDes and dict <-> Row conversion), but I'd like more introspection on what is holding memory.
As a last resort, I'm considering extending the current cProfile based Profiler class and add tracemalloc probes, but maybe I'm missing something more obvious and straightforward.Dian Fu
03/20/2023, 2:15 AMwhile memory consumption grows over time, the number of objects tracked by Python’s GC seem to stabilize after a few minutes of runtime, and not grow linearly with memory.Does the Python process memory continues grow in this case?
Gabriele Modena
03/20/2023, 9:42 AMDian Fu
03/20/2023, 11:21 AMProcessFunction to check whether the memory leak comes from the PyFlink framework or your custom code
• If it comes your custom code, try to comment out part of the logic to identify which part of code the memory leak comes from
Besides, I guess you could also try tools like the following: https://web.archive.org/web/20160316152429/http://www.lshift.net/blog/2008/11/14/tracing-python-memory-leaks/Gabriele Modena
03/20/2023, 11:41 AMTry to comment all of the code inside yourThat's the path I'm taking now, with some heuristics I got from cProfile. I'll report back if something interesting comes out.to check whether the memory leak comes from the PyFlink framework or your custom codeProcessFunction
Andrew Otto
03/27/2023, 6:34 PMDian Fu
03/28/2023, 1:55 AMAndrew Otto
03/28/2023, 12:32 PMAndrew Otto
04/27/2023, 12:16 PM