hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Work logged] (HDDS-1624) Refactor operations inside the bucket lock in OM key write.
Date Tue, 04 Jun 2019 06:13:00 GMT

     [ https://issues.apache.org/jira/browse/HDDS-1624?focusedWorklogId=253559&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-253559
]

ASF GitHub Bot logged work on HDDS-1624:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Jun/19 06:12
            Start Date: 04/Jun/19 06:12
    Worklog Time Spent: 10m 
      Work Description: anuengineer commented on pull request #882: HDDS-1624 : Refactor operations
inside the bucket lock in OM key write.
URL: https://github.com/apache/hadoop/pull/882#discussion_r290136803
 
 

 ##########
 File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/UniqueId.java
 ##########
 @@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.hadoop.utils;
+
+import org.apache.hadoop.hdds.HddsUtils;
+
+/**
+ * This class uses system current time milliseconds to generate unique id.
+ */
+public final class UniqueId {
+    /*
+     * When we represent time in milliseconds using 'long' data type,
+     * the LSB bits are used. Currently we are only using 44 bits (LSB),
+     * 20 bits (MSB) are not used.
+     * We will exhaust this 44 bits only when we are in year 2525,
+     * until then we can safely use this 20 bits (MSB) for offset to generate
+     * unique id within millisecond.
+     *
+     * Year        : Mon Dec 31 18:49:04 IST 2525
+     * TimeInMillis: 17545641544247
+     * Binary Representation:
+     *   MSB (20 bits): 0000 0000 0000 0000 0000
+     *   LSB (44 bits): 1111 1111 0101 0010 1001 1011 1011 0100 1010 0011 0111
+     *
+     * We have 20 bits to run counter, we should exclude the first bit (MSB)
+     * as we don't want to deal with negative values.
+     * To be on safer side we will use 'short' data type which is of length
+     * 16 bits and will give us 65,536 values for offset.
+     *
+     */
+
+  private static volatile short offset = 0;
+
+  /**
+   * Private constructor so that no one can instantiate this class.
+   */
+  private UniqueId() {}
+
+  /**
+   * Calculate and returns next unique id based on System#currentTimeMillis.
+   *
+   * @return unique long value
+   */
+  public static synchronized long next() {
+    long utcTime = HddsUtils.getUtcTime();
+    if ((utcTime & 0xFFFF000000000000L) == 0) {
+      return utcTime << Short.SIZE | (offset++ & 0x0000FFFF);
+    }
+    throw new RuntimeException("Got invalid UTC time," +
+        " cannot generate unique Id. UTC Time: " + utcTime);
 
 Review comment:
   I think this line is a No-op and will never get thrown.
 
----------------------------------------------------------------
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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 253559)

> Refactor operations inside the bucket lock in OM key write.
> -----------------------------------------------------------
>
>                 Key: HDDS-1624
>                 URL: https://issues.apache.org/jira/browse/HDDS-1624
>             Project: Hadoop Distributed Data Store
>          Issue Type: Bug
>          Components: Ozone Manager
>            Reporter: Aravindan Vijayan
>            Assignee: Aravindan Vijayan
>            Priority: Critical
>              Labels: pull-request-available
>             Fix For: 0.5.0
>
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> There are a few steps that are done inside the OM bucket lock that are lock invariant
and can be done outside the lock. This patch refactors those steps. It also adds an isExist
API in the metadata store so that we dont need to deserialize the byte[] to Object while doing
a simple _table.get(key) != null_ check. 
> On applying the patch, the OM + SCM (With dummy datanodes) write performance improves
by around 3 - 6x based on number of existing keys in the OM RocksDB. 
> Thanks to [~nandakumar131] who helped with this patch. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org


Mime
View raw message