* [ruby-core:118994] [Ruby master Feature#20707] Move `Time#xmlschema` into core
@ 2024-08-30 14:50 byroot (Jean Boussier) via ruby-core
2024-09-05 7:39 ` [ruby-core:119058] " matz (Yukihiro Matsumoto) via ruby-core
0 siblings, 1 reply; 2+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2024-08-30 14:50 UTC (permalink / raw)
To: ruby-core; +Cc: byroot (Jean Boussier)
Issue #20707 has been reported by byroot (Jean Boussier).
----------------------------------------
Feature #20707: Move `Time#xmlschema` into core
https://bugs.ruby-lang.org/issues/20707
* 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/
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ruby-core:119058] [Ruby master Feature#20707] Move `Time#xmlschema` into core
2024-08-30 14:50 [ruby-core:118994] [Ruby master Feature#20707] Move `Time#xmlschema` into core byroot (Jean Boussier) via ruby-core
@ 2024-09-05 7:39 ` matz (Yukihiro Matsumoto) via ruby-core
0 siblings, 0 replies; 2+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-core @ 2024-09-05 7:39 UTC (permalink / raw)
To: ruby-core; +Cc: matz (Yukihiro Matsumoto)
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-05 7:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-30 14:50 [ruby-core:118994] [Ruby master Feature#20707] Move `Time#xmlschema` into core byroot (Jean Boussier) via ruby-core
2024-09-05 7:39 ` [ruby-core:119058] " matz (Yukihiro Matsumoto) via ruby-core
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).