#45 Adjust function signature so caching has effect.
Merged 7 years ago by maxamillion. Opened 7 years ago by ralph.
ralph/fedora-websites slow-slow  into  master

file modified
+4 -1
@@ -187,7 +187,10 @@ 

          # This is cached

          if collect_atomic_vars is not None:

              # Go get two-week-atomic release info from datagrepper

-             collected_atomic_vars = collect_atomic_vars(globalvar.release)

+             collected_atomic_vars = collect_atomic_vars(

+                 globalvar.release['curr_id'],

+                 globalvar.release['next_id'],

+             )

              # Overwrite the handwritten vars with ones from datagrepper

              for key1, entry in collected_atomic_vars.items():

                  for key2, value in entry.items():

@@ -101,30 +101,30 @@ 

                  yield message

  

  

- def make_templates(release):

+ def make_templates(curr_id, next_id):

      return [

          # As things stand now, we only do two-week-atomic stuff for the current

          # stable release.

-         (release['curr_id'], '', ''),

+         (curr_id, '', ''),

  

          # If we ever move to doing pre-release versions as well, just uncomment

          # the following line and it should all work. We leave it commented out

          # now because querying datagrepper for pre-release results that are not

          # there is much more slow than querying for something that exists.

-         #(release['next_id'], 'pre_cloud_', 'pre_'),

+         #(next_id, 'pre_cloud_', 'pre_'),

      ]

  

  

  # We cache this guy on disk so we don't hit datagrepper over and over.

  @cache.cache_on_arguments()

- def collect(release):

+ def collect(curr_id, next_id):

      results = collections.defaultdict(dict)

  

      # This is the information needed to provide "latest" download targets that

      # redirect to the actual mirrormanager url via htpasswd file

      results['release']['redir_map'] = collections.defaultdict(dict)

  

-     for idx, composedate_prefix, iso_size_prefix in make_templates(release):

+     for idx, composedate_prefix, iso_size_prefix in make_templates(curr_id, next_id):

  

          log.info("Looking for latest atomic release for %s" % idx)

          # Get the *latest* atomic release information.
@@ -201,7 +201,8 @@ 

      """

  

      results = collections.defaultdict(dict)

-     for idx, composedate_prefix, iso_size_prefix in make_templates(release):

+     templates = make_templates(release['curr_id'], release['next_id'])

+     for idx, composedate_prefix, iso_size_prefix in templates:

          two_weeks_ago = datetime.now(UTC) - timedelta(days=14)

          timestamp = release[composedate_prefix + 'atomic_ts']

          latest = datetime.fromtimestamp(timestamp, UTC)

We wrapped that atomic collect(release) method in a cache to make
things fast, but it never worked (it seems). We modify that release
dict on every pass, so its different every time which then always
bypasses the cache.

In this change, we stop passing that whole dict of releases through,
since we only need a few small values. We pass those instead now.
Caching works, and the site build time is faster.

Pull-Request has been merged by maxamillion

7 years ago