Permalink
Browse files

Save a performance experiment with PyPy.

Summary: PyPy runs the OSH parser more slowly than CPython.

This wasn't that surprising since it's a string-based workload.  Saving
it anyway.
  • Loading branch information...
Andy Chu
Andy Chu committed Oct 6, 2017
1 parent ce06499 commit 65f7b6cd28f637dbeea5442490c3231638e8d133
Showing with 65 additions and 4 deletions.
  1. 0 benchmarks/__init__.py
  2. +14 −0 benchmarks/fake_libc.py
  3. +35 −0 benchmarks/pypy.sh
  4. +4 −1 core/cmd_exec.py
  5. +4 −1 core/expr_eval.py
  6. +4 −1 core/glob_.py
  7. +4 −1 osh/bool_parse.py
View
No changes.
View
@@ -0,0 +1,14 @@
#!/usr/bin/python
"""
fake_libc.py
For PyPy.
"""
def regex_parse(regex_str):
return True
# This makes things fall through to the first case statement...
def fnmatch(s, to_match):
return True
View
@@ -0,0 +1,35 @@
#!/bin/bash
#
# Summary: PyPy is slower than CPython for parsing. (I bet it also uses more
# memory, although I didn't measure that.)
#
# I don't plan on using PyPy, but this is simple enough to save for posterity.
#
# Usage:
# ./pypy.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
readonly PYPY=~/install/pypy2-v5.9.0-linux64/bin/pypy
parse-abuild() {
local vm=$1
time $vm bin/oil.py osh -n ~/git/alpine/abuild/abuild >/dev/null
}
# ~3.5 seconds
parse-with-cpython() {
parse-abuild python
}
# ~4.8 seconds
# NOTE: We could run it in a loop to see if the JIT warms up, but that would
# only be for curiousity. Most shell processes are short-lived, so it's the
# wrong thing to optimize for.
parse-with-pypy() {
parse-abuild $PYPY
}
"$@"
View
@@ -39,7 +39,10 @@
from osh import ast_ as ast
from osh import parse_lib
import libc # for fnmatch
try:
import libc # for fnmatch
except ImportError:
from benchmarks import fake_libc as libc
EBuiltin = builtin.EBuiltin
View
@@ -12,7 +12,10 @@
import os
import stat
import libc # for fnmatch
try:
import libc # for fnmatch
except ImportError:
from benchmarks import fake_libc as libc
from core.id_kind import BOOL_OPS, OperandType, Id, IdName
from core import util
View
@@ -5,7 +5,10 @@
import re
import libc
try:
import libc
except ImportError:
from benchmarks import fake_libc as libc
from core.util import log
View
@@ -42,7 +42,10 @@
from osh.lex import LexMode
import libc # for regex_parse
try:
import libc # for regex_parse
except ImportError:
from benchmarks import fake_libc as libc
log = util.log

0 comments on commit 65f7b6c

Please sign in to comment.