Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7736 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Optimization of template compilation time check

Reported by: alex Assigned to: core
Priority: normal Milestone: 1.x
Component: ActionPack Version: edge
Severity: normal Keywords: optimization symlink template compilation
Cc:

Description

Current check uses File.mtime, then a check for symlink?, in which case it uses File.lstat:

        compile_time < File.mtime(file_name) ||
          (File.symlink?(file_name) && (compile_time < File.lstat(file_name).mtime))

This incurs two system calls at best, and three system calls if the file is indeed a symlink: mtime calls fstat(), whereas File.symlink? uses lstat(), making the duplicate call to lstat() unnecessary.

This patch reverses the logic so that lstat() is always called once; if the file is a symlink (as indicated in the stat mode flags), one additional stat() call is made to find the modification time of the endpoint. This optimizes for the common case where a template is a regular file.

The patch also aliases the compilation time lookup to avoid a duplicate hash access.

Attachments

action_view_compile_time_check.patch (1.4 kB) - added by alex on 03/06/07 14:40:37.
Compilation check patch

Change History

03/06/07 14:40:37 changed by alex

  • attachment action_view_compile_time_check.patch added.

Compilation check patch

03/06/07 20:23:07 changed by bitsweat

  • component changed from ActiveRecord to ActionPack.
  • summary changed from [PATCH] Optimization of template compilation time check to [PPATCH] Optimization of template compilation time check.

looks good..

05/27/07 18:33:44 changed by josh

  • summary changed from [PPATCH] Optimization of template compilation time check to [PATCH] Optimization of template compilation time check.

05/27/07 19:16:13 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [6871]) Reduce file stat calls when checking for template changes. Closes #7736.