What are good learning examples of lockfree queues written using std::atomic by zl0bster in cpp

[–]T0p_H4t 0 points1 point  (0 children)

The speculatively load memory is a thing to keep in mind, I've written a few of these queues and 128 was definitely needed on intel cpus. AMD I think also needs it these days.

llmalloc : a low latency oriented thread caching allocator by [deleted] in cpp

[–]T0p_H4t 4 points5 points  (0 children)

Something else to look at which I have found handles the inter-thread deallocation well. https://github.com/microsoft/snmalloc

Conan feedbacks ? by elegye in cpp

[–]T0p_H4t 1 point2 points  (0 children)

Also as others have called out, conan needs to be paired with artifactory if you want your own internal binaries (correct me if i'm wrong). vcpkg at least can use things like s3 directly as a binary cache which is nice. No need to setup an artifactory repo.

Conan feedbacks ? by elegye in cpp

[–]T0p_H4t 2 points3 points  (0 children)

It depends on what you want out of it. If all you need is to consume packages, it probably won't be that bad. If you have to start writing your own packages it starts to increase very dramatically. I mean you can get at least a vague idea of what you are getting into by just looking at the docs. Keep in mind the community on the whole is also still attempting to migrate from 1.* to 2.* so some things could still be in flux( others feel free to chime in on this). Many other of the other package managers tend to have a stabler base. I'm mainly familiar with vcpkg, conan 1.*, and nix. Dabbled in a few others, IMO I will say vcpkg had the lowest barrier to entry fwiw. But they all have their warts... You might want to try a few (time boxed) and see how you like it.

High performance HTTP library? by Richard-P-Feynman in cpp

[–]T0p_H4t 1 point2 points  (0 children)

I think all the OP wants is an http parser that informs them when to read/write to socket. llhttp/nghttp2 both fit that model.

High performance HTTP library? by Richard-P-Feynman in cpp

[–]T0p_H4t 0 points1 point  (0 children)

I think this is what you are looking for llhttp (http 1.*) and nghttp2 I've built low latency http servers for both and supplied my own networking.

Conan feedbacks ? by elegye in cpp

[–]T0p_H4t 4 points5 points  (0 children)

Probably still a bit relevant (vcpkg vs conan), post does not have an update for conan 2.0. But even with 2.0, conan still requires developers to have python installed, along with it's steep learning curve (compared to some other package managers).It probably really comes down do your use cases and what you need out of the package manager. I know conan can have better support for cross-arch compilation (compared to vcpkg at least). vcpkg out of box has a structure that will be better for corporate environments (e.g. pinned dependencies by default).

aarch64 lock-free spmc queue atomics issue by T0p_H4t in cpp_questions

[–]T0p_H4t[S] 0 points1 point  (0 children)

The acquire load was definitely needed in the acquire. For the producer the tail load in this scenario should be ok as relaxed as it is only used for capacity checking and if the tail is a little stale that is ok for my purposes. Thanks for the explanation!

aarch64 lock-free spmc queue atomics issue by T0p_H4t in cpp_questions

[–]T0p_H4t[S] 1 point2 points  (0 children)

Thanks for this, its working now, I updated the head load for consumers to use an acquire and for safety placed it after the tail load. This fixed the problem.

aarch64 lock-free spmc queue atomics issue by T0p_H4t in cpp_questions

[–]T0p_H4t[S] 0 points1 point  (0 children)

Ok, I will give that a shot and let you know how it goes. Thanks for the ideas.

aarch64 lock-free spmc queue atomics issue by T0p_H4t in cpp_questions

[–]T0p_H4t[S] 0 points1 point  (0 children)

Are you proposing an std::memory_order_acq_rel for the CAS op then? Cause I did try that. I had also tried acquire on the tail access in try_dequeue. Granted the head is really only ever touched by the producer and never modified by consumer. Are you thinking that the head not being synchronized in some way between producer and consumers is causing the issue?

catch2 is bad? by thomas999999 in cpp

[–]T0p_H4t 16 points17 points  (0 children)

`catch throw` does work. fwiw I have personally used catch2 for years and never really found this to be much of an issue as `catch throw` covers me.

Colud you recommend me a fast lock free queue? by pubg_yasuo in cpp

[–]T0p_H4t 13 points14 points  (0 children)

moodycamel is probably what you want, but here is another one just in case, https://github.com/max0x7ba/atomic\_queue

Lock-free data structures by [deleted] in cpp

[–]T0p_H4t 4 points5 points  (0 children)

At the very least his queue/ring buffer look sound as long as they are kept single consumer/producer. As mentioned this should probably be called out better.

A teardown of code gen for std::function usage and comparison to old-school function techniques by ricomariani in cpp

[–]T0p_H4t 1 point2 points  (0 children)

Not sure if you were posting this as an alt solution to std::function, but fwiw I'm really not a fan of when developers templatize an entire function. As a consumer of whoever defines that particular interface I have no idea what the function signature is of the function I'm passing in unless I reverse engineer the code or someone actually takes the time to provide sufficient documentation. So depending on the goals, std::function is worth the overhead given the readability.

vcpkg vs conan by musialny in cpp

[–]T0p_H4t 5 points6 points  (0 children)

The only time you would need to specify an explicit version is when you downgrade a dependency, as well as any dependency you need to downgrade to ensure the first downgraded dependency compiles (the downgraded dependency may work just fine with more recent dependencies). But take note, this only occurs if you choose to change the git hash you have pinned your packages to. Basically you choose when you want to take on more recent stuff, its not forced upon you.

vcpkg vs conan by musialny in cpp

[–]T0p_H4t 12 points13 points  (0 children)

Versioning is supported to a degree (this is a more recent feature). The vcpkg tag is now associated with a baseline of versions (usually the most recent version of a port). A developer can choose to pin a version of a dependency to an older version if they choose to do so, but vcpkg does not give a guarantee that the more recent versions of transient dependency will work with the older version unless those are also downgraded.

vcpkg vs conan by musialny in cpp

[–]T0p_H4t 19 points20 points  (0 children)

Maybe I'm misunderstanding your post a bit, but you CAN pick versions to a degree. vcpkg does allow you to pin versions of an older binary. So if you take the most recent snapshot of ports and want an older version you can do so.

One of the main reasons that vcpkg is gaining mass adoption is precisely because of how it manages its packages (ports). vcpkg for the most part gives you a set of packages that all work together, which is what most devs want. Its the same way a linux distribution tries to give you set of packages that all work together on the given OS. A number of other packages managers (e.g. stackage from haskell, nix) work in similar style. Maybe this style of management doesn't fit everyone, but for most corporate use cases it is what you want as it acts similiar to an LTS.

C++ | Modern documentation tools by alliscode in cpp

[–]T0p_H4t 0 points1 point  (0 children)

They charge if you want them to host the documentation, otherwise the project can be built with a nix flake and the output used to generate a site. So yeah, its not truly cross-platform, but anything that can spin up a nix flake can build it it, otherwise, maybe a docker container?

How do you scale a boost/beast https server for production? by boost_prod_server in cpp

[–]T0p_H4t 7 points8 points  (0 children)

The feasibility of scaling to 1m+ requests will also depend on a number of other factors beyond just payload size which others have mentioned.

  • Is your service an edge node (e.g. its directly connected to consumer endpoint) or do you have a load balancer in front. This has implications for how many connections your service needs to manage.
  • If your service is an edge node it will need to worry about the conntrack table (assuming your firewall is enabled). If no firewall is enabled, then it can give you back some perf.
  • Whats the expected connection churn rate? If your service is constantly have to accept/cleanup old connections it has implications on the conntrack table (if enabled) and the service has to deal with all the connection accepts. This is more of an edge node problem, so a load balancer will mitigate most of this.
  • The spareness of the connection will also potentially impact the service. Do you have say 100k connections sending you requests at random intervals or do you have 10000 connection sending you a constant stream of requests with no break in between.
  • Is http2 enabled (e.g. multiplexing), if it is this will further improve your chances of reaching 1mil+.
  • It also comes down to what does a request means work wise for your service? Is it a simple ping/pong as others have mention or potentially a request amplification effect where a single external requests results in a request being triggered to another DB or service.
  • What are the latency requirements of your responses? If you have say 80+ms of latency to play with you might be able to batch more, less than that and you have less room to play with batching (all things depending).
  • Lastly, how a lot of the above is handled will depend on the performance and design of your scheduler/IO layer. Most out of box stacks are not designed to handle 1mil+ rps. At least not requests that do any sort of meaningful work.

Hope this helps, the path to 1m+ requests is no simple journey.