Commit 02f0edc3 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Don't quantize build timestamps on official builds

Official builds - the PDBs and the PE files - often get published to a
symbol server. For PE files the path name in the symbol server is:

    "%s\%08X%s\%s" % (peName, timeStamp, imageSize, peName)

Since the peName for a particular DLL/EXE never changes and since the
size often doesn't change this means that the timeStamp is the only
differentiator between nearby builds. With the strategy of setting the
build timestamp to 5 am of the last commit time it is easy to get
a build that overwrites the previous build on the symbol server. This
happened when build 75.0.3770.143 overwrote all of the PE files from
build 75.0.3770.142, which complicated the investigation of (restricted
view, sorry) crbug.com/964273. This probably happened many other times.
The PDB files were never overwritten which is why this was not noticed
earlier.

When the 5 am quantization was added we were using the current time for
the build timestamps. Now that we are using the last commit time it is
less important to quantize to 5 am so this change removes that
quantization, for official builds only.

An increased number of days where we do multiple builds of one channel
means that this issue is hit more frequently than when the
quantization was initially added.

Bug: 993509
Change-Id: Ibfac95569b713ede056d3ff070db0c05b4a38c77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1754527Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#687349}
parent 5b37a8c8
...@@ -56,36 +56,43 @@ def GetFirstSundayOfMonth(year, month): ...@@ -56,36 +56,43 @@ def GetFirstSundayOfMonth(year, month):
return [date_day[0] for date_day in weeks[0] if date_day[1] == 6][0] return [date_day[0] for date_day in weeks[0] if date_day[1] == 6][0]
def GetBuildDate(build_type, utc_now): def GetUnofficialBuildDate(build_date):
"""Gets the approximate build date given the specific build type. """Gets the approximate build date given the specific build type.
>>> GetBuildDate('default', datetime.datetime(2016, 2, 6, 1, 2, 3)) >>> GetUnofficialBuildDate(datetime.datetime(2016, 2, 6, 1, 2, 3))
datetime.datetime(2016, 1, 3, 1, 2, 3) datetime.datetime(2016, 1, 3, 5, 0)
>>> GetBuildDate('default', datetime.datetime(2016, 2, 7, 5)) >>> GetUnofficialBuildDate(datetime.datetime(2016, 2, 7, 5))
datetime.datetime(2016, 2, 7, 5, 0) datetime.datetime(2016, 2, 7, 5, 0)
>>> GetBuildDate('default', datetime.datetime(2016, 2, 8, 5)) >>> GetUnofficialBuildDate(datetime.datetime(2016, 2, 8, 5))
datetime.datetime(2016, 2, 7, 5, 0) datetime.datetime(2016, 2, 7, 5, 0)
>>> GetBuildDate('official', datetime.datetime(2016, 2, 8, 5))
datetime.datetime(2016, 2, 8, 5, 0)
""" """
day = utc_now.day
month = utc_now.month if build_date.hour < 5:
year = utc_now.year # The time is locked at 5:00 am in UTC to cause the build cache
if build_type != 'official': # invalidation to not happen exactly at midnight. Use the same calculation
first_sunday = GetFirstSundayOfMonth(year, month) # as the day before.
# If our build is after the first Sunday, we've already refreshed our build # See //base/build_time.cc.
# cache on a quiet day, so just use that day. build_date = build_date - datetime.timedelta(days=1)
# Otherwise, take the first Sunday of the previous month. build_date = datetime.datetime(build_date.year, build_date.month,
if day >= first_sunday: build_date.day, 5, 0, 0)
day = first_sunday
else: day = build_date.day
month -= 1 month = build_date.month
if month == 0: year = build_date.year
month = 12 first_sunday = GetFirstSundayOfMonth(year, month)
year -= 1 # If our build is after the first Sunday, we've already refreshed our build
day = GetFirstSundayOfMonth(year, month) # cache on a quiet day, so just use that day.
# Otherwise, take the first Sunday of the previous month.
if day >= first_sunday:
day = first_sunday
else:
month -= 1
if month == 0:
month = 12
year -= 1
day = GetFirstSundayOfMonth(year, month)
return datetime.datetime( return datetime.datetime(
year, month, day, utc_now.hour, utc_now.minute, utc_now.second) year, month, day, build_date.hour, build_date.minute, build_date.second)
def main(): def main():
...@@ -104,16 +111,14 @@ def main(): ...@@ -104,16 +111,14 @@ def main():
# use_dummy_lastchange is set. # use_dummy_lastchange is set.
lastchange_file = os.path.join(THIS_DIR, 'util', 'LASTCHANGE.committime') lastchange_file = os.path.join(THIS_DIR, 'util', 'LASTCHANGE.committime')
last_commit_timestamp = int(open(lastchange_file).read()) last_commit_timestamp = int(open(lastchange_file).read())
now = datetime.datetime.utcfromtimestamp(last_commit_timestamp) build_date = datetime.datetime.utcfromtimestamp(last_commit_timestamp)
if now.hour < 5: # For official builds we want full fidelity time stamps because official
# The time is locked at 5:00 am in UTC to cause the build cache # builds are typically added to symbol servers and Windows symbol servers
# invalidation to not happen exactly at midnight. Use the same calculation # use the link timestamp as the prime differentiator, but for unofficial
# as the day before. # builds we do lots of quantization to avoid churn.
# See //base/build_time.cc. if args.build_type != 'official':
now = now - datetime.timedelta(days=1) build_date = GetUnofficialBuildDate(build_date)
now = datetime.datetime(now.year, now.month, now.day, 5, 0, 0)
build_date = GetBuildDate(args.build_type, now)
print(int(calendar.timegm(build_date.utctimetuple()))) print(int(calendar.timegm(build_date.utctimetuple())))
return 0 return 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment