72 Commits

Author SHA1 Message Date
Jacek Sieka
ef1b077adf
v4.0.2 2024-03-25 10:38:37 +01:00
Jacek Sieka
0e806d59ae
v4.0.1 2024-03-21 09:21:51 +01:00
Eugene Kabanov
d4f1487b0c
Disable libbacktrace enabled test on X86 platforms. (#523)
* Disable libbacktrace enabled test on X86 platforms.

* Fix mistype.

* Use macos-12 workers from now.
2024-03-19 16:28:52 +00:00
Eugene Kabanov
7b02247ce7
Add --mm:refc to libbacktrace test. (#505)
* Add `--mm:refc` to `libbacktrace` test.

* Make tests with `refc` to run before tests with default memory manager.
2024-02-14 19:23:15 +02:00
Jacek Sieka
8cf2d69aaa
Minimal threading docs (#493)
* Minimal threading docs

* compile examples with threads

* links
2024-02-14 08:27:09 +01:00
Jacek Sieka
672db137b7
v4.0.0 (#494)
Features:

* Exception effects / raises for async procedures helping you write more
efficient leak-free code
* Cross-thread notification mechanism for suitable building channels,
queues and other multithreaded primitives
* Async process I/O
* IPv6 dual stack support
* HTTP middleware support alloing multiple services to share a single
http server
* A new [documentation web
site](https://status-im.github.io/nim-chronos/) covering the basics,
with several simple examples for getting started
* Implicit returns, support for `results.?` and other conveniences
* Rate limiter
* Revamped cancellation support with more control over the cancellation
process
* Efficiency improvements with `lent` and `sink`

See the [porting](https://status-im.github.io/nim-chronos/porting.html)
guides for porting code from earlier chronos releases (as well as
asyncdispatch)
2024-01-24 19:33:13 +02:00
Jacek Sieka
24be151cf3
move docs to docs (#466)
* introduce user guide based on `mdbook`
* set up structure for adding simple `chronos` usage examples
* move most readme content to book
* ci deploys book and api guide automatically
* remove most of existing engine docs (obsolete)
2023-11-15 09:06:37 +01:00
Jacek Sieka
0d55475c29
stew/results -> results (#468) 2023-11-13 10:56:19 +01:00
Jacek Sieka
f0eb7a0ae9
simplify tests (#469)
* simplify tests

`chronosPreviewV4` is obsolete

* oops
2023-11-13 10:54:37 +01:00
Jacek Sieka
53690f4717
run tests outside of nim compilation (#463)
else we need memory for both compiler and test
2023-11-08 16:14:33 +01:00
Tanguy
a759c11ce4
Raise tracking (#251)
* Exception tracking v2

* some fixes

* Nim 1.2 compat

* simpler things

* Fixes for libp2p

* Fixes for strictException

* better await exception check

* Fix for template async proc

* make async work with procTy

* FuturEx is now a ref object type

* add tests

* update test

* update readme

* Switch to asyncraises pragma

* Address tests review comments

* Rename FuturEx to RaiseTrackingFuture

* Fix typo

* Split asyncraises into async, asyncraises

* Add -d:chronosWarnMissingRaises

* Add comment to RaiseTrackingFuture

* Allow standalone asyncraises

* CheckedFuture.fail type checking

* First cleanup

* Remove useless line

* Review comments

* nimble: Remove #head from unittest2

* Remove implict raises: CancelledError

* Move checkFutureExceptions to asyncfutures2

* Small refacto

* small cleanup

* Complete in closure finally

* cleanup tests, add comment

* bump

* chronos is not compatible with nim 1.2 anymore

* re-add readme modifications

* fix special exception handlers

* also propagate excetion type in `read`

* `RaiseTrackingFuture` -> `InternalRaisesFuture`

Use internal naming scheme for RTF (this type should only be accessed
via asyncraises)

* use `internalError` for error reading

* oops

* 2.0 workarounds

* again

* remove try/finally for non-raising functions

* Revert "remove try/finally for non-raising functions"

This reverts commit 86bfeb5c972ef379a3bd34e4a16cd158a7455721.

`finally` is needed if code returns early :/

* fixes

* avoid exposing `newInternalRaisesFuture` in manual macro code
* avoid unnecessary codegen for `Future[void]`
* avoid reduntant block around async proc body
* simplify body generation for forward declarations with comment but no
body
* avoid duplicate `gcsafe` annotiations
* line info for return at end of async proc

* expand tests

* fix comments, add defer test

---------

Co-authored-by: Jacek Sieka <jacek@status.im>
2023-10-17 14:18:14 +02:00
Eugene Kabanov
6b4f5a1d23
Recover poll engine and add tests. (#421)
* Initial commit.

* Fix one more place with deprecated constant.

* Fix testall and nimble file.

* Fix poll issue.

* Workaround Nim's faulty declaration of `poll()` and types on MacOS.

* Fix syntax errors.

* Fix MacOS post-rebase issue.

* Add more conditionals.

* Address review comments.

* Fix Nim 1.2 configuration defaults.
2023-08-01 12:56:08 +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
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
2023-06-04 09:46:04 +02:00
Jacek Sieka
229de5f842
Compile-time configuration (#371)
This PR moves all compile-time configuration to a single module,
simplifying documentation and access to these features.

Upcomfing features may be enabled either individually, or through a new
`chronosPreviewV4` catch-all designed to allow code to be prepared for
increased strictness in future chronos releases.

`-d:chronosDebug` may be used to enable the existing debugging helpers
together.
2023-03-31 07:35:04 +02:00
Eugene Kabanov
1394c9e049
IOSelectors refactoring to properly support signals and processes. (AsyncProc 2) (#366)
* ioselectors_epoll() refactoring.

* ioselectors_kqueue() refactoring.

* ioselectors_poll() initial refactor.

* Remove `s.count` because it inconsistent and not used in `chronos`.

* Remove Windows version of select() engine.

* Add ability to switch event queue engine via `asyncEventEngine` command line option.

* Make it possible to switch between engines.

* Fix epoll regression.

* Fix poll() engine issues.

* Address review comments.

* Add proper trick.

* Address review comments.

* Bump version to 3.1.0.
2023-03-24 17:52:55 +02:00
Jacek Sieka
189f6e390c
normalise nimble file (#331)
* normalise nimble file

* abort redundant builds

* bump checkout
2022-11-23 06:54:10 +01:00
Ivan Yonchovski
59f611f0fc
Use unittest2 directly (#291) 2022-06-29 17:22:57 +03:00
Ștefan Talpalaru
17fed89c99
style fixes (#253)
* style fixes

and disable the cron CI job
2022-01-04 23:14:30 +01:00
Jacek Sieka
0fc82049ac enable --styleCheck:usages 2021-12-27 17:33:25 +02:00
Jacek Sieka
c25fa1f6cd
posix: fast path for write (#244)
When `write` is called on a `StreamTransport`, the current sequence of
operations is:

* copy data to queue
* register for "write" event notification
* return unfinished future to `write` caller
* wait for "write" notification (in `poll`)
* perform one `send`
* wait for notification again if there's more data to write
* complete the future

In this PR, we introduce a fast path for writing:

* If the queue is empty, try to send as much data as possible
  * If all data is sent, return completed future without `poll` round
  * If there's more data to send than can be sent in one go, add the
rest to queue
* If the queue is not empty, enqueue as above
* When notified that write is possible, keep writing until OS buffer is
full before waiting for event again

The fast path provides significant performance benefits when there are
many small writes, such as when sending gossip to many peers, by
avoiding the poll loop and data copy on each send.

Also fixes an issue where the socket would not be removed from the
writer set if there were pending writes on close.
2021-12-08 11:35:27 +01:00
Eugene Kabanov
7da1f5d4d2
Bump version to 3.0.9. (#249) 2021-12-03 15:32:58 +02:00
Ștefan Talpalaru
25ccbb0beb
version 3.0.8 2021-11-20 01:31:09 +01:00
Ștefan Talpalaru
b24ee653d3
version 3.0.7 2021-11-19 01:08:55 +01:00
Miran
3697426f85
properly move testing libbacktrace to a separate task (#236)
This is a continuation of #231.
2021-11-15 11:40:49 +01:00
Ștefan Talpalaru
df980dd713
CI: separate libbacktrace test in its own task (#231) 2021-11-08 19:09:06 +02:00
Eugene Kabanov
ef2430d08d
Add Accept header handling to httpserver.nim. (#211)
* Add `Accept` header handling to httpserver.nim.
Add simple test suite.
Bump version to 3.0.6.

* Fix compilation error.
2021-07-28 17:08:38 +03:00
Eugene Kabanov
15137f71c3
Basic authorization implementation for HTTP client. (#204)
* Basic authorization implementation for HTTP client.
Add tests for basic authorization.

* Bump chronos version to 3.0.5.
2021-06-29 02:38:08 +03:00
Eugene Kabanov
7ccb170f7a
Enable comma as array delimiter and adding tests. (#191)
* Enable comma as array delimiter and adding tests.

* Bump version to 3.0.4.
2021-05-17 22:39:24 +03:00
cheatfate
67f0f1224f
Bump nimble version.
Make some useful fields public.
2021-05-10 10:40:56 +03:00
Ștefan Talpalaru
c15c985c1f
support nimStackTraceOverride (#181) 2021-05-06 09:49:55 +02:00
Eugene Kabanov
aab1e30a72
Refactor common.nim and add more resolve procedures. (#177)
* Refactor common.nim to remove `result` usage.
Fix comparison of TransportAddress issue.
Add resolveTAddress procedures for both IPv4 and IPv6 addresses.
Fix tests.

* Bump version to 3.0.2.
2021-04-10 00:39:54 +03:00
Jacek Sieka
895fc53193
add explicit gcsafe annotations (fixes #174) (#175)
Seems like a variation of https://github.com/nim-lang/Nim/issues/17369
2021-04-03 10:05:08 +02:00
Jacek Sieka
4abd7a5645
exception tracking (#166)
* exception tracking

This PR adds minimal exception tracking to chronos, moving the goalpost
one step further.

In particular, it becomes invalid to raise exceptions from `callSoon`
callbacks: this is critical for writing correct error handling because
there's no reasonable way that a user of chronos can possibly _reason_
about exceptions coming out of there: the event loop will be in an
indeterminite state when the loop is executing an _random_ callback.

As expected, there are several issues in the error handling of chronos:
in particular, it will end up in an inconsistent internal state whenever
the selector loop operations fail, because the internal state update
functions are not written in an exception-safe way. This PR turns this
into a Defect, which probably is not the optimal way of handling things
- expect more work to be done here.

Some API have no way of reporting back errors to callers - for example,
when something fails in the accept loop, there's not much it can do, and
no way to report it back to the user of the API - this has been fixed
with the new accept flow - the old one should be deprecated.

Finally, there is information loss in the API: in composite operations
like `poll` and `waitFor` there's no way to differentiate internal
errors from user-level errors originating from callbacks.

* store `CatchableError` in future
* annotate proc's with correct raises information
* `selectors2` to avoid non-CatchableError IOSelectorsException
* `$` should never raise
* remove unnecessary gcsafe annotations
* fix exceptions leaking out of timer waits
* fix some imports
* functions must signal raising the union of all exceptions across all
platforms to enable cross-platform code
* switch to unittest2
* add `selectors2` which supercedes the std library version and fixes
several exception handling issues in there

* fixes

* docs, platform-independent eh specifiers for some functions

* add feature flag for strict exception mode

also bump version to 3.0.0 - _most_ existing code should be compatible
with this version of exception handling but some things might need
fixing - callbacks, existing raises specifications etc.

* fix AsyncCheck for non-void T
2021-03-24 10:08:33 +01:00
Eugene Kabanov
f774644129
Fix integer decoding overflow issue. (#163)
Switch to stew.base10 procedures.
Adjust tests to follow new behavior.
Bump version to 2.6.1.
2021-03-06 00:22:32 +02:00
Andreas Rumpf
1324b2f787
Enable --gc:orc testing for nim-chronos (#161)
* enable --gc:orc testing on nim devel (1.5.x)
2021-03-03 20:04:09 +02:00
cheatfate
1243aef627
Bump chronos version to 2.6.0. 2021-03-02 15:27:42 +02:00
cheatfate
789a5f8252 Fix dependency name. 2021-02-18 22:16:04 +02:00
cheatfate
53aec163eb Fix nimble dependencies. 2021-02-18 22:16:04 +02:00
Eugene Kabanov
a5442edfc0
Add asyncSpawn() procedure and tests. (#123)
Deprecated asyncDiscard() procedure.
Bump version to 2.5.2.
2020-09-01 21:41:18 +03:00
Zahary Karadjov
e6d50b7736 Revert "some metrics for monitoring futures (#85)"
This reverts commit e45ef32b5b7b1ed49ffcc52f39f42b7c30fab564.

Metrics implemented this way, with a lock inside the otherwise tight
event loop are not consistent with the chronos architecture that for
good or bad uses thread local variables to avoid them - the solution
does not have rough consensus behind it, and other avenues should be
explored for this generally useful functionality.
2020-08-16 01:48:25 +03:00
Ștefan Talpalaru
e45ef32b5b
some metrics for monitoring futures (#85) 2020-08-06 19:30:53 +02:00
Jacek Sieka
f856c885fa
fix endian conversion issues (#82)
* fixes call to `bigEndian32` on a uint64 which breaks on big endian
platforms
* prefer endians2 for less and safer code
2020-07-12 18:22:47 +02:00
Jacek Sieka
8b8a1e793d
bump supported nim version 2020-07-12 18:20:21 +02:00
Eugene Kabanov
ce6e7d17b1
Make Future tracking and stack traces optional (#108)
* Make Future tracking optional via -d:chronosDutureTracking compilation flag.
* Stack traces is now optional, use -d:chronosStackTraces.
* Fix mistypes and add test for chronosStackTrace option.
2020-07-08 19:48:01 +03:00
Eugene Kabanov
5629b3c41f
[WIP] Zero-cost unattended Future[T] tracking mechanism. (#106)
* Zero-cost unattended Future[T] tracking mechanism with tests and tracking of test suite.
2020-07-06 09:33:13 +03:00
Eugene Kabanov
319e2bfc09
Fix Nim's issue #13899 using #14723 and add tests. (#104) 2020-06-24 13:03:36 +03:00
Eugene Kabanov
02b8da986b
Add accept() call (#103)
* Add accept() call and tests.
* Fix rare fd leaks on Windows.
* Fix compilation warnings.
* Add fd leak test.
* Bump version to 2.4.0.
2020-06-24 11:21:52 +03:00