{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## License\n", "\n", "Copyright 2020 Google LLC\n", "\n", "Licensed under the the Apache License v2.0 with LLVM Exceptions (the \"License\");\n", "you may not use this file except in compliance with the License.\n", "You may obtain a copy of the License at\n", "\n", "https://llvm.org/LICENSE.txt\n", "\n", "Unless required by applicable law or agreed to in writing, software\n", "distributed under the License is distributed on an \"AS IS\" BASIS,\n", "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", "See the License for the specific language governing permissions and\n", "limitations under the License." ] }, { "cell_type": "code", "execution_count": 724, "metadata": {}, "outputs": [], "source": [ "import requests\n", "import os\n", "import logging\n", "import argparse\n", "import json\n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns" ] }, { "cell_type": "code", "execution_count": 725, "metadata": {}, "outputs": [], "source": [ "cache_file = \"cache.json\"\n", "token = f'Bearer {os.getenv(\"BUILDKITE_API_TOKEN\")}'\n", "builds = []" ] }, { "cell_type": "code", "execution_count": 726, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "loaded 13566 entries\n" ] } ], "source": [ "if os.path.exists(cache_file):\n", " with open(cache_file) as f:\n", " builds = json.load(f)\n", " print(f'loaded {len(builds)} entries') " ] }, { "cell_type": "code", "execution_count": 727, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "loading page 1\n", "loading page 2\n", "loading page 3\n", "https://buildkite.com/llvm-project/llvm-master-build/builds/723 is running , skipping\n", "https://buildkite.com/llvm-project/llvm-master-build/builds/721 is running , skipping\n", "https://buildkite.com/llvm-project/llvm-master-build/builds/719 is running , skipping\n", "loading page 4\n", "https://buildkite.com/llvm-project/llvm-master-build/builds/717 is running , skipping\n", "https://buildkite.com/llvm-project/llvm-master-build/builds/715 is running , skipping\n", "loading page 5\n", "loading page 6\n", "loading page 7\n", "loading page 8\n", "loading page 9\n", "loading page 10\n", "13706 jobs in total\n", "saved 13706 entries\n" ] } ], "source": [ "# load new jobs from Buildkite API\n", "max_pages = 2000\n", "if True:\n", " existing = set()\n", " for j in builds:\n", " existing.add(j['id'])\n", "\n", " # uncomment to reset\n", "# builds = []\n", "# existing = set()\n", " page = 1\n", " stop = False\n", " while page <= max_pages:\n", " print('loading page', page)\n", " re = requests.get('https://api.buildkite.com/v2/organizations/llvm-project/builds',\n", " params={'page': page},\n", " headers={'Authorization': token})\n", " if re.status_code != 200:\n", " print('response status', re.status_code, re)\n", " break\n", " x = re.json()\n", " if x == []:\n", " print('empty response')\n", " break\n", " for j in x:\n", " if j['id'] in existing:\n", "# print('found existing job', j['id'])\n", " # load some more pages as some of them might be running before and wasn't added. \n", " max_pages = min(page + 5, max_pages)\n", " else:\n", " # skip running jobs \n", " if (j['state'] == 'running') or (j['state'] == 'scheduled'):\n", " print(j['web_url'], 'is', j['state'], ', skipping')\n", " continue\n", " builds.append(j)\n", " page += 1\n", " print(len(builds), 'jobs in total') \n", " with open(cache_file, 'w') as f:\n", " json.dump(builds, f)\n", " print(f'saved {len(builds)} entries')" ] }, { "cell_type": "code", "execution_count": 728, "metadata": {}, "outputs": [], "source": [ "d = {\n", " 'id': [],\n", " 'number': [],\n", " 'pipeline': [],\n", "}\n", "\n", "jobs = {\n", " 'pipeline': [],\n", " 'name': [],\n", " 'step_key': [],\n", " 'state': [],\n", " 'exit_status': [],\n", " 'agent_id': [],\n", " \n", " 'agent_name': [],\n", " 'runnable_at': [],\n", " 'started_at': [],\n", " 'wait_duration': [],\n", " 'finished_at': [],\n", " 'run_duration': [],\n", "}\n", "\n", "sec = np.timedelta64(1, 's')\n", "\n", "for b in builds:\n", " env = b['env']\n", " if 'ph_windows_agents' not in env:\n", " continue\n", " if 'scripts_branch' not in env:\n", " continue\n", " d['id'].append(b['id'])\n", " d['number'].append(b['number'])\n", " d['pipeline'].append(b['pipeline']['slug'])\n", " for x in b['jobs']:\n", " if x['state'] in ['waiting_failed', 'canceled', 'skipped', 'broken']:\n", " continue\n", " try:\n", " jobs['pipeline'].append(b['pipeline']['slug'])\n", " jobs['name'].append(x['name'])\n", " jobs['step_key'].append(x['step_key'] if 'step_key' in x else '')\n", " jobs['state'].append(x['state'] )\n", " jobs['exit_status'].append(x['exit_status'] if 'exit_status' in x else -1)\n", " jobs['agent_id'].append(x['agent']['id'] if 'agent' in x else '')\n", " jobs['agent_name'].append(x['agent']['name'] if 'agent' in x else '')\n", " runnable = np.datetime64(x['runnable_at'].replace('Z', ''))\n", " started = np.datetime64(x['started_at'].replace('Z', ''))\n", " finished = np.datetime64(x['finished_at'].replace('Z', ''))\n", " jobs['runnable_at'].append(runnable)\n", " jobs['started_at'].append(started)\n", " jobs['wait_duration'].append((started - runnable) / sec)\n", " jobs['finished_at'].append(finished)\n", " jobs['run_duration'].append((finished - started) / sec)\n", " except Exception as e:\n", " print(x)\n", " raise e \n", "jobs = pd.DataFrame(jobs)" ] }, { "cell_type": "code", "execution_count": 729, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['llvm-master-build'], dtype=object)" ] }, "execution_count": 729, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jobs.pipeline.unique()" ] }, { "cell_type": "code", "execution_count": 730, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | pipeline | \n", "name | \n", "step_key | \n", "state | \n", "exit_status | \n", "agent_id | \n", "agent_name | \n", "runnable_at | \n", "started_at | \n", "wait_duration | \n", "finished_at | \n", "run_duration | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "llvm-master-build | \n", ":seedling: setup | \n", "None | \n", "passed | \n", "0 | \n", "f20d42d3-31cb-4e46-a3d6-699877e7b283 | \n", "premerge-debian-77f64f444-fm624-1 | \n", "2020-07-27 18:10:16 | \n", "2020-07-27 18:15:44.928 | \n", "328.928 | \n", "2020-07-27 18:15:47.797 | \n", "2.869 | \n", "
1 | \n", "llvm-master-build | \n", ":windows: build and test windows | \n", "windows | \n", "passed | \n", "0 | \n", "c9e48cee-e909-45b2-aa23-0d7335786499 | \n", "we32n1b | \n", "2020-07-27 18:15:47 | \n", "2020-07-28 01:36:57.687 | \n", "26470.687 | \n", "2020-07-28 02:26:08.750 | \n", "2951.063 | \n", "
2 | \n", "llvm-master-build | \n", ":seedling: setup | \n", "None | \n", "passed | \n", "0 | \n", "f20d42d3-31cb-4e46-a3d6-699877e7b283 | \n", "premerge-debian-77f64f444-fm624-1 | \n", "2020-07-27 18:10:15 | \n", "2020-07-27 18:15:34.989 | \n", "319.989 | \n", "2020-07-27 18:15:37.721 | \n", "2.732 | \n", "
3 | \n", "llvm-master-build | \n", ":windows: build and test windows | \n", "windows | \n", "passed | \n", "0 | \n", "d4d0a0a4-255b-4fdd-8aba-abb00ba0bf34 | \n", "we16c2b | \n", "2020-07-27 18:15:37 | \n", "2020-07-28 03:13:59.996 | \n", "32302.996 | \n", "2020-07-28 04:14:12.521 | \n", "3612.525 | \n", "
4 | \n", "llvm-master-build | \n", ":seedling: setup | \n", "None | \n", "passed | \n", "0 | \n", "f20d42d3-31cb-4e46-a3d6-699877e7b283 | \n", "premerge-debian-77f64f444-fm624-1 | \n", "2020-07-27 18:10:14 | \n", "2020-07-27 18:15:25.094 | \n", "311.094 | \n", "2020-07-27 18:15:27.918 | \n", "2.824 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
189 | \n", "llvm-master-build | \n", ":windows: build and test windows | \n", "windows | \n", "passed | \n", "0 | \n", "42f6f98d-15bd-4ad4-ac48-8626a752a154 | \n", "w16c2-1 | \n", "2020-07-29 18:22:31 | \n", "2020-07-29 20:23:50.686 | \n", "7279.686 | \n", "2020-07-29 21:23:50.271 | \n", "3599.585 | \n", "
190 | \n", "llvm-master-build | \n", ":seedling: setup | \n", "None | \n", "passed | \n", "0 | \n", "db5829eb-04bf-4700-9bec-423258de4a7d | \n", "premerge-debian-77f64f444-vxgx4-1 | \n", "2020-07-29 18:21:47 | \n", "2020-07-29 18:22:09.243 | \n", "22.243 | \n", "2020-07-29 18:22:12.321 | \n", "3.078 | \n", "
191 | \n", "llvm-master-build | \n", ":windows: build and test windows | \n", "windows | \n", "passed | \n", "0 | \n", "42f6f98d-15bd-4ad4-ac48-8626a752a154 | \n", "w16c2-1 | \n", "2020-07-29 18:22:12 | \n", "2020-07-29 19:24:00.345 | \n", "3708.345 | \n", "2020-07-29 20:23:45.967 | \n", "3585.622 | \n", "
192 | \n", "llvm-master-build | \n", ":seedling: setup | \n", "None | \n", "passed | \n", "0 | \n", "db5829eb-04bf-4700-9bec-423258de4a7d | \n", "premerge-debian-77f64f444-vxgx4-1 | \n", "2020-07-29 18:21:45 | \n", "2020-07-29 18:21:49.190 | \n", "4.190 | \n", "2020-07-29 18:21:52.862 | \n", "3.672 | \n", "
193 | \n", "llvm-master-build | \n", ":windows: build and test windows | \n", "windows | \n", "passed | \n", "0 | \n", "42f6f98d-15bd-4ad4-ac48-8626a752a154 | \n", "w16c2-1 | \n", "2020-07-29 18:21:52 | \n", "2020-07-29 18:21:54.857 | \n", "2.857 | \n", "2020-07-29 19:23:58.471 | \n", "3723.614 | \n", "
194 rows × 12 columns
\n", "\n", " | median | \n", "mean | \n", "std | \n", "count_nonzero | \n", "
---|---|---|---|---|
\n", " | run_duration | \n", "run_duration | \n", "run_duration | \n", "run_duration | \n", "
agent_name | \n", "\n", " | \n", " | \n", " | \n", " |
we16n1a | \n", "4982.7380 | \n", "5013.848800 | \n", "396.926050 | \n", "5.0 | \n", "
we16n1b | \n", "4692.7930 | \n", "4707.102222 | \n", "121.624149 | \n", "9.0 | \n", "
w16n2-1 | \n", "3846.2090 | \n", "3881.809600 | \n", "81.657742 | \n", "5.0 | \n", "
we16c2a | \n", "3779.3110 | \n", "3858.373400 | \n", "183.822602 | \n", "5.0 | \n", "
we16c2b | \n", "3593.5200 | \n", "3615.016200 | \n", "66.460005 | \n", "10.0 | \n", "
w16c2-1 | \n", "3585.6220 | \n", "3612.092800 | \n", "63.120688 | \n", "5.0 | \n", "
we16n1c | \n", "3068.6440 | \n", "3085.927100 | \n", "1412.888086 | \n", "10.0 | \n", "
we32n1b | \n", "2964.4520 | \n", "2964.178300 | \n", "59.215712 | \n", "10.0 | \n", "
we32n1a | \n", "2880.9180 | \n", "3031.068800 | \n", "428.110568 | \n", "5.0 | \n", "
we16c2c | \n", "2366.5155 | \n", "2377.441900 | \n", "1005.847826 | \n", "10.0 | \n", "
we32n1c | \n", "2289.9605 | \n", "2275.634700 | \n", "629.386804 | \n", "10.0 | \n", "
w64 | \n", "2282.6860 | \n", "2282.769800 | \n", "33.481977 | \n", "5.0 | \n", "