Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4982B200CC2 for ; Wed, 5 Jul 2017 13:04:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 427B4162F3A; Wed, 5 Jul 2017 11:04:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 874EC162F38 for ; Wed, 5 Jul 2017 13:04:04 +0200 (CEST) Received: (qmail 27080 invoked by uid 500); 5 Jul 2017 11:04:03 -0000 Mailing-List: contact jira-help@kafka.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jira@kafka.apache.org Delivered-To: mailing list jira@kafka.apache.org Received: (qmail 27069 invoked by uid 99); 5 Jul 2017 11:04:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Jul 2017 11:04:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4DDA51813D7 for ; Wed, 5 Jul 2017 11:04:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id jhWmsAwW7gNP for ; Wed, 5 Jul 2017 11:04:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 2C6465FB43 for ; Wed, 5 Jul 2017 11:04:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 51A0CE0069 for ; Wed, 5 Jul 2017 11:04:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 10F2324604 for ; Wed, 5 Jul 2017 11:04:00 +0000 (UTC) Date: Wed, 5 Jul 2017 11:04:00 +0000 (UTC) From: "Neil Avery (JIRA)" To: jira@kafka.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (KAFKA-5515) Consider removing date formatting from Segments class MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 05 Jul 2017 11:04:05 -0000 [ https://issues.apache.org/jira/browse/KAFKA-5515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16068546#comment-16068546 ] Neil Avery edited comment on KAFKA-5515 at 7/5/17 11:03 AM: ------------------------------------------------------------ *Investigation:* Taking a look at the use shows SimpleDateFormat (SFD) is used for *parsing* Segment file names during initialisation, and *format*ting during runtime. I presume the suggested problem lies in the formatting. *Micro benchmark SDF* Formatting 1,000,000 items takes 250ms once hotspotting has kicked in. Per/M items (ms): [707, 572, 543, 591, 546.0, 545.0, 363.0, 250 etc] Parsing is slow - 2500ms per 1,000,000 items Commons-lang3-FastDateFormat is available in the project but not as a dependency on this particular module. FDF micro-bench starts at 400ms/million then gets down to 350ms (not very convincing). Calendar usage sucks performance and there is a degree of caching inside both of the impls. Looking at this in a different way "Segments" is a time-series slice/bucketing function to group/allocate/lookup segments etc. I've knocked together a simple math alternative that breaks into time-slice where all months/years are equals size i.e. not using a calendar - you get an approximate idea of performance: 150-200ms without hotspotting. The problem is that a real-calendar is still used upon initialisation extract segment-ids - there will be inconsistencies and likely breakage. *Best performance* The best alternative would be to ditch calendars for parsing and formatting and to trunc/floor unix time to minutes/hours etc (at the cost a segment-filename readability). I'm not sure if there will be operational upgrade paths etc in order to make the change seamless. was (Author: neil.avery): I've taken a look at dropping SimpleDateFormat and replacing it with commons-lang3-FastDateFormat (available in project but not a dependency on this module). Microbenchmarking diffs show SDF starts at 800ms/million then hotspots down to 250ms. Interestingly FDF starts at 400ms/million then gets down to 350ms (not very convincing). Calendar usage sucks performance and there is a degree of caching inside both of the impls. Looking at this in a different way "Segments" is a time-series slice/bucketing function to group/allocate/lookup segments etc. Does a real world calendar matter? - I've knocked together a simple math alternative that break into time-slice where all months/years are equals size. The time formatting is identical but day/month will be incorrect as a result of no calendar. This gets down to 150ms pretty much straight away. (still using SDF is still used for parsing). All tests pass, system runs fine etc - but I'm not sure of the gravity of this as a possible change - will it break things - any advice or feedback? > Consider removing date formatting from Segments class > ----------------------------------------------------- > > Key: KAFKA-5515 > URL: https://issues.apache.org/jira/browse/KAFKA-5515 > Project: Kafka > Issue Type: Improvement > Components: streams > Reporter: Bill Bejeck > Assignee: Neil Avery > Labels: performance > > Currently the {{Segments}} class uses a date when calculating the segment id and uses {{SimpleDateFormat}} for formatting the segment id. However this is a high volume code path and creating a new {{SimpleDateFormat}} and formatting each segment id is expensive. We should look into removing the date from the segment id or at a minimum use a faster alternative to {{SimpleDateFormat}}. We should also consider keeping a lookup of existing segments to avoid as many string operations as possible. -- This message was sent by Atlassian JIRA (v6.4.14#64029)