austin-python 2.1.1__tar.gz → 2.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. {austin_python-2.1.1 → austin_python-2.1.2}/PKG-INFO +1 -1
  2. {austin_python-2.1.1 → austin_python-2.1.2}/austin/events.py +1 -2
  3. {austin_python-2.1.1 → austin_python-2.1.2}/austin/format/mojo.py +21 -2
  4. {austin_python-2.1.1 → austin_python-2.1.2}/austin/stats.py +18 -15
  5. {austin_python-2.1.1 → austin_python-2.1.2}/pyproject.toml +4 -4
  6. {austin_python-2.1.1 → austin_python-2.1.2}/test/stats/test_austin_stats.py +16 -16
  7. {austin_python-2.1.1 → austin_python-2.1.2}/.flake8 +0 -0
  8. {austin_python-2.1.1 → austin_python-2.1.2}/.gitignore +0 -0
  9. {austin_python-2.1.1 → austin_python-2.1.2}/.readthedocs.yml +0 -0
  10. {austin_python-2.1.1 → austin_python-2.1.2}/AUTHORS +0 -0
  11. {austin_python-2.1.1 → austin_python-2.1.2}/CODE-OF-CONDUCT.md +0 -0
  12. {austin_python-2.1.1 → austin_python-2.1.2}/CONTRIBUTING.md +0 -0
  13. {austin_python-2.1.1 → austin_python-2.1.2}/COPYING +0 -0
  14. {austin_python-2.1.1 → austin_python-2.1.2}/ISSUE_TEMPLATE.md +0 -0
  15. {austin_python-2.1.1 → austin_python-2.1.2}/LICENSE.md +0 -0
  16. {austin_python-2.1.1 → austin_python-2.1.2}/MANIFEST.in +0 -0
  17. {austin_python-2.1.1 → austin_python-2.1.2}/PULL_REQUEST_TEMPLATE.md +0 -0
  18. {austin_python-2.1.1 → austin_python-2.1.2}/README.md +0 -0
  19. {austin_python-2.1.1 → austin_python-2.1.2}/austin/__init__.py +0 -0
  20. {austin_python-2.1.1 → austin_python-2.1.2}/austin/aio.py +0 -0
  21. {austin_python-2.1.1 → austin_python-2.1.2}/austin/base.py +0 -0
  22. {austin_python-2.1.1 → austin_python-2.1.2}/austin/cli.py +0 -0
  23. {austin_python-2.1.1 → austin_python-2.1.2}/austin/config.py +0 -0
  24. {austin_python-2.1.1 → austin_python-2.1.2}/austin/errors.py +0 -0
  25. {austin_python-2.1.1 → austin_python-2.1.2}/austin/format/__init__.py +0 -0
  26. {austin_python-2.1.1 → austin_python-2.1.2}/austin/format/collapsed_stack.py +1 -1
  27. {austin_python-2.1.1 → austin_python-2.1.2}/austin/format/compress.py +0 -0
  28. {austin_python-2.1.1 → austin_python-2.1.2}/austin/format/pprof/__init__.py +0 -0
  29. {austin_python-2.1.1 → austin_python-2.1.2}/austin/format/pprof/__main__.py +0 -0
  30. {austin_python-2.1.1 → austin_python-2.1.2}/austin/format/pprof/profile.proto +0 -0
  31. {austin_python-2.1.1 → austin_python-2.1.2}/austin/format/pprof/profile_pb2.py +0 -0
  32. {austin_python-2.1.1 → austin_python-2.1.2}/austin/format/speedscope.py +0 -0
  33. {austin_python-2.1.1 → austin_python-2.1.2}/austin/simple.py +0 -0
  34. {austin_python-2.1.1 → austin_python-2.1.2}/austin/threads.py +0 -0
  35. {austin_python-2.1.1 → austin_python-2.1.2}/austin/tools/diff.py +0 -0
  36. {austin_python-2.1.1 → austin_python-2.1.2}/austin/tools/mojodbg.py +0 -0
  37. {austin_python-2.1.1 → austin_python-2.1.2}/austin/tools/resolve.py +0 -0
  38. {austin_python-2.1.1 → austin_python-2.1.2}/test/__init__.py +0 -0
  39. {austin_python-2.1.1 → austin_python-2.1.2}/test/conftest.py +0 -0
  40. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/austin.json +0 -0
  41. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/austin.out +0 -0
  42. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/austin.pprof +0 -0
  43. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/austinp.mojo +0 -0
  44. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/austinp.resolved.mojo +0 -0
  45. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/column.mojo +0 -0
  46. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/column.py +0 -0
  47. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/diff_a-b.austin +0 -0
  48. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/diff_a.austin +0 -0
  49. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/diff_b.austin +0 -0
  50. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/mp.austin +0 -0
  51. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/mp.mojo +0 -0
  52. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/test.austin +0 -0
  53. {austin_python-2.1.1 → austin_python-2.1.2}/test/data/test.mojo +0 -0
  54. {austin_python-2.1.1 → austin_python-2.1.2}/test/format/__init__.py +0 -0
  55. {austin_python-2.1.1 → austin_python-2.1.2}/test/format/test_compress.py +0 -0
  56. {austin_python-2.1.1 → austin_python-2.1.2}/test/format/test_mojo.py +0 -0
  57. {austin_python-2.1.1 → austin_python-2.1.2}/test/format/test_pprof.py +0 -0
  58. {austin_python-2.1.1 → austin_python-2.1.2}/test/format/test_speedscope.py +0 -0
  59. {austin_python-2.1.1 → austin_python-2.1.2}/test/stats/test_austin_file_reader.py +0 -0
  60. {austin_python-2.1.1 → austin_python-2.1.2}/test/stats/test_hierarchical_stats.py +0 -0
  61. {austin_python-2.1.1 → austin_python-2.1.2}/test/test_aio.py +0 -0
  62. {austin_python-2.1.1 → austin_python-2.1.2}/test/test_cli.py +0 -0
  63. {austin_python-2.1.1 → austin_python-2.1.2}/test/test_config.py +0 -0
  64. {austin_python-2.1.1 → austin_python-2.1.2}/test/test_semver.py +0 -0
  65. {austin_python-2.1.1 → austin_python-2.1.2}/test/test_simple.py +0 -0
  66. {austin_python-2.1.1 → austin_python-2.1.2}/test/test_threads.py +0 -0
  67. {austin_python-2.1.1 → austin_python-2.1.2}/test/tools/test_diff.py +0 -0
  68. {austin_python-2.1.1 → austin_python-2.1.2}/test/tools/test_resolve.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: austin-python
3
- Version: 2.1.1
3
+ Version: 2.1.2
4
4
  Summary: Python wrapper for Austin, the CPython frame stack sampler.
5
5
  Project-URL: homepage, https://github.com/P403n1x87/austin-python
6
6
  Project-URL: documentation, https://austin-python.readthedocs.io
@@ -1,10 +1,9 @@
1
1
  import typing as t
2
- from collections import namedtuple
3
2
  from dataclasses import dataclass
4
3
 
5
4
 
6
- ThreadName = namedtuple("ThreadName", ["thread", "iid"])
7
5
  ProcessId = int
6
+ ThreadName = str
8
7
  InterpreterId = int
9
8
  MicroSeconds = int
10
9
  Bytes = int
@@ -277,7 +277,12 @@ def str_reader() -> t.Generator[t.Optional[str], bytes, str]:
277
277
  (b,) = yield bytes(buffer[:i]).decode(errors="replace")
278
278
  i = 0
279
279
  else:
280
- buffer[i] = b
280
+ try:
281
+ buffer[i] = b
282
+ except IndexError:
283
+ # Expand the buffer if needed
284
+ buffer += bytearray(i - len(buffer) + 1)
285
+ buffer[i] = b
281
286
  (b,) = yield None
282
287
  i += 1
283
288
 
@@ -353,6 +358,14 @@ class BaseMojoStreamReader(AustinEventIterator):
353
358
 
354
359
  return metadata
355
360
 
361
+ @property
362
+ def mode(self) -> t.Optional[str]:
363
+ return self.metadata.get("mode")
364
+
365
+ @property
366
+ def gc(self) -> t.Optional[str]:
367
+ return self.metadata.get("gc")
368
+
356
369
  def _finalize_sample(self) -> AustinSample:
357
370
  """Finalize the current sample."""
358
371
  assert self._running_sample is not None, self._running_sample
@@ -395,7 +408,13 @@ class BaseMojoStreamReader(AustinEventIterator):
395
408
  if self._running_sample is not None:
396
409
  self._finalize_sample()
397
410
 
398
- self._running_sample = _RunningSample(pid=pid, iid=iid, thread=thread)
411
+ self._running_sample = _RunningSample(
412
+ pid=pid,
413
+ iid=iid,
414
+ thread=thread,
415
+ idle=False if self.mode == "full" else None,
416
+ gc=False if self.gc is not None else None,
417
+ )
399
418
 
400
419
  return MojoStack(pid, iid if iid is not None else -1, thread)
401
420
 
@@ -21,6 +21,7 @@
21
21
  # You should have received a copy of the GNU General Public License
22
22
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
+ from collections import namedtuple
24
25
  from copy import deepcopy
25
26
  from dataclasses import dataclass
26
27
  from dataclasses import field
@@ -39,10 +40,12 @@ from austin.events import AustinMetadata
39
40
  from austin.events import AustinMetrics
40
41
  from austin.events import AustinSample
41
42
  from austin.events import ProcessId
42
- from austin.events import ThreadName
43
43
  from austin.format.collapsed_stack import AustinEventCollapsedStackFormatter
44
44
 
45
45
 
46
+ ThreadInfo = namedtuple("ThreadInfo", ["thread", "iid"])
47
+
48
+
46
49
  COLLAPSED_STACK_FORMATTER = AustinEventCollapsedStackFormatter()
47
50
 
48
51
 
@@ -136,12 +139,12 @@ class FrameStats(HierarchicalStats):
136
139
  class ThreadStats(HierarchicalStats):
137
140
  """Thread statistics."""
138
141
 
139
- label: ThreadName
142
+ label: ThreadInfo
140
143
  children: Dict[AustinFrame, FrameStats] = field(default_factory=dict) # type: ignore[assignment]
141
144
 
142
145
  def collapse(
143
146
  self, stats_type: AustinStatsType
144
- ) -> Generator[Tuple[ThreadName, List[AustinFrame], AustinMetrics], None, None]:
147
+ ) -> Generator[Tuple[ThreadInfo, List[AustinFrame], AustinMetrics], None, None]:
145
148
  """Collapse the hierarchical statistics."""
146
149
 
147
150
  if self.own:
@@ -166,7 +169,7 @@ class ProcessStats:
166
169
  """Process statistics."""
167
170
 
168
171
  pid: ProcessId
169
- threads: Dict[ThreadName, ThreadStats] = field(default_factory=dict)
172
+ threads: Dict[ThreadInfo, ThreadStats] = field(default_factory=dict)
170
173
 
171
174
  def collapse(
172
175
  self, stats_type: AustinStatsType
@@ -175,22 +178,22 @@ class ProcessStats:
175
178
  yield from (
176
179
  AustinSample(
177
180
  pid=self.pid,
178
- iid=thread_name.iid,
179
- thread=thread_name.thread,
181
+ iid=thread_info.iid,
182
+ thread=thread_info.thread,
180
183
  frames=tuple(frames),
181
184
  metrics=metric,
182
185
  )
183
186
  for thread in self.threads.values()
184
- for thread_name, frames, metric in thread.collapse(stats_type)
187
+ for thread_info, frames, metric in thread.collapse(stats_type)
185
188
  )
186
189
 
187
- def get_thread(self, thread_name: ThreadName) -> Optional[ThreadStats]:
190
+ def get_thread(self, thread_info: ThreadInfo) -> Optional[ThreadStats]:
188
191
  """Get thread statistics from this process by name.
189
192
 
190
193
  If the given thread name is not registered with this current process
191
194
  statistics, then ``None`` is returned.
192
195
  """
193
- return self.threads.get(thread_name)
196
+ return self.threads.get(thread_info)
194
197
 
195
198
 
196
199
  @dataclass
@@ -286,8 +289,8 @@ class AustinStats:
286
289
  return
287
290
 
288
291
  pid = sample.pid
289
- thread_name = ThreadName(sample.thread, sample.iid or 0)
290
- thread_stats = ThreadStats(thread_name, own=0, total=metric)
292
+ thread_info = ThreadInfo(sample.thread, sample.iid or 0)
293
+ thread_stats = ThreadStats(thread_info, own=0, total=metric)
291
294
 
292
295
  # Convert the list of frames into a nested FrameStats instance
293
296
  stats: HierarchicalStats = thread_stats
@@ -300,15 +303,15 @@ class AustinStats:
300
303
 
301
304
  with self._lock:
302
305
  if pid not in self.processes:
303
- self.processes[pid] = ProcessStats(pid, {thread_name: thread_stats})
306
+ self.processes[pid] = ProcessStats(pid, {thread_info: thread_stats})
304
307
  return
305
308
 
306
309
  process = self.processes[pid]
307
- if thread_name not in process.threads:
308
- process.threads[thread_name] = thread_stats
310
+ if thread_info not in process.threads:
311
+ process.threads[thread_info] = thread_stats
309
312
  return
310
313
 
311
- process.threads[thread_name] << thread_stats
314
+ process.threads[thread_info] << thread_stats
312
315
 
313
316
  def flatten(self) -> Generator[AustinSample, None, None]:
314
317
  for process in self.processes.values():
@@ -127,10 +127,10 @@ source = ["austin"]
127
127
  [tool.coverage.report]
128
128
  show_missing = true
129
129
 
130
- [tool.isort]
131
- force_single_line = true
132
- lines_after_imports = 2
133
- profile = "black"
130
+ [tool.ruff.lint.isort]
131
+ force-single-line = true
132
+ lines-after-imports = 2
133
+ force-sort-within-sections = true
134
134
 
135
135
  [tool.mypy]
136
136
  ignore_missing_imports = true
@@ -21,19 +21,19 @@
21
21
  # You should have received a copy of the GNU General Public License
22
22
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
- import io
25
24
  from copy import deepcopy
25
+ import io
26
26
 
27
27
  from austin.events import AustinFrame
28
28
  from austin.events import AustinMetrics
29
29
  from austin.events import AustinSample
30
- from austin.events import ThreadName
31
30
  from austin.format.collapsed_stack import AustinFileReader
32
31
  from austin.format.collapsed_stack import parse_collapsed_stack
33
32
  from austin.stats import AustinStats
34
33
  from austin.stats import AustinStatsType
35
34
  from austin.stats import FrameStats
36
35
  from austin.stats import ProcessStats
36
+ from austin.stats import ThreadInfo
37
37
  from austin.stats import ThreadStats
38
38
 
39
39
 
@@ -54,8 +54,8 @@ def test_austin_stats_single_process():
54
54
  42: ProcessStats(
55
55
  pid=42,
56
56
  threads={
57
- ThreadName("0x7f45645646", 0): ThreadStats(
58
- label=ThreadName("0x7f45645646", 0),
57
+ ThreadInfo("0x7f45645646", 0): ThreadStats(
58
+ label=ThreadInfo("0x7f45645646", 0),
59
59
  own=0,
60
60
  total=152,
61
61
  children={
@@ -82,8 +82,8 @@ def test_austin_stats_single_process():
82
82
  42: ProcessStats(
83
83
  pid=42,
84
84
  threads={
85
- ThreadName("0x7f45645646", 0): ThreadStats(
86
- label=ThreadName("0x7f45645646", 0),
85
+ ThreadInfo("0x7f45645646", 0): ThreadStats(
86
+ label=ThreadInfo("0x7f45645646", 0),
87
87
  total=300,
88
88
  own=148,
89
89
  children={
@@ -110,8 +110,8 @@ def test_austin_stats_single_process():
110
110
  42: ProcessStats(
111
111
  pid=42,
112
112
  threads={
113
- ThreadName("0x7f45645646", 0): ThreadStats(
114
- label=ThreadName("0x7f45645646", 0),
113
+ ThreadInfo("0x7f45645646", 0): ThreadStats(
114
+ label=ThreadInfo("0x7f45645646", 0),
115
115
  total=400,
116
116
  own=148,
117
117
  children={
@@ -138,8 +138,8 @@ def test_austin_stats_single_process():
138
138
  42: ProcessStats(
139
139
  pid=42,
140
140
  threads={
141
- ThreadName("0x7f45645646", 0): ThreadStats(
142
- label=ThreadName("0x7f45645646", 0),
141
+ ThreadInfo("0x7f45645646", 0): ThreadStats(
142
+ label=ThreadInfo("0x7f45645646", 0),
143
143
  total=800,
144
144
  own=148,
145
145
  children={
@@ -175,8 +175,8 @@ def test_austin_stats_single_process():
175
175
  42: ProcessStats(
176
176
  pid=42,
177
177
  threads={
178
- ThreadName("0x7f45645664", 0): ThreadStats(
179
- label=ThreadName("0x7f45645664", 0),
178
+ ThreadInfo("0x7f45645664", 0): ThreadStats(
179
+ label=ThreadInfo("0x7f45645664", 0),
180
180
  own=0,
181
181
  total=152,
182
182
  children={
@@ -191,8 +191,8 @@ def test_austin_stats_single_process():
191
191
  )
192
192
  },
193
193
  ),
194
- ThreadName("0x7f45645646", 0): ThreadStats(
195
- label=ThreadName("0x7f45645646", 0),
194
+ ThreadInfo("0x7f45645646", 0): ThreadStats(
195
+ label=ThreadInfo("0x7f45645646", 0),
196
196
  total=800,
197
197
  own=148,
198
198
  children={
@@ -302,8 +302,8 @@ def test_load():
302
302
  42: ProcessStats(
303
303
  pid=42,
304
304
  threads={
305
- ThreadName("0x7f45645646", 0): ThreadStats(
306
- label=ThreadName("0x7f45645646", 0),
305
+ ThreadInfo("0x7f45645646", 0): ThreadStats(
306
+ label=ThreadInfo("0x7f45645646", 0),
307
307
  own=0,
308
308
  total=1300,
309
309
  children={
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,6 +1,6 @@
1
- import typing as t
2
1
  from functools import singledispatchmethod
3
2
  from pathlib import Path
3
+ import typing as t
4
4
 
5
5
  from austin.events import AustinEvent
6
6
  from austin.events import AustinEventIterator