tracing updated

This commit is contained in:
AF 2022-07-17 18:47:37 +03:00
parent 96338b559e
commit 30284c8f72
3 changed files with 19 additions and 14 deletions

8
faq.md Normal file
View File

@ -0,0 +1,8 @@
### Why is `Coroutine[Any, Any, T]` used instead of `Awaitable[T]`?
* Typing issues (PyCharm)
* Explicit expression of whether some sort of action is performed or not (tasks vs futures vs coros)
### Why is `subset-verify-optimized` branch closed?
* Performance gain at large set sizes are 0% or less.
* Performance gain with caching is always negative.
* Using merge-based optimization is assumed to be even less practical.

View File

@ -110,18 +110,20 @@ class TestBridge(unittest.IsolatedAsyncioTestCase):
async def test_flowstandard(self):
set_gather_linear()
set0 = {os.urandom(8).hex().encode() for _ in range(64)}
set0 = {os.urandom(8).hex().encode() for _ in range(512)}
abt0: ActiveBinaryTree[Plain, Integer] = await self.abt_of(*set0)
abt1: ActiveBinaryTree[Plain, Integer] = abt0
for _ in range(16):
for _ in range(32):
abt1 = await abt1.add(HashPoint.of(Plain(os.urandom(8).hex().encode())))
fs0 = FlowStandard(abt0.protocolized())
fs1 = FlowStandard(abt1.protocolized())
_t = time.process_time()
await fs0.verify_subset(UnitReducer(fs1))
for _ in range(16):
await fs0.verify_subset(UnitReducer(fs1))
with self.assertWarns(RuntimeWarning):
with self.assertRaises(ValueError):
await fs1.verify_subset(UnitReducer(fs0))
for _ in range(16):
with self.assertRaises(ValueError):
await fs1.verify_subset(UnitReducer(fs0))
print('verification time', time.process_time() - _t)
async def test_flow13(self):

View File

@ -75,14 +75,9 @@ async def _instrument(process: Callable[[], Coroutine[Any, Any, None]]) -> list[
async def _process(bank: BankBlock) -> None:
assert_true(await bank.verify())
print('processed')
async def _pre_measure(bank: BankBlock):
with Measure(bank, 'verify') as measurement:
await _process(bank)
print('pre-measured', *(f'{t:.3f}' for t in measurement.log))
assert_true(await bank.verify())
print('measured', *(f'{t:.3f}' for t in measurement.log))
async def _trace(params):
@ -92,7 +87,7 @@ async def _trace(params):
*params['subjects'],
*params['transactions'],
)
await _pre_measure(bank)
await _process(bank)
bank = await _migrate(bank, params)
set_gather_asyncio()
with DeintrumentationSize(Instrumentation, 'deinstrument'):
@ -120,6 +115,6 @@ preset_old = dict(blocks=16, subjects=(8, 15), transactions=(8, 15), caching=Fal
if __name__ == '__main__':
asyncio.run(
trace(
preset_short
preset_long
)
)