You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by amansinha100 <gi...@git.apache.org> on 2016/08/16 01:47:01 UTC

[GitHub] drill pull request #569: DRILL-4846: Fix a few performance issues for metada...

GitHub user amansinha100 opened a pull request:

    https://github.com/apache/drill/pull/569

    DRILL-4846: Fix a few performance issues for metadata access:

     - Create a MetadataContext that can be shared among multiple invocations of the Metadata APIs.
     - Check directory modification time only if not previously checked.
     - Remove a redundant call for metadata read.
     - Added more logging.
     - Consolidate couple of metadata methods.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/amansinha100/incubator-drill DRILL-4846

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/drill/pull/569.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #569
    
----
commit 1f8ae8f6b88b96b5861b81a2468d8f99d3f8b1c2
Author: Aman Sinha <as...@maprtech.com>
Date:   2016-08-03T16:00:51Z

    DRILL-4846: Fix a few performance issues for metadata access:
    
     - Create a MetadataContext that can be shared among multiple invocations of the Metadata APIs.
     - Check directory modification time only if not previously checked.
     - Remove a redundant call for metadata read.
     - Added more logging.
     - Consolidate couple of metadata methods.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill pull request #569: DRILL-4846: Fix a few performance issues for metada...

Posted by amansinha100 <gi...@git.apache.org>.
Github user amansinha100 commented on a diff in the pull request:

    https://github.com/apache/drill/pull/569#discussion_r75058437
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java ---
    @@ -470,41 +483,38 @@ private ParquetTableMetadataBase readBlockMeta(String path) throws IOException {
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         FSDataInputStream is = fs.open(p);
     
    -    ParquetTableMetadataBase parquetTableMetadata = mapper.readValue(is, ParquetTableMetadataBase.class);
    -    logger.info("Took {} ms to read metadata from cache file", timer.elapsed(TimeUnit.MILLISECONDS));
    -    timer.stop();
    -    if (tableModified(parquetTableMetadata, p)) {
    -      parquetTableMetadata =
    -          (createMetaFilesRecursively(Path.getPathWithoutSchemeAndAuthority(p.getParent()).toString())).getLeft();
    -    }
    -    return parquetTableMetadata;
    -  }
    -
    -  private ParquetTableMetadataDirs readMetadataDirs(String path) throws IOException {
    -    Stopwatch timer = Stopwatch.createStarted();
    -    Path p = new Path(path);
    -    ObjectMapper mapper = new ObjectMapper();
    -
    -    final SimpleModule serialModule = new SimpleModule();
    -    serialModule.addDeserializer(SchemaPath.class, new SchemaPath.De());
    -
    -    AfterburnerModule module = new AfterburnerModule();
    -    module.setUseOptimizedBeanDeserializer(true);
    +    boolean alreadyCheckedModification = false;
    +    boolean newMetadata = false;
     
    -    mapper.registerModule(serialModule);
    -    mapper.registerModule(module);
    -    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    -    FSDataInputStream is = fs.open(p);
    +    if (metaContext != null) {
    +      alreadyCheckedModification = metaContext.getStatus(parentDir.toString());
    +    }
     
    -    ParquetTableMetadataDirs parquetTableMetadataDirs = mapper.readValue(is, ParquetTableMetadataDirs.class);
    -    logger.info("Took {} ms to read directories from directory cache file", timer.elapsed(TimeUnit.MILLISECONDS));
    -    timer.stop();
    +    if (dirsOnly) {
    +      parquetTableMetadataDirs = mapper.readValue(is, ParquetTableMetadataDirs.class);
    +      logger.info("Took {} ms to read directories from directory cache file", timer.elapsed(TimeUnit.MILLISECONDS));
    +      timer.stop();
    +      if (!alreadyCheckedModification && tableModified(parquetTableMetadataDirs.getDirectories(), p, parentDir, metaContext)) {
    --- End diff --
    
    While it is true that they are separate files, the REFRESH command would have created them within a small time interval, so there is an assumption that their modifications times are very close (unless a subdirectory is modified of course..but in that case, we will call metaContext.clear() to invalidate the cached information).  


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill pull request #569: DRILL-4846: Fix a few performance issues for metada...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/drill/pull/569


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill pull request #569: DRILL-4846: Fix a few performance issues for metada...

Posted by jinfengni <gi...@git.apache.org>.
Github user jinfengni commented on a diff in the pull request:

    https://github.com/apache/drill/pull/569#discussion_r75037246
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java ---
    @@ -470,41 +483,38 @@ private ParquetTableMetadataBase readBlockMeta(String path) throws IOException {
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         FSDataInputStream is = fs.open(p);
     
    -    ParquetTableMetadataBase parquetTableMetadata = mapper.readValue(is, ParquetTableMetadataBase.class);
    -    logger.info("Took {} ms to read metadata from cache file", timer.elapsed(TimeUnit.MILLISECONDS));
    -    timer.stop();
    -    if (tableModified(parquetTableMetadata, p)) {
    -      parquetTableMetadata =
    -          (createMetaFilesRecursively(Path.getPathWithoutSchemeAndAuthority(p.getParent()).toString())).getLeft();
    -    }
    -    return parquetTableMetadata;
    -  }
    -
    -  private ParquetTableMetadataDirs readMetadataDirs(String path) throws IOException {
    -    Stopwatch timer = Stopwatch.createStarted();
    -    Path p = new Path(path);
    -    ObjectMapper mapper = new ObjectMapper();
    -
    -    final SimpleModule serialModule = new SimpleModule();
    -    serialModule.addDeserializer(SchemaPath.class, new SchemaPath.De());
    -
    -    AfterburnerModule module = new AfterburnerModule();
    -    module.setUseOptimizedBeanDeserializer(true);
    +    boolean alreadyCheckedModification = false;
    +    boolean newMetadata = false;
     
    -    mapper.registerModule(serialModule);
    -    mapper.registerModule(module);
    -    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    -    FSDataInputStream is = fs.open(p);
    +    if (metaContext != null) {
    +      alreadyCheckedModification = metaContext.getStatus(parentDir.toString());
    +    }
     
    -    ParquetTableMetadataDirs parquetTableMetadataDirs = mapper.readValue(is, ParquetTableMetadataDirs.class);
    -    logger.info("Took {} ms to read directories from directory cache file", timer.elapsed(TimeUnit.MILLISECONDS));
    -    timer.stop();
    +    if (dirsOnly) {
    +      parquetTableMetadataDirs = mapper.readValue(is, ParquetTableMetadataDirs.class);
    +      logger.info("Took {} ms to read directories from directory cache file", timer.elapsed(TimeUnit.MILLISECONDS));
    +      timer.stop();
    +      if (!alreadyCheckedModification && tableModified(parquetTableMetadataDirs.getDirectories(), p, parentDir, metaContext)) {
    --- End diff --
    
    tableModified compares the directory's modification time against metadata cache file's modification time. 
    
    In 1st call,  the metadata file is .drill.parquet_metadata_directories. And we keep track of the directory compared. In 2nd call, supposedly we should compare .drill.parquet_metadata against directory. But MetaContext keeps track the comparison based on .drill.parquet_metadata_directories.  Will this cause any potential problem, since .drill.parquet_metadata and .drill.parquet_metadata_directories are different files?
     
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill pull request #569: DRILL-4846: Fix a few performance issues for metada...

Posted by jinfengni <gi...@git.apache.org>.
Github user jinfengni commented on a diff in the pull request:

    https://github.com/apache/drill/pull/569#discussion_r75064413
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java ---
    @@ -470,41 +483,38 @@ private ParquetTableMetadataBase readBlockMeta(String path) throws IOException {
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         FSDataInputStream is = fs.open(p);
     
    -    ParquetTableMetadataBase parquetTableMetadata = mapper.readValue(is, ParquetTableMetadataBase.class);
    -    logger.info("Took {} ms to read metadata from cache file", timer.elapsed(TimeUnit.MILLISECONDS));
    -    timer.stop();
    -    if (tableModified(parquetTableMetadata, p)) {
    -      parquetTableMetadata =
    -          (createMetaFilesRecursively(Path.getPathWithoutSchemeAndAuthority(p.getParent()).toString())).getLeft();
    -    }
    -    return parquetTableMetadata;
    -  }
    -
    -  private ParquetTableMetadataDirs readMetadataDirs(String path) throws IOException {
    -    Stopwatch timer = Stopwatch.createStarted();
    -    Path p = new Path(path);
    -    ObjectMapper mapper = new ObjectMapper();
    -
    -    final SimpleModule serialModule = new SimpleModule();
    -    serialModule.addDeserializer(SchemaPath.class, new SchemaPath.De());
    -
    -    AfterburnerModule module = new AfterburnerModule();
    -    module.setUseOptimizedBeanDeserializer(true);
    +    boolean alreadyCheckedModification = false;
    +    boolean newMetadata = false;
     
    -    mapper.registerModule(serialModule);
    -    mapper.registerModule(module);
    -    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    -    FSDataInputStream is = fs.open(p);
    +    if (metaContext != null) {
    +      alreadyCheckedModification = metaContext.getStatus(parentDir.toString());
    +    }
     
    -    ParquetTableMetadataDirs parquetTableMetadataDirs = mapper.readValue(is, ParquetTableMetadataDirs.class);
    -    logger.info("Took {} ms to read directories from directory cache file", timer.elapsed(TimeUnit.MILLISECONDS));
    -    timer.stop();
    +    if (dirsOnly) {
    +      parquetTableMetadataDirs = mapper.readValue(is, ParquetTableMetadataDirs.class);
    +      logger.info("Took {} ms to read directories from directory cache file", timer.elapsed(TimeUnit.MILLISECONDS));
    +      timer.stop();
    +      if (!alreadyCheckedModification && tableModified(parquetTableMetadataDirs.getDirectories(), p, parentDir, metaContext)) {
    --- End diff --
    
    Make sense. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill issue #569: DRILL-4846: Fix a few performance issues for metadata acce...

Posted by jinfengni <gi...@git.apache.org>.
Github user jinfengni commented on the issue:

    https://github.com/apache/drill/pull/569
  
    +1
    
    LGTM


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---