You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/02/10 06:24:48 UTC
[GitHub] [incubator-hudi] lamber-ken opened a new pull request #1317:
[HUDI-605] Avoid calculating the size of schema redundantly
lamber-ken opened a new pull request #1317: [HUDI-605] Avoid calculating the size of schema redundantly
URL: https://github.com/apache/incubator-hudi/pull/1317
## What is the purpose of the pull request
The same schema object is shared amongst all records in the JVM.
## Brief change log
- Calculate the size of schema when init HoodieRecordSizeEstimator
## Verify this pull request
This pull request is already covered by existing tests:
`org.apache.hudi.common.util.collection.TestDiskBasedMap`.
## Committer checklist
- [X] Has a corresponding JIRA in PR title & commit
- [X] Commit message is descriptive of the change
- [ ] CI is green
- [ ] Necessary doc changes done or have another open PR
- [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-hudi] lamber-ken commented on a change in pull request
#1317: [HUDI-605] Avoid calculating the size of schema redundantly
Posted by GitBox <gi...@apache.org>.
lamber-ken commented on a change in pull request #1317: [HUDI-605] Avoid calculating the size of schema redundantly
URL: https://github.com/apache/incubator-hudi/pull/1317#discussion_r377734447
##########
File path: hudi-common/src/main/java/org/apache/hudi/common/util/HoodieRecordSizeEstimator.java
##########
@@ -49,8 +48,9 @@ public long sizeEstimate(HoodieRecord<T> hoodieRecord) {
// note the sizes and differences. A correct estimation in such cases is handled in
/** {@link ExternalSpillableMap} **/
long sizeOfRecord = ObjectSizeCalculator.getObjectSize(hoodieRecord);
- long sizeOfSchema = ObjectSizeCalculator.getObjectSize(schema);
- LOG.info("SizeOfRecord => " + sizeOfRecord + " SizeOfSchema => " + sizeOfSchema);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("SizeOfRecord => " + sizeOfRecord + " SizeOfSchema => " + sizeOfSchema);
+ }
Review comment:
More, HoodieRecordSizeEstimator is mainly used in `ExternalSpillableMap`, `ExternalSpillableMap#put` has log it.
```
if (shouldEstimatePayloadSize && estimatedPayloadSize == 0) {
// At first, use the sizeEstimate of a record being inserted into the spillable map.
// Note, the converter may over estimate the size of a record in the JVM
this.estimatedPayloadSize = keySizeEstimator.sizeEstimate(key) + valueSizeEstimator.sizeEstimate(value);
LOG.info("Estimated Payload size => " + estimatedPayloadSize);
}
```
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-hudi] lamber-ken commented on a change in pull request
#1317: [HUDI-605] Avoid calculating the size of schema redundantly
Posted by GitBox <gi...@apache.org>.
lamber-ken commented on a change in pull request #1317: [HUDI-605] Avoid calculating the size of schema redundantly
URL: https://github.com/apache/incubator-hudi/pull/1317#discussion_r376897263
##########
File path: hudi-common/src/main/java/org/apache/hudi/common/util/collection/DiskBasedMap.java
##########
@@ -223,8 +223,8 @@ private R get(ValueMetadata entry) {
private synchronized R put(T key, R value, boolean flush) {
try {
byte[] val = SerializationUtils.serialize(value);
- Integer valueSize = val.length;
- Long timestamp = System.currentTimeMillis();
+ int valueSize = val.length;
Review comment:
The type of `val.lenght` is primitive type(int), the type of `System.currentTimeMillis()` is primitive type(long).
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-hudi] leesf commented on a change in pull request #1317:
[HUDI-605] Avoid calculating the size of schema redundantly
Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1317: [HUDI-605] Avoid calculating the size of schema redundantly
URL: https://github.com/apache/incubator-hudi/pull/1317#discussion_r377649151
##########
File path: hudi-common/src/main/java/org/apache/hudi/common/util/HoodieRecordSizeEstimator.java
##########
@@ -49,8 +48,9 @@ public long sizeEstimate(HoodieRecord<T> hoodieRecord) {
// note the sizes and differences. A correct estimation in such cases is handled in
/** {@link ExternalSpillableMap} **/
long sizeOfRecord = ObjectSizeCalculator.getObjectSize(hoodieRecord);
- long sizeOfSchema = ObjectSizeCalculator.getObjectSize(schema);
- LOG.info("SizeOfRecord => " + sizeOfRecord + " SizeOfSchema => " + sizeOfSchema);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("SizeOfRecord => " + sizeOfRecord + " SizeOfSchema => " + sizeOfSchema);
+ }
Review comment:
Would be still keep to `LOG.info` or Any reason to change to debug?
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-hudi] vinothchandar commented on a change in pull
request #1317: [HUDI-605] Avoid calculating the size of schema redundantly
Posted by GitBox <gi...@apache.org>.
vinothchandar commented on a change in pull request #1317: [HUDI-605] Avoid calculating the size of schema redundantly
URL: https://github.com/apache/incubator-hudi/pull/1317#discussion_r376894610
##########
File path: hudi-common/src/main/java/org/apache/hudi/common/util/collection/DiskBasedMap.java
##########
@@ -223,8 +223,8 @@ private R get(ValueMetadata entry) {
private synchronized R put(T key, R value, boolean flush) {
try {
byte[] val = SerializationUtils.serialize(value);
- Integer valueSize = val.length;
- Long timestamp = System.currentTimeMillis();
+ int valueSize = val.length;
Review comment:
why change these?
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-hudi] leesf merged pull request #1317: [HUDI-605] Avoid
calculating the size of schema redundantly
Posted by GitBox <gi...@apache.org>.
leesf merged pull request #1317: [HUDI-605] Avoid calculating the size of schema redundantly
URL: https://github.com/apache/incubator-hudi/pull/1317
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-hudi] lamber-ken commented on a change in pull request
#1317: [HUDI-605] Avoid calculating the size of schema redundantly
Posted by GitBox <gi...@apache.org>.
lamber-ken commented on a change in pull request #1317: [HUDI-605] Avoid calculating the size of schema redundantly
URL: https://github.com/apache/incubator-hudi/pull/1317#discussion_r376898473
##########
File path: hudi-common/src/main/java/org/apache/hudi/common/util/collection/DiskBasedMap.java
##########
@@ -223,8 +223,8 @@ private R get(ValueMetadata entry) {
private synchronized R put(T key, R value, boolean flush) {
try {
byte[] val = SerializationUtils.serialize(value);
- Integer valueSize = val.length;
- Long timestamp = System.currentTimeMillis();
+ int valueSize = val.length;
Review comment:
Will revert it if this against contribution guide. 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
With regards,
Apache Git Services
[GitHub] [incubator-hudi] lamber-ken commented on a change in pull request
#1317: [HUDI-605] Avoid calculating the size of schema redundantly
Posted by GitBox <gi...@apache.org>.
lamber-ken commented on a change in pull request #1317: [HUDI-605] Avoid calculating the size of schema redundantly
URL: https://github.com/apache/incubator-hudi/pull/1317#discussion_r377731900
##########
File path: hudi-common/src/main/java/org/apache/hudi/common/util/HoodieRecordSizeEstimator.java
##########
@@ -49,8 +48,9 @@ public long sizeEstimate(HoodieRecord<T> hoodieRecord) {
// note the sizes and differences. A correct estimation in such cases is handled in
/** {@link ExternalSpillableMap} **/
long sizeOfRecord = ObjectSizeCalculator.getObjectSize(hoodieRecord);
- long sizeOfSchema = ObjectSizeCalculator.getObjectSize(schema);
- LOG.info("SizeOfRecord => " + sizeOfRecord + " SizeOfSchema => " + sizeOfSchema);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("SizeOfRecord => " + sizeOfRecord + " SizeOfSchema => " + sizeOfSchema);
+ }
Review comment:
Thanks for reviewing this. Use `LOG.info` will print each time when you put an element, `LOG.debug` is better.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-hudi] lamber-ken commented on a change in pull request
#1317: [HUDI-605] Avoid calculating the size of schema redundantly
Posted by GitBox <gi...@apache.org>.
lamber-ken commented on a change in pull request #1317: [HUDI-605] Avoid calculating the size of schema redundantly
URL: https://github.com/apache/incubator-hudi/pull/1317#discussion_r377734447
##########
File path: hudi-common/src/main/java/org/apache/hudi/common/util/HoodieRecordSizeEstimator.java
##########
@@ -49,8 +48,9 @@ public long sizeEstimate(HoodieRecord<T> hoodieRecord) {
// note the sizes and differences. A correct estimation in such cases is handled in
/** {@link ExternalSpillableMap} **/
long sizeOfRecord = ObjectSizeCalculator.getObjectSize(hoodieRecord);
- long sizeOfSchema = ObjectSizeCalculator.getObjectSize(schema);
- LOG.info("SizeOfRecord => " + sizeOfRecord + " SizeOfSchema => " + sizeOfSchema);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("SizeOfRecord => " + sizeOfRecord + " SizeOfSchema => " + sizeOfSchema);
+ }
Review comment:
More, HoodieRecordSizeEstimator is mainly used in `ExternalSpillableMap`, `ExternalSpillableMap#put` has logged it.
```
if (shouldEstimatePayloadSize && estimatedPayloadSize == 0) {
// At first, use the sizeEstimate of a record being inserted into the spillable map.
// Note, the converter may over estimate the size of a record in the JVM
this.estimatedPayloadSize = keySizeEstimator.sizeEstimate(key) + valueSizeEstimator.sizeEstimate(value);
LOG.info("Estimated Payload size => " + estimatedPayloadSize);
}
```
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-hudi] lamber-ken commented on a change in pull request
#1317: [HUDI-605] Avoid calculating the size of schema redundantly
Posted by GitBox <gi...@apache.org>.
lamber-ken commented on a change in pull request #1317: [HUDI-605] Avoid calculating the size of schema redundantly
URL: https://github.com/apache/incubator-hudi/pull/1317#discussion_r376899375
##########
File path: hudi-common/src/main/java/org/apache/hudi/common/util/collection/DiskBasedMap.java
##########
@@ -223,8 +223,8 @@ private R get(ValueMetadata entry) {
private synchronized R put(T key, R value, boolean flush) {
try {
byte[] val = SerializationUtils.serialize(value);
- Integer valueSize = val.length;
- Long timestamp = System.currentTimeMillis();
+ int valueSize = val.length;
Review comment:
Done.
----------------------------------------------------------------
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
With regards,
Apache Git Services