You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/02/09 03:35:58 UTC
[GitHub] [flink] xintongsong opened a new pull request #14904: [WIP][FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
xintongsong opened a new pull request #14904:
URL: https://github.com/apache/flink/pull/14904
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
*(For example: This pull request makes task deployment go through the blob server, rather than through RPC. That way we avoid re-transferring them on each deployment (during recovery).)*
## Brief change log
*(for example:)*
- *The TaskInfo is stored in the blob store on job creation time as a persistent artifact*
- *Deployments RPC transmits only the blob storage reference*
- *TaskManagers retrieve the TaskInfo from the blob cache*
## Verifying this change
*(Please pick either of the following options)*
This change is a trivial rework / code cleanup without any test coverage.
*(or)*
This change is already covered by existing tests, such as *(please describe tests)*.
*(or)*
This change added tests and can be verified as follows:
*(example:)*
- *Added integration tests for end-to-end deployment with large payloads (100MB)*
- *Extended integration test for recovery after master (JobManager) failure*
- *Added test that validates that TaskInfo is transferred only once across recoveries*
- *Manually verified the change by running a 4 node cluser with 2 JobManagers and 4 TaskManagers, a stateful streaming program, and killing one JobManager and two TaskManagers during the execution, verifying that recovery happens correctly.*
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no)
- The serializers: (yes / no / don't know)
- The runtime per-record code paths (performance sensitive): (yes / no / don't know)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / no / don't know)
- The S3 file system connector: (yes / no / don't know)
## Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
}, {
"hash" : "b194119f275e5a19a86281965584b60df59d5c39",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138",
"triggerID" : "b194119f275e5a19a86281965584b60df59d5c39",
"triggerType" : "PUSH"
}, {
"hash" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143",
"triggerID" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"triggerType" : "PUSH"
}, {
"hash" : "d1936a88cb501ec300e7b6dd752210850df4ef1a",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13320",
"triggerID" : "d1936a88cb501ec300e7b6dd752210850df4ef1a",
"triggerType" : "PUSH"
}, {
"hash" : "e4771acc22f44a36ba14772f2f8c83cab8b4dcb3",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "e4771acc22f44a36ba14772f2f8c83cab8b4dcb3",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d1936a88cb501ec300e7b6dd752210850df4ef1a Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13320)
* e4771acc22f44a36ba14772f2f8c83cab8b4dcb3 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775636912
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.
## Automated Checks
Last check on commit e4771acc22f44a36ba14772f2f8c83cab8b4dcb3 (Fri Feb 19 07:33:15 UTC 2021)
**Warnings:**
* No documentation files were touched! Remember to keep the Flink docs up to date!
<sub>Mention the bot in a comment to re-run the automated checks.</sub>
## Review Progress
* ❓ 1. The [description] looks good.
* ❓ 2. There is [consensus] that the contribution should go into to Flink.
* ❓ 3. Needs [attention] from.
* ❓ 4. The change fits into the overall [architecture].
* ❓ 5. Overall code [quality] is good.
Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
- `@flinkbot approve all` to approve all aspects
- `@flinkbot approve-until architecture` to approve everything until `architecture`
- `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
- `@flinkbot disapprove architecture` to remove an approval you gave earlier
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
curcur commented on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-779305230
thanks!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #14904: [WIP][FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 797afe4dcb649ffa6e1e761581389c6055af0c9c UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
}, {
"hash" : "b194119f275e5a19a86281965584b60df59d5c39",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138",
"triggerID" : "b194119f275e5a19a86281965584b60df59d5c39",
"triggerType" : "PUSH"
}, {
"hash" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143",
"triggerID" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b194119f275e5a19a86281965584b60df59d5c39 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138)
* ce6b3c307ea29e9848aeb1b71734adbf67492fa2 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #14904: [WIP][FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775636912
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.
## Automated Checks
Last check on commit 797afe4dcb649ffa6e1e761581389c6055af0c9c (Tue Feb 09 03:38:18 UTC 2021)
**Warnings:**
* No documentation files were touched! Remember to keep the Flink docs up to date!
<sub>Mention the bot in a comment to re-run the automated checks.</sub>
## Review Progress
* ❓ 1. The [description] looks good.
* ❓ 2. There is [consensus] that the contribution should go into to Flink.
* ❓ 3. Needs [attention] from.
* ❓ 4. The change fits into the overall [architecture].
* ❓ 5. Overall code [quality] is good.
Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
- `@flinkbot approve all` to approve all aspects
- `@flinkbot approve-until architecture` to approve everything until `architecture`
- `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
- `@flinkbot disapprove architecture` to remove an approval you gave earlier
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
}, {
"hash" : "b194119f275e5a19a86281965584b60df59d5c39",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138",
"triggerID" : "b194119f275e5a19a86281965584b60df59d5c39",
"triggerType" : "PUSH"
}, {
"hash" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 797afe4dcb649ffa6e1e761581389c6055af0c9c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133)
* b194119f275e5a19a86281965584b60df59d5c39 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138)
* ce6b3c307ea29e9848aeb1b71734adbf67492fa2 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on a change in pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong commented on a change in pull request #14904:
URL: https://github.com/apache/flink/pull/14904#discussion_r576076365
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -357,4 +385,9 @@ public final void put(int offset, ByteBuffer source, int numBytes) {
}
}
}
+
+ @Override
+ public <T> T processAsByteBuffer(Function<ByteBuffer, T> processFunction) {
+ return Preconditions.checkNotNull(processFunction).apply(wrapInternal(0, size));
+ }
Review comment:
I'll look into them together with the follow-up refactor effort. Since not all `wrap` calls are on the entire segment, I'll need to check the performance impact from using `Function` on those calls.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong commented on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-778720630
Comments addressed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] tillrohrmann commented on a change in pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
tillrohrmann commented on a change in pull request #14904:
URL: https://github.com/apache/flink/pull/14904#discussion_r576310043
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -357,4 +385,9 @@ public final void put(int offset, ByteBuffer source, int numBytes) {
}
}
}
+
+ @Override
+ public <T> T processAsByteBuffer(Function<ByteBuffer, T> processFunction) {
+ return Preconditions.checkNotNull(processFunction).apply(wrapInternal(0, size));
+ }
Review comment:
Maybe it is also ok to provide additional methods on the `MemorySegment` which use internally a `ByteBuffer` implementation to be efficient.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
}, {
"hash" : "b194119f275e5a19a86281965584b60df59d5c39",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138",
"triggerID" : "b194119f275e5a19a86281965584b60df59d5c39",
"triggerType" : "PUSH"
}, {
"hash" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143",
"triggerID" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"triggerType" : "PUSH"
}, {
"hash" : "d1936a88cb501ec300e7b6dd752210850df4ef1a",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13320",
"triggerID" : "d1936a88cb501ec300e7b6dd752210850df4ef1a",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ce6b3c307ea29e9848aeb1b71734adbf67492fa2 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143)
* d1936a88cb501ec300e7b6dd752210850df4ef1a Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13320)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775776799
cc @tillrohrmann
Could you please take a look at this PR?
One thing I'm not entirely sure is that, do we still need a configuration option to fallback to the original behaviors, given that we have already forbidden wrapping buffers from unsafe segments?
This [branch](https://github.com/xintongsong/flink/tree/FLINK-20663-managed-memory-2) contains an additional commit compared to this PR, which introduces such a configuration option by touching quite some files. (FYI, this branch also passed the [CI tests](https://dev.azure.com/tonysong820/Flink/_build/results?buildId=154&view=results).)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] tillrohrmann commented on a change in pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
tillrohrmann commented on a change in pull request #14904:
URL: https://github.com/apache/flink/pull/14904#discussion_r575294320
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -357,4 +385,9 @@ public final void put(int offset, ByteBuffer source, int numBytes) {
}
}
}
+
+ @Override
+ public <T> T processAsByteBuffer(Function<ByteBuffer, T> processFunction) {
+ return Preconditions.checkNotNull(processFunction).apply(wrapInternal(0, size));
+ }
Review comment:
Which calls to `wrap` cannot be replaced with this call?
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -57,6 +59,10 @@
*/
@Nullable private ByteBuffer offHeapBuffer;
+ @Nullable private final Runnable cleaner;
+
+ private final boolean allowWrap;
Review comment:
It might not be super clear which segments are allowed to be wrapped and which not. Adding some explanation could help.
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -357,4 +385,9 @@ public final void put(int offset, ByteBuffer source, int numBytes) {
}
}
}
+
+ @Override
+ public <T> T processAsByteBuffer(Function<ByteBuffer, T> processFunction) {
+ return Preconditions.checkNotNull(processFunction).apply(wrapInternal(0, size));
+ }
Review comment:
Do we know what the performance penalty for the additional `Function` is?
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java
##########
@@ -1386,4 +1387,17 @@ public final boolean equalTo(MemorySegment seg2, int offset1, int offset2, int l
public byte[] getHeapMemory() {
return heapMemory;
}
+
+ /**
+ * Applies the given process function on a {@link ByteBuffer} that represents this entire
+ * segment.
+ *
+ * <p>Note: The {@link ByteBuffer} passed into the process function is temporary and could
+ * become invalid after the processing. Thus, the process function should not try to keep any
+ * reference of the {@link ByteBuffer}.
+ *
+ * @param processFunction to be applied to the segment as {@link ByteBuffer}.
+ * @return the value that the process function returns.
+ */
+ public abstract <T> T processAsByteBuffer(Function<ByteBuffer, T> processFunction);
Review comment:
We could also add a `acceptAsByteBuffer(Consumer<ByteBuffer> consumer)` for the case where we don't want to return a value.
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -94,26 +126,22 @@
@Override
public void free() {
super.free();
+ if (cleaner != null) {
+ cleaner.run();
+ }
Review comment:
If we had a `DirectMemorySegment`, then we could only allow `wrap` on this type, for example.
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -94,26 +126,22 @@
@Override
public void free() {
super.free();
+ if (cleaner != null) {
+ cleaner.run();
+ }
Review comment:
Looking at the special casing of this class, why don't we introduce an `DirectMemorySegment` and a `UnsafeMemorySegment`? Also, why do we have the `HeapMemorySegment` and still allow the `HybridMemorySegment` to be used with heap memory?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong commented on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775776799
cc @tillrohrmann
Could you please take a look at this PR?
One thing I'm not entirely sure is that, do we still need a configuration option to fallback to the original behaviors, given that we have already forbidden wrapping buffers from unsafe segments?
This [branch](https://github.com/xintongsong/flink/tree/FLINK-20663-managed-memory-2) contains an additional commit compared to this PR, which introduces such a configuration option by touching quite some files.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] tillrohrmann commented on a change in pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
tillrohrmann commented on a change in pull request #14904:
URL: https://github.com/apache/flink/pull/14904#discussion_r576068283
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -357,4 +385,9 @@ public final void put(int offset, ByteBuffer source, int numBytes) {
}
}
}
+
+ @Override
+ public <T> T processAsByteBuffer(Function<ByteBuffer, T> processFunction) {
+ return Preconditions.checkNotNull(processFunction).apply(wrapInternal(0, size));
+ }
Review comment:
We could think about replacing these calls with `processAsByteBuffer` also for the direct memory in order to be able to get rid of the `wrap` method.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [WIP][FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 797afe4dcb649ffa6e1e761581389c6055af0c9c Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
}, {
"hash" : "b194119f275e5a19a86281965584b60df59d5c39",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138",
"triggerID" : "b194119f275e5a19a86281965584b60df59d5c39",
"triggerType" : "PUSH"
}, {
"hash" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143",
"triggerID" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"triggerType" : "PUSH"
}, {
"hash" : "d1936a88cb501ec300e7b6dd752210850df4ef1a",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "d1936a88cb501ec300e7b6dd752210850df4ef1a",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ce6b3c307ea29e9848aeb1b71734adbf67492fa2 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143)
* d1936a88cb501ec300e7b6dd752210850df4ef1a UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
}, {
"hash" : "b194119f275e5a19a86281965584b60df59d5c39",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138",
"triggerID" : "b194119f275e5a19a86281965584b60df59d5c39",
"triggerType" : "PUSH"
}, {
"hash" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143",
"triggerID" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 797afe4dcb649ffa6e1e761581389c6055af0c9c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133)
* b194119f275e5a19a86281965584b60df59d5c39 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138)
* ce6b3c307ea29e9848aeb1b71734adbf67492fa2 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
}, {
"hash" : "b194119f275e5a19a86281965584b60df59d5c39",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138",
"triggerID" : "b194119f275e5a19a86281965584b60df59d5c39",
"triggerType" : "PUSH"
}, {
"hash" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143",
"triggerID" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"triggerType" : "PUSH"
}, {
"hash" : "d1936a88cb501ec300e7b6dd752210850df4ef1a",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13320",
"triggerID" : "d1936a88cb501ec300e7b6dd752210850df4ef1a",
"triggerType" : "PUSH"
}, {
"hash" : "e4771acc22f44a36ba14772f2f8c83cab8b4dcb3",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13335",
"triggerID" : "e4771acc22f44a36ba14772f2f8c83cab8b4dcb3",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d1936a88cb501ec300e7b6dd752210850df4ef1a Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13320)
* e4771acc22f44a36ba14772f2f8c83cab8b4dcb3 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13335)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [WIP][FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 797afe4dcb649ffa6e1e761581389c6055af0c9c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-779289434
Passed CI here:
* master (1.13): https://dev.azure.com/tonysong820/Flink/_build/results?buildId=157&view=results
* release-1.12: https://dev.azure.com/tonysong820/Flink/_build/results?buildId=158&view=results
Merging this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] tillrohrmann commented on a change in pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
tillrohrmann commented on a change in pull request #14904:
URL: https://github.com/apache/flink/pull/14904#discussion_r576065491
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -94,26 +126,22 @@
@Override
public void free() {
super.free();
+ if (cleaner != null) {
+ cleaner.run();
+ }
Review comment:
With this refactoring we could also think about getting rid of the whole native memory cleaner logic.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [WIP][FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
}, {
"hash" : "b194119f275e5a19a86281965584b60df59d5c39",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "b194119f275e5a19a86281965584b60df59d5c39",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 797afe4dcb649ffa6e1e761581389c6055af0c9c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133)
* b194119f275e5a19a86281965584b60df59d5c39 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on a change in pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong commented on a change in pull request #14904:
URL: https://github.com/apache/flink/pull/14904#discussion_r575746460
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -94,26 +126,22 @@
@Override
public void free() {
super.free();
+ if (cleaner != null) {
+ cleaner.run();
+ }
Review comment:
`HybridMemorySegment` is currently the only `MemorySegment` implementation that is used in production. `HeapMemorySegment` is no longer used, but seems intentionally not removed as it is annotated with `@SuppressWarnings("unused")`.
From my side, it makes sense to split `HybridMemorySegment` into `HeapMemorySegment`, `DirectMemorySegment` and `UnsafeMemorySegment`. This should get rid of lots of `if-else` branches in the implementation.
I'm leaning towards addressing this refactor as a follow-up effort, and only do that for the master branch.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] tillrohrmann commented on a change in pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
tillrohrmann commented on a change in pull request #14904:
URL: https://github.com/apache/flink/pull/14904#discussion_r576070731
##########
File path: flink-core/src/test/java/org/apache/flink/core/memory/HybridOffHeapUnsafeMemorySegmentTest.java
##########
@@ -38,4 +39,10 @@ MemorySegment createSegment(int size) {
MemorySegment createSegment(int size, Object owner) {
return MemorySegmentFactory.allocateOffHeapUnsafeMemory(size, owner, () -> {});
}
+
+ @Override
+ @Test(expected = UnsupportedOperationException.class)
+ public void testByteBufferWrapping() {
+ createSegment(10).wrap(1, 2);
+ }
Review comment:
Maybe add a test which ensures that we call the cleaner in case of `free`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong closed pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong closed pull request #14904:
URL: https://github.com/apache/flink/pull/14904
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on a change in pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong commented on a change in pull request #14904:
URL: https://github.com/apache/flink/pull/14904#discussion_r576077302
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -94,26 +126,22 @@
@Override
public void free() {
super.free();
+ if (cleaner != null) {
+ cleaner.run();
+ }
Review comment:
I'll drive the refactor effort and try to get it done in the 1.13 release cycle.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
}, {
"hash" : "b194119f275e5a19a86281965584b60df59d5c39",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138",
"triggerID" : "b194119f275e5a19a86281965584b60df59d5c39",
"triggerType" : "PUSH"
}, {
"hash" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143",
"triggerID" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ce6b3c307ea29e9848aeb1b71734adbf67492fa2 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong commented on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-779128132
Thanks for the review, @tillrohrmann.
I've added the test case. Will merge this once AZP gives green light.
For the follow-up refactor effort, I opened FLINK-21375.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
}, {
"hash" : "b194119f275e5a19a86281965584b60df59d5c39",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138",
"triggerID" : "b194119f275e5a19a86281965584b60df59d5c39",
"triggerType" : "PUSH"
}, {
"hash" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13143",
"triggerID" : "ce6b3c307ea29e9848aeb1b71734adbf67492fa2",
"triggerType" : "PUSH"
}, {
"hash" : "d1936a88cb501ec300e7b6dd752210850df4ef1a",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13320",
"triggerID" : "d1936a88cb501ec300e7b6dd752210850df4ef1a",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d1936a88cb501ec300e7b6dd752210850df4ef1a Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13320)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong commented on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-778718163
@tillrohrmann Thanks for the review.
Concerning indefinitely waiting when there's enough `expectedFreeMemory` but not enough `actualFreeMemory`, we have actually considered similar approach.
I think this approach indeed solves the failures due to GC not releasing memory timely. However, it solves the problem by *waiting longer*, which may not have as good performance as the current solution that tries to *release earlier*. In case there's no enough heap activities to trigger GC in advance, we may frequently experience full GC on finishing existing tasks and deploying new tasks, which is costly for batch scenarios where deploying new tasks are frequent and TMs are usually large.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong commented on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-779289434
Passed CI here:
* master (1.13): https://dev.azure.com/tonysong820/Flink/_build/results?buildId=157&view=results
* release-1.12: https://dev.azure.com/tonysong820/Flink/_build/results?buildId=157&view=results
Merging this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #14904: [WIP][FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14904:
URL: https://github.com/apache/flink/pull/14904#issuecomment-775639746
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133",
"triggerID" : "797afe4dcb649ffa6e1e761581389c6055af0c9c",
"triggerType" : "PUSH"
}, {
"hash" : "b194119f275e5a19a86281965584b60df59d5c39",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138",
"triggerID" : "b194119f275e5a19a86281965584b60df59d5c39",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 797afe4dcb649ffa6e1e761581389c6055af0c9c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13133)
* b194119f275e5a19a86281965584b60df59d5c39 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=13138)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] tillrohrmann commented on a change in pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
tillrohrmann commented on a change in pull request #14904:
URL: https://github.com/apache/flink/pull/14904#discussion_r576064881
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -94,26 +126,22 @@
@Override
public void free() {
super.free();
+ if (cleaner != null) {
+ cleaner.run();
+ }
Review comment:
Ok, this sounds reasonable. Then let's do this refactoring soon. In fact, `HeapMemorySegment` does not seem to be that unused anymore. Somehow the table API started using this class for some `RawFormatDeserializationSchema`. This might be a good indicator for pulling things straight.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on a change in pull request #14904: [FLINK-20663][runtime] Instantly release unsafe memory on freeing segment.
Posted by GitBox <gi...@apache.org>.
xintongsong commented on a change in pull request #14904:
URL: https://github.com/apache/flink/pull/14904#discussion_r575744928
##########
File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
##########
@@ -357,4 +385,9 @@ public final void put(int offset, ByteBuffer source, int numBytes) {
}
}
}
+
+ @Override
+ public <T> T processAsByteBuffer(Function<ByteBuffer, T> processFunction) {
+ return Preconditions.checkNotNull(processFunction).apply(wrapInternal(0, size));
+ }
Review comment:
> Which calls to wrap cannot be replaced with this call?
Technically, I don't think there are `wrap` calls that CANNOT be replaced. Some of the calls only wrap part of the segment, which can be solved by simply adding `offset` and `length` as arguments. I have not replaced all calls to `wrap` with this `processAsByteBuffer`, mostly because the remaining calls are on direct segment, thus it's not necessary to migrate them.
> Do we know what the performance penalty for the additional Function is?
We don't have a measurement. However, given that this method is for the per-segment operation (by default 32KB), I don't expect a significant performance penalty from using the `Function`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org