[Daniel's week] February 21, 2025
Daniel Stenberg
daniel at haxx.se
Fri Feb 21 16:34:27 CET 2025
Hello friends,
Happy Friday. Here follows some of what I did this week.
## strparse
A few releases ago I removed the last few uses of the sscanf() function. To do that nicely, I introduced a small set of string parsing helper functions to curl that I call “strparse”.
Once I had introduced strparse into libcurl, I could gradually start converting other “handcrafted” text parser over to using the new function family instead. Because it makes the code both smaller and easier to read, and in some cases also probably a bit more robust.
I also initially added a 32-bit decimal number parser with built-in max limit check to parse for example port numbers in the alt-svc cache.
This week I converted the decimal number parser to deal with 64-bit numbers, as its API is a little more convenient to use than our previous takes: it handles overflow detection easier and better, and it has this max value check. I converted several old number parsing use cases over to this new parser for those reasons.
Why stop at just a decimal number parser? I added support for hexadecimal and octal as well, as those are bases we parse in curl code. This could make me remove all uses of strtol() and strtoul() from libcurl and now at last be fairly sure all uses have a decent approach to overflows \- and with a set maximum value for every use. And a better control that they all work with up to 64-bit numbers as they should \- using “long” for that since it is always 32-bit on Windows.
Converting numbers from ASCII to binary is not really something that is speed sensitive for curl but I wrote up a small test program to benchmark how fast these new functions performed hexadecimal, decimal and octal conversions. Then I tested different approaches to make them faster. The goal was still to keep the function small and easy to read with performance perhaps being number three in the priority list. After some experiments I made the hexadecimal parser 2.3 times faster, and actually noticeably faster than strtoll() on my machine. The decimal and octal parsing is still slower than glibc though. Still fast enough for us I believe.
I continue to move forward and will convert more libcurl parser code over to use strparse. It helps with cleaning up functions and makes them end up more approachable.
## Changing three times
I wrote a blog post[^1] about the observation that we seem to write each line of code about three times, even though the total number of lines of code has increased significantly over time.
## curl up 2025
I have booked flights and hotel stay for curl up 2025 in Prague[^2]. The list of proposed sessions/talks at the event is slowly starting to build up and I hope I can entice more people to contribute. It does not have to be anything long, big or complicated, but getting more voices to speak would be valuable.
## Cursor AI
I have toyed around a bit with the AI editor called “cursor AI”[^3] through the last week or so. I can see how having an AI developer assistant that I can query about code and ask for advice for performance enhancements etc is handy. I did try to ask it for suggested improvements for several curl functions and while it often suggests a complete solution that is not suitable, there are often some bread crumbs in the proposals that can be extracted and used.
Some of the problems with its suggested solutions include that A) it likes to offer C code that is not C89, and since curl is stuck on the old version we can’t use code written for later C versions B) It is fond of creating code that only works on specific architectures, for example little-endian and platforms that can do unaligned memory accesses etc. Rather subtle, I know, but for a curl developer important details. Also, it does not really KNOW what is faster so quite often when asking it for a faster version of a particular function, it answers confidently and provides a well-commented function with the same basic functionality but it does not execute faster than the original version I pasted it.
Ironically, what I find is one of the biggest hurdles preventing me from using cursor AI more is that it is built on VS code and I find it a hideous editor to work with. My fingers, spine and entire developer life is so accustomed to emacs that I feel handicapped and severely slowed down when I try to actually write code and use this editor for typing, replacing, etc rather than just asking the AI questions.
I will probably keep trying out these tools to see if and how they can help us make curl better.
## Feature window
Tomorrow Saturday we are yet again opening the curl feature window, and this time it will be open for merging new things into curl for two weeks. One week shorter than normal because the previous patch release shortened this release cycle somewhat[^4]. Typically that should not be a problem, because features that are up for merging should already be more or less done and ready when the window opens and two weeks should then be plenty of time to iron out the wrinkles that might occur when multiple pull-requests tramble on each other when getting merged into the master branch.
## RELEASE NOTES
Friday morning I did a video walk-through of the procedures I have and do when I update the curl RELEASE-NOTES document[^5]. I have been meaning to write a detailed blog post about it for a while, and I will probably still do it soon as a complement to this video version.
## OpenSSL QUIC API
I touched the subject briefly in my email last week, and I then subsequently wrote a blog post about the subject[^6], I think maybe primarily because I find their decisions and way to go about with this so strange. When they finally provide a QUIC API for all the QUIC stacks, as has been wanted for many years by now, they do it in a way nobody wants and that lacks fundamental features.
## Weekly done differently
This week I’m trying a different way to write my weekly email with a perhaps easier way to spell and grammar check, combined with working footnotes/links. It might make it look slightly different. This version is written in Google docs and then saved as markdown.
## Coming up
- The feature window opens tomorrow
- The second monthly “help us in curl” email goes out on Tuesday
- Work on content for my curl Roadmap 2025 webinar planned for March 6
[^1]: https://daniel.haxx.se/blog/2025/02/18/changing-every-line-three-times/
[^2]: https://github.com/curl/curl-up/wiki/2025
[^3]: https://www.cursor.com/
[^4]: https://everything.curl.dev/project/releases.html\#release-cycle
[^5]: https://youtu.be/sElmQtHoo5Y
[^6]: https://daniel.haxx.se/blog/2025/02/16/openssl-does-a-quic-api/
--
/ daniel.haxx.se || https://rock-solid.curl.dev
More information about the daniel
mailing list