627 Commits

Author SHA1 Message Date
gmega
c960f96be8
rename states and callbacks to reflect current domain understanding 2023-12-08 11:33:58 -03:00
gmega
7474c5238d
remove profiler export from main module; disable profiler in tests by default 2023-12-08 10:21:08 -03:00
gmega
eb7cf1ae1b
enable profiling on testprofiler; import/export profiler from chronos's root module 2023-12-07 18:53:12 -03:00
gmega
321b6c7024
capitalize test suite names to make it consistent with the rest 2023-12-07 17:11:27 -03:00
gmega
8ffe7f4a88
improve assertion error messages 2023-12-07 17:10:17 -03:00
gmega
5d27b12b17
move instrumentation points for async future FSM into more correct locations 2023-12-07 17:09:45 -03:00
gmega
3f774a1fa4
enable future ID; add extra debug info 2023-12-01 18:41:50 -03:00
gmega
9883d7dd8a
add zombie checks to run state too 2023-11-29 13:30:15 -03:00
gmega
9f9b31450e
add zombie track test, strenghten zombie event spec test 2023-11-29 12:18:57 -03:00
gmega
b64014c154
remove example file (included by accident) 2023-11-29 09:52:32 -03:00
gmega
ade1f3018e
add failing test case for an async proc with children in its finally block 2023-11-28 18:47:43 -03:00
gmega
1d5d02cfa4
add location info to assertions to make them easier to trace 2023-11-28 09:17:58 -03:00
gmega
128531cd83
add accessor to exec time + children, type aliases, minor refactor 2023-11-27 18:08:08 -03:00
gmega
d80fa15233
add call count and max exec time; rename enable => enableProfiling to clear up intent 2023-11-27 14:11:06 -03:00
gmega
d320e2ab09
change enable flag to "chronosProfiling"; add "enable" profiler proc; add stronger assertions to event tests" 2023-11-27 12:27:14 -03:00
gmega
e65c48c153
add tests for exceptions, cancellation, and multiple pauses 2023-11-27 10:58:07 -03:00
gmega
a5fb393ad8
add test for future with a single non-blocking child 2023-11-27 09:52:41 -03:00
gmega
ce1e03aa4e
add test for simple non-blocking future 2023-11-27 09:49:44 -03:00
gmega
81711f8b11
add support for blocking children 2023-11-24 19:46:19 -03:00
gmega
8b5c6a4674
add harness for simulating profiled time and basic profiler metric test 2023-11-24 15:19:01 -03:00
gmega
d4809d5a98
add harness and initial test 2023-11-22 19:31:42 -03:00
Jaremy Creechley
d0ed08c4a3
non-procs 2023-11-01 17:05:55 -07:00
Jaremy Creechley
bd656ab6df
fix onFuturePause using template arg, not future object 2023-10-31 12:38:47 -07:00
Jaremy Creechley
74e5ebaf4a
fix onFuturePause using template arg, not future object 2023-10-31 12:37:20 -07:00
Jaremy Creechley
0a14f702ee
fix test timing 2023-10-27 16:16:23 -07:00
Jaremy Creechley
ac6c22c51a
futures profiling instrumentation 2023-10-26 15:23:13 -07:00
Jaremy Creechley
f9909c4053
futures profiling instrumentation 2023-10-26 13:50:03 -07:00
Eugene Kabanov
0277b65be2
Asynchronous thread notification mechanism. (#406)
* Initial commit.

* Some fixes.

* More fixes.

* Add first test.

* Further fixes for MacOS/BSD.

* Fixes for Linux.

* Add proper tests.

* Lower number of tests.

* Add threadsync tests to test suite.

* There is no need to run tests when threads are off.

* Address review comments.
Fix the issue with multiple signals.
Add tests.

* Switch to use socketpair() instead of pipes.
Fix semaphoring issue on MacOS/BSD.
Add tests.

* Add single threaded fire/wait tests.
codex-stable
2023-07-21 15:51:36 +03:00
Eugene Kabanov
e04c042e8a
Add cross-platform shutdown() call and use it for HTTP server. (#420)
* Add cross-platform shutdown() call and use it for httpserver connection processing.

* Fix Posix compilation issues and warnings.
2023-07-19 20:33:28 +03:00
Eugene Kabanov
d652c52142
Fix regression introduced by #416. (#419) 2023-07-17 16:39:41 +03:00
cheatfate
726fcb1915
Revert "Bump version to 3.2.1."
This reverts commit c8f650e65113ac44368a8c96af594056d270d24b.
2023-07-14 16:40:07 +03:00
cheatfate
c8f650e651
Bump version to 3.2.1. 2023-07-14 14:57:24 +03:00
Eugene Kabanov
155d89450e
Trackers refactoring. (#416)
* Refactor chronos trackers to be more simple.

* Refactor trackers.
Add HTTP server trackers.
Refactor HTTP main processing loop.

* Compatibility fixes.
Add checkLeaks().

* Fix posix test issue.

* Add httpdebug module which introduces HTTP connection dumping helpers.
Add tests for it.

* Recover and deprecate old version of Trackers.

* Make public iterators to iterate over all tracker counters available.
Fix asynctests to use public iterators instead private one.
2023-07-14 13:35:08 +03:00
Jacek Sieka
3d80ea9fc7
fix EpollEvent memory layout (#411)
* fix EpollEvent memory layout

on x86_64, `EpollEvent` is packed - the upstream version is correct here

* copy-paste upstream instead

* Adjust lines to be 80 characters per line.

---------

Co-authored-by: cheatfate <eugene.kabanov@status.im>
2023-07-06 19:51:59 +03:00
Jacek Sieka
0a6f5854a7
fix unused result warning on implict return (fixes #414) (#417)
* fix unused result warning on implict return

* describe `{.used.}` tradeoffs

* oops
2023-07-04 01:11:08 +03:00
Eugene Kabanov
94ca0c3847
Fix remoteAddress() should raise TransportAbortedError too. (#409)
Add ENOTCONN as TransportAbortedError.
Refactor remoteAddress()/localAddress().
2023-06-26 16:31:09 +03:00
Eugene Kabanov
73fd1206ab
Disable HTTP/1.1 pipeline support for HTTP/S server by default. (#410)
* Disable HTTP/1.1 pipeline support for HTTP/S server by default.
Add tests.

* Fix tests according to new behavior.
Fix tests to use random assigned OS ports instead of predefined.

* Fix flaky tests in testasyncstream.
2023-06-26 16:28:33 +03:00
Tanguy
47016961f5
Less flaky rate limit tests (#408) 2023-06-23 10:11:14 +02:00
Jacek Sieka
0035f4fa66
Introduce chronos/futures (#405)
* move `Future[T]` into its own module along with some basic accessors
* mark all fields internal, exposing only read-only versions under the
old names
* introduce `init`/`completed`/etc as a way of creating a future (vs
newFuture)
* introduce `LocationKind` for `SrcLoc` access
* don't expose `FutureList` unless future tracking is enabled
* introduce `chronosStrictFutureAccess` which controls a number of
additional `Defect` being raised when accessing Future fields in the
wrong state - this will become true in a future version

In this version, `Future[T]` backwards compatibility code remains in
`asyncfutures2` meaning that if only `chronos/futures` is imported, only
"new" API is available.

This branch is a refinement / less invasive / minimal version of
https://github.com/status-im/nim-chronos/pull/373.
2023-06-07 20:04:07 +02:00
Jacek Sieka
1d6c309d77
clean up Defect (#404) 2023-06-05 22:21:50 +02:00
Jacek Sieka
2ef34c7339
ratelimit: set cancellation earlier (#402)
future may be completed by worker before cancellation is set
2023-06-05 13:47:38 +02:00
Jacek Sieka
a6ac5f2213
exception warning fixes (#403) 2023-06-05 13:03:38 +02:00
Jacek Sieka
157ca4fea5
Support implicit returns (#401)
* based on https://github.com/nim-lang/Nim/pull/21898
* also fixes generic Future[T] where T ends up being `void`
2023-06-05 13:02:13 +02:00
tersec
2c7774d982
drop support for Nim 1.2, 1.4, add Nim 2.0 to CI testing matrix (#378)
* add Nim 2.0 to CI testing matrix

* Deprecate 1.2 and 1.4 testing branches.

---------

Co-authored-by: cheatfate <eugene.kabanov@status.im>
2023-06-04 09:51:02 +02:00
Jacek Sieka
ba143e029f
version 3.2.0 (#399)
last version to support Nim 1.2, 1.4 - may receive critical backports
but otherwise this is EOL for said Nim versions
v3.2.0
2023-06-04 09:46:04 +02:00
Eugene Kabanov
6e80f16e0c
Fix recently introduced imports poisoning. (#400)
* Fix import poison introduced.

* Move export to handles, and annotate it.
2023-06-03 19:36:06 +03:00
Eugene Kabanov
02fda01bf2
Add facility to emulate signals on Windows. (#357)
* Initial Windows asyncproc part.
Deprecate usage of net/nativesockets in handles, asyncloop.
Introduce primitives with inheritable flag.

* Some posix fixes.

* More duplicate fixes.

* Fix AsyncProcessOption.EchoCommand option.
Remove isMainModule code.
Fix execCommand to use AsyncProcessOption.EvalCommand.

* Initial asyncproc tests commit.

* Some Posix fixes.

* Fix Posix crash.

* Add testsuite.
Fix osnet.nim to use proper declarations.
Fix timer.nim to use proper declarations.
Add Windows environment handling procedures.
Fix createAsyncPipe.
Add leaks tracking for AsyncProcessRef.

* Fix O_CLOEXEC constant value.

* Add file descriptors leak test.

* Remove commented code.
Refactor exceptions.
Fix compilation warnings.

* No exception ioselectors_kqueue initial commit.

* Some BSD fixes.
Linux refactoring of selectors.nim.

* Some fixes to move further.

* Last Linux fixes.

* Fixes for asyncloop to use 2nd version of selectors api.

* Add osutils.nim.

* Some fixes.

* Hardening resumeRead(), resumeWrite() and consumers.
Add ESRCH handling.
Introduce no-exception fromPipe2.

* Make Windows part exception-free and fix zombie race issue.

* createStreamServer() fixes.

* Upgrade asyncproc to use non-exception primitives.
Fix ioselectors_kqueue to use closeFd().

* Refactor accept() and acceptLoop() to be exception free.

* Deprecated some `result` usage.
Last fixes to make stream.nim exception free.
Use closeFd().
Refactor some loops to use handleEintr().

* Fix connect() forgot to unregister socket on error.

* All createAsyncSocket() sockets should be closed with unregisterAndCloseFd().

* Attempt to fix posix bug with incomplete output.

* Change number of runs in big test.

* Refactoring pipes creation. Attempt to fix "write error: Resource temporarily unavailable".

* Fix waitForExit(duration) code.
Fix test exit code.

* Fix Windows missing SIGTERM.

* Fix mistype.

* Fix compilation error.

* Attempt to fix Nim 1.6 issue.

* Eliminate Nim's WideCString usage to avoid any problems in future.

* Deprecate posix usage in osnet.

* Eliminate unused imports.

* Some debugging statements for investigation.

* Remove all the debugging statements.

* Remove testhelpers in favor of unittest2/asynctests.

* Fix flaky test.

* Make test more resilient to timings.

* Add memory size dump to CI.

* Refactor some blocks to use valueOr.
Make waitForExit to use kill() instead of terminate().

* Remove memory dumps.

* Fix peekProcessExitCode() blocks issue.

* Fix Windows issue.

* Add some debugging echoes.

* Fix compilation error.

* Add some debugging echoes.

* Add more helpers.

* Fix compilation error.

* waitForExit() is primary suspect.

* Remove fast-path for waitForExit.
Remove loop for reading signal events.

* Remove all debugging echoes.

* Return one debugging echo.

* Fix futures tests.

* Add test for multiple processes waiting to attempt stress test.

* Refactor ioselectors_epoll for better signalfd and process monitoring.
Add more race condition fixes to waitForExit.
Fix some Nim 1.6 warnings.

* Fix after rebase issues and warnings.

* Fix style issues.
Fix different Nim versions issues.
Workaround `signalfd` style issues.

* Add one more Linux signals workaround.
Add one more multiple processes test.

* Windows fixes.

* Remove unixPlatform define.
Fix WSAECONNABORTED for devel.

* Temporarily disable rate limit tests.
Fix more devel issues.

* Deprecate `hasThreadSupport` for ioselectors_kqueue.
Fix verifySelectParams issue.
Add exit codes test for multiple processes.
Fix osnet PtrToCstringConv warning.

* ioselectors_kqueue refactoring.

* Initial commit.

* Fix 1.2-1.4 compilation issue.

* Fix unused warning for testCtrlC() test.

* Post-rebase fixes.

* Restore master files.

* More fixes.

* Remove duplicates.

* Fix style mistake.

* Add more flexible pragmas.
2023-06-02 01:53:20 +03:00
Eugene Kabanov
315a27236c
Recover cancellation cleanup for AsyncEvent wait(). (#398)
* Recover cancellation cleanup for AsyncEvent wait().

* Address review comments.
2023-06-01 18:09:49 +03:00
gpicron
5be223e92c
allow reuse of port for UDP (#379) 2023-06-01 17:02:33 +03:00
Jacek Sieka
e436f20b33
Memory cleanups (#395)
* Avoid `FutureContinue` bloat by moving type punning into iterator
(which is typed anyway)
* clear closure iterator from future when iteration is done also on
cancellation / exception
* remove some redundant local variables in `await`
* document `futureContinue` flow
2023-05-31 07:24:25 +02:00