view tests/test-issue1993.t @ 30418:1156ec81f709

util: improve iterfile so it chooses code path wisely We have performance concerns on "iterfile" as it is 4X slower on normal files. While modern systems have the nice property that reading a "fast" (on-disk) file cannot be interrupted and should be made use of. This patch dumps the related knowledge in comments. And "iterfile" chooses code paths wisely: 1. If it's CPython 3, or PyPY, use the fast path. 2. If fp is a normal file, use the fast path. 3. If fp is not a normal file and CPython version >= 2.7.4, use the same workaround (4x slower) as before. 4. If fp is not a normal file and CPython version < 2.7.4, use another workaround (2x slower but may block longer then necessary) which basically re-invents the buffer + readline logic in Python. This will give us good confidence on both correctness and performance dealing with EINTR in iterfile(fp) for all known supported Python versions.
author Jun Wu <quark@fb.com>
date Tue, 15 Nov 2016 20:25:51 +0000
parents 4591cd6b6794
children
line wrap: on
line source

  $ hg init a
  $ cd a
  $ echo a > a
  $ hg ci -Am0
  adding a
  $ echo b > b
  $ hg ci -Am1
  adding b
  $ hg tag -r0 default
  warning: tag default conflicts with existing branch name
  $ hg log
  changeset:   2:30a83d1e4a1e
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     Added tag default for changeset f7b1eb17ad24
  
  changeset:   1:925d80f479bb
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     1
  
  changeset:   0:f7b1eb17ad24
  tag:         default
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     0
  
  $ hg update 'tag(default)'
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ hg parents
  changeset:   0:f7b1eb17ad24
  tag:         default
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     0
  
  $ hg update 'branch(default)'
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg parents
  changeset:   2:30a83d1e4a1e
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     Added tag default for changeset f7b1eb17ad24
  

  $ cd ..