From: "matz (Yukihiro Matsumoto) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "matz (Yukihiro Matsumoto)" <noreply@ruby-lang.org>
Subject: [ruby-core:119058] [Ruby master Feature#20707] Move `Time#xmlschema` into core
Date: Thu, 05 Sep 2024 07:39:13 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-109636.20240905073913.7941@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-20707.20240830145001.7941@ruby-lang.org>
Issue #20707 has been updated by matz (Yukihiro Matsumoto).
Accepted.
Matz.
----------------------------------------
Feature #20707: Move `Time#xmlschema` into core
https://bugs.ruby-lang.org/issues/20707#change-109636
* Author: byroot (Jean Boussier)
* Status: Open
----------------------------------------
### Performance
Converting `Time` into `RFC3339 / ISO8601` representation is an significant hotspot for application that serialize data in JSON, XML or other formats.
Right now this feature is currently available through the `time` default gem, so it rely on `Time#strftime`.
While [`strftime` could certainly be optimized](https://github.com/ruby/ruby/pull/11508), ultimately it's a very generic API so can't make a lot of assumptions about the output.
Whereas `ISO8601` is a very strict format, with very few dynamic part, so it's much easier for dedicated code to be well optimized, as the final size of the string can be computed upfront etc.
[I experimented with this and was able to get a ~5x speedup with a fairly straightforward implementation](https://github.com/ruby/ruby/pull/11510).
```
compare-ruby: ruby 3.4.0dev (2024-08-29T13:11:40Z master 6b08a50a62) +YJIT [arm64-darwin23]
built-ruby: ruby 3.4.0dev (2024-08-30T13:17:32Z native-xmlschema 34041ff71f) +YJIT [arm64-darwin23]
warming up......
| |compare-ruby|built-ruby|
|:-----------------------|-----------:|---------:|
|time._xmlschema | 1.087M| 5.190M|
| | -| 4.78x|
|utc_time._xmlschema | 1.464M| 6.848M|
| | -| 4.68x|
|time._xmlschema(6) | 859.960k| 4.646M|
| | -| 5.40x|
|utc_time._xmlschema(6) | 1.080M| 5.917M|
| | -| 5.48x|
|time._xmlschema(9) | 893.909k| 4.668M|
| | -| 5.22x|
|utc_time._xmlschema(9) | 1.056M| 5.707M|
| | -| 5.40x|
```
### Usability
Aside from the performance reason, `ISO8601` is so common that having this functionality built-in without needing to require anything would make sense to me.
`xmlschema` is the most common reason why I require `time`, and in many case having it core would allow not to load it at all.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
prev parent reply other threads:[~2024-09-05 7:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-30 14:50 [ruby-core:118994] " byroot (Jean Boussier) via ruby-core
2024-09-05 7:39 ` matz (Yukihiro Matsumoto) via ruby-core [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-109636.20240905073913.7941@ruby-lang.org \
--to=ruby-core@ml.ruby-lang.org \
--cc=noreply@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).