From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70B42178CF1 for ; Mon, 29 Apr 2024 20:44:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714423467; cv=none; b=S5QQuz7uvMU2UFpfcGC8AfNu5tZW16IHuZkHufWO4ezjXG2FxyaW9pTzDIZEZZIs/V3FiJy5kUZ53zlYFuJAtYbYTqOxcDi5ET2RKfZCQdDz5/86jD8kei83qs+y/Gv8fR0LWzBDvg+XKfSpb7ZnNFXuFE7uj5sRITPYuDTLbvI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714423467; c=relaxed/simple; bh=5VX68u/Li1sjhd8gSunrRWSJN9qD+2Wq4hjNMX/awMs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q+qzRFKqX3MspymHZcJs+67yPKg30CiAf74fF9QFEBJZQUb+mkaLAvOGfK0ZhCZ+9m9yvwp7kAW0GTrbcQyCNdaecdFqWxfo5UUThPZSSo7jIVcjoQrVSPnjzm37aP/wFI2QqMXdGf0dLXWOzRanovjJCas9Bkgn6MdbCO4HTSk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com; spf=none smtp.mailfrom=ttaylorr.com; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b=TDPRkWiy; arc=none smtp.client-ip=209.85.222.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="TDPRkWiy" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-78ecd752a7cso358205785a.0 for ; Mon, 29 Apr 2024 13:44:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1714423464; x=1715028264; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8flAK7JhzakD+2lsKZhmDULy09W5z3KJEkpqDGr3jLE=; b=TDPRkWiy1j4XPlCxnS/pYM79097TGD2aBiOtlKk4UfJqAsNizZWeXloSyE0qx7KljD HUI0ZURE9fT/8TdFhrSWcu/gZy2d+Y6zMWY49ZMa7eV+CeglLo+xjxsQb95EyCX/WFhy 0JMTb7kJzOBVSx8U1+evjBz+cArbjEwaXDqDf1Z+hXvxW8yH2vDJW7GOy2FDPovH048+ P/ylJO2yr9TkS9RFIhhG9H5J1eZyhRFugWNPotPB2EVFMuLplwp/J+USZP7BP0JJDiAH xQlR0o/lKOMTlJHf6UvZtlxWJCEWA+u83hGIG3h2Lx3bdq/r6KM7w+6Ak9qVm+AW9Opr 3EAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714423464; x=1715028264; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8flAK7JhzakD+2lsKZhmDULy09W5z3KJEkpqDGr3jLE=; b=ZXMPEC8ftyv0y6HzEjrWaQfOcE+B/bEbk0pRXR5kNbQckSOD4/evSZ3ybvyYF8mOAG PEyOrj7dyH25vEKxk3mSw4Q2H+wDnpi43yp+YTN4frWiZAIYGN5t7nqVE5sjBvz7noNu 4OcIXxzcEYDsLtHswnMBQ0slYrktQ/58G6xin0vJCxsAJGCoYRYq6h4ohcjYgdXu9oZl NJQS/P7P/viyKw6Il9tS/lP05WGJFJPbKHnjA4YI0nbOx9cGyQijRKLq8MmxTOX9Tx2P LWMVgT91QlTOOKvL6/ognKccg6TgCDRi+VPsBJ6gIkO7cZTkiAZ5ZMuVuRzfDbeRoRdC MW5Q== X-Gm-Message-State: AOJu0YzFRRHyPTHp6b4btl9vWA627IwRIWxAFqsUoJ5ZXiyocP8UjA5L 0KFNWcb4SpNs9SgGFZwraPaB1I9jIsPKQWQnaJKXoSh6Yo8VuBdgDlmW12zj61rB6zmNMrrMji3 HTBY= X-Google-Smtp-Source: AGHT+IH17Vg8Yxokefx9W1EU//H0k6JwkCYHf/PcX4QyYQGMifvpgTaYZh0jpNYC/OOhMZ6oi7+3Nw== X-Received: by 2002:a05:620a:51cf:b0:790:9625:d6d9 with SMTP id cx15-20020a05620a51cf00b007909625d6d9mr11957729qkb.35.1714423464481; Mon, 29 Apr 2024 13:44:24 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id d15-20020a05620a158f00b00790f882fa89sm1015804qkk.33.2024.04.29.13.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 13:44:23 -0700 (PDT) Date: Mon, 29 Apr 2024 16:44:22 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Elijah Newren , Junio C Hamano Subject: [PATCH v2 21/23] ewah: `bitmap_equals_ewah()` Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Prepare to reuse existing pseudo-merge bitmaps by implementing a `bitmap_equals_ewah()` helper. This helper will be used to see if a raw bitmap (containing the set of parents for some pseudo-merge) is equal to any existing pseudo-merge's commits bitmap (which are stored as EWAH-compressed bitmaps on disk). Signed-off-by: Taylor Blau --- ewah/bitmap.c | 19 +++++++++++++++++++ ewah/ewok.h | 1 + 2 files changed, 20 insertions(+) diff --git a/ewah/bitmap.c b/ewah/bitmap.c index dc2ca190f12..55928dada86 100644 --- a/ewah/bitmap.c +++ b/ewah/bitmap.c @@ -261,6 +261,25 @@ int bitmap_equals(struct bitmap *self, struct bitmap *other) return 1; } +int bitmap_equals_ewah(struct bitmap *self, struct ewah_bitmap *other) +{ + struct ewah_iterator it; + eword_t word; + size_t i = 0; + + ewah_iterator_init(&it, other); + + while (ewah_iterator_next(&word, &it)) + if (word != (i < self->word_alloc ? self->words[i++] : 0)) + return 0; + + for (; i < self->word_alloc; i++) + if (self->words[i]) + return 0; + + return 1; +} + int bitmap_is_subset(struct bitmap *self, struct bitmap *other) { size_t common_size, i; diff --git a/ewah/ewok.h b/ewah/ewok.h index 7074a6347b7..5e357e24933 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -179,6 +179,7 @@ void bitmap_unset(struct bitmap *self, size_t pos); int bitmap_get(struct bitmap *self, size_t pos); void bitmap_free(struct bitmap *self); int bitmap_equals(struct bitmap *self, struct bitmap *other); +int bitmap_equals_ewah(struct bitmap *self, struct ewah_bitmap *other); /* * Both `bitmap_is_subset()` and `ewah_bitmap_is_subset()` return 1 if the set -- 2.45.0.23.gc6f94b99219