ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:120869] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values?
@ 2025-02-03 13:02 andrykonchin (Andrew Konchin) via ruby-core
  2025-02-03 13:08 ` [ruby-core:120870] " Eregon (Benoit Daloze) via ruby-core
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: andrykonchin (Andrew Konchin) via ruby-core @ 2025-02-03 13:02 UTC (permalink / raw)
  To: ruby-core; +Cc: andrykonchin (Andrew Konchin)

Issue #21110 has been reported by andrykonchin (Andrew Konchin).

----------------------------------------
Misc #21110: Should Marshal.dump always use object links for repeated Float values?
https://bugs.ruby-lang.org/issues/21110

* Author: andrykonchin (Andrew Konchin)
* Status: Open
----------------------------------------
I've noticed (during the downstreaming ruby/spec in https://github.com/ruby/ruby/pull/12679) that a repeated Float value may be dumped "directly"/"immediately" without an objct link on x86 architecture, and with a link in other cases. It seems it depends on whether Float is `Flonum` or not.

amd64:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060@\x06", where @\x06 is an object link
```

i686:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060f\x060", so f\x060 is dumped twice
```

Both dumps are loaded correctly, so it seems there is no any compatibility issue.

Should dumping be consistent and don't depend on architecture?



-- 
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] 6+ messages in thread

* [ruby-core:120870] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values?
  2025-02-03 13:02 [ruby-core:120869] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values? andrykonchin (Andrew Konchin) via ruby-core
@ 2025-02-03 13:08 ` Eregon (Benoit Daloze) via ruby-core
  2025-02-03 14:51 ` [ruby-core:120871] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2025-02-03 13:08 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #21110 has been updated by Eregon (Benoit Daloze).


IMO Marshal should not depend on obscure implementation details like Flonum, i.e. Float whether fitting in a Flonum or not should be dumped the same with Marshal.
What do others think?

----------------------------------------
Misc #21110: Should Marshal.dump always use object links for repeated Float values?
https://bugs.ruby-lang.org/issues/21110#change-111743

* Author: andrykonchin (Andrew Konchin)
* Status: Open
----------------------------------------
I've noticed (during the downstreaming ruby/spec in https://github.com/ruby/ruby/pull/12679) that a repeated Float value may be dumped "directly"/"immediately" without an objct link on x86 architecture, and with a link in other cases. It seems it depends on whether Float is `Flonum` or not.

amd64:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060@\x06", where @\x06 is an object link
```

i686:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060f\x060", so f\x060 is dumped twice
```

Both dumps are loaded correctly, so it seems there is no any compatibility issue.

Should dumping be consistent and don't depend on architecture?



-- 
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] 6+ messages in thread

* [ruby-core:120871] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values?
  2025-02-03 13:02 [ruby-core:120869] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values? andrykonchin (Andrew Konchin) via ruby-core
  2025-02-03 13:08 ` [ruby-core:120870] " Eregon (Benoit Daloze) via ruby-core
@ 2025-02-03 14:51 ` nobu (Nobuyoshi Nakada) via ruby-core
  2025-02-03 15:20 ` [ruby-core:120872] " Eregon (Benoit Daloze) via ruby-core
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2025-02-03 14:51 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #21110 has been updated by nobu (Nobuyoshi Nakada).


I agree that `Marshal` should not depend on the details.
At least, `Float` should be distinguished only by its value, not its object ID.

OTOH, dump of `Float` is often longer:
```ruby
Marshal.dump(Math.log(324.0)) #=> "\x04\bf\x165.780743515792329"
```
So it may use with a link just for deduplication, I think.

----------------------------------------
Misc #21110: Should Marshal.dump always use object links for repeated Float values?
https://bugs.ruby-lang.org/issues/21110#change-111747

* Author: andrykonchin (Andrew Konchin)
* Status: Open
----------------------------------------
I've noticed (during the downstreaming ruby/spec in https://github.com/ruby/ruby/pull/12679) that a repeated Float value may be dumped "directly"/"immediately" without an object link on x86 architecture, and with a link in other cases. It seems it depends on whether Float is `Flonum` or not.

amd64:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060@\x06", where @\x06 is an object link
```

i686:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060f\x060", so f\x060 is dumped twice
```

Both dumps are loaded correctly, so it seems there is no any compatibility issue.

Should dumping be consistent and don't depend on architecture?

>From https://github.com/ruby/ruby/pull/12679#discussion_r1937116017



-- 
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] 6+ messages in thread

* [ruby-core:120872] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values?
  2025-02-03 13:02 [ruby-core:120869] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values? andrykonchin (Andrew Konchin) via ruby-core
  2025-02-03 13:08 ` [ruby-core:120870] " Eregon (Benoit Daloze) via ruby-core
  2025-02-03 14:51 ` [ruby-core:120871] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2025-02-03 15:20 ` Eregon (Benoit Daloze) via ruby-core
  2025-02-05 11:17 ` [ruby-core:120881] " nobu (Nobuyoshi Nakada) via ruby-core
  2025-02-09  9:15 ` [ruby-core:120924] " herwin (Herwin W) via ruby-core
  4 siblings, 0 replies; 6+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2025-02-03 15:20 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #21110 has been updated by Eregon (Benoit Daloze).


Right, I think always adding a link makes sense.
Then the logic for flonum/not-flonum should be identical (as shown [here](https://github.com/ruby/ruby/pull/12679#discussion_r1937116017)).

----------------------------------------
Misc #21110: Should Marshal.dump always use object links for repeated Float values?
https://bugs.ruby-lang.org/issues/21110#change-111748

* Author: andrykonchin (Andrew Konchin)
* Status: Open
----------------------------------------
I've noticed (during the downstreaming ruby/spec in https://github.com/ruby/ruby/pull/12679) that a repeated Float value may be dumped "directly"/"immediately" without an object link on x86 architecture, and with a link in other cases. It seems it depends on whether Float is `Flonum` or not.

amd64:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060@\x06", where @\x06 is an object link
```

i686:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060f\x060", so f\x060 is dumped twice
```

Both dumps are loaded correctly, so it seems there is no any compatibility issue.

Should dumping be consistent and don't depend on architecture?

>From https://github.com/ruby/ruby/pull/12679#discussion_r1937116017



-- 
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] 6+ messages in thread

* [ruby-core:120881] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values?
  2025-02-03 13:02 [ruby-core:120869] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values? andrykonchin (Andrew Konchin) via ruby-core
                   ` (2 preceding siblings ...)
  2025-02-03 15:20 ` [ruby-core:120872] " Eregon (Benoit Daloze) via ruby-core
@ 2025-02-05 11:17 ` nobu (Nobuyoshi Nakada) via ruby-core
  2025-02-09  9:15 ` [ruby-core:120924] " herwin (Herwin W) via ruby-core
  4 siblings, 0 replies; 6+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2025-02-05 11:17 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #21110 has been updated by nobu (Nobuyoshi Nakada).


https://github.com/ruby/ruby/pull/12703

----------------------------------------
Misc #21110: Should Marshal.dump always use object links for repeated Float values?
https://bugs.ruby-lang.org/issues/21110#change-111757

* Author: andrykonchin (Andrew Konchin)
* Status: Open
----------------------------------------
I've noticed (during the downstreaming ruby/spec in https://github.com/ruby/ruby/pull/12679) that a repeated Float value may be dumped "directly"/"immediately" without an object link on x86 architecture, and with a link in other cases. It seems it depends on whether Float is `Flonum` or not.

amd64:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060@\x06", where @\x06 is an object link
```

i686:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060f\x060", so f\x060 is dumped twice
```

Both dumps are loaded correctly, so it seems there is no any compatibility issue.

Should dumping be consistent and don't depend on architecture?

>From https://github.com/ruby/ruby/pull/12679#discussion_r1937116017



-- 
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] 6+ messages in thread

* [ruby-core:120924] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values?
  2025-02-03 13:02 [ruby-core:120869] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values? andrykonchin (Andrew Konchin) via ruby-core
                   ` (3 preceding siblings ...)
  2025-02-05 11:17 ` [ruby-core:120881] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2025-02-09  9:15 ` herwin (Herwin W) via ruby-core
  4 siblings, 0 replies; 6+ messages in thread
From: herwin (Herwin W) via ruby-core @ 2025-02-09  9:15 UTC (permalink / raw)
  To: ruby-core; +Cc: herwin (Herwin W)

Issue #21110 has been updated by herwin (Herwin W).


nobu (Nobuyoshi Nakada) wrote in #note-3:
> At least, `Float` should be distinguished only by its value, not its object ID

Bigint has similar behaviour:
``` ruby
Marshal.dump([2**64, 2**64]) #=> "\x04\b[\al+\n\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00l+\n\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00"
Marshal.dump([n=2**64, n]) #=> "\x04\b[\al+\n\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00@\x06"
```


----------------------------------------
Misc #21110: Should Marshal.dump always use object links for repeated Float values?
https://bugs.ruby-lang.org/issues/21110#change-111807

* Author: andrykonchin (Andrew Konchin)
* Status: Open
----------------------------------------
I've noticed (during the downstreaming ruby/spec in https://github.com/ruby/ruby/pull/12679) that a repeated Float value may be dumped "directly"/"immediately" without an object link on x86 architecture, and with a link in other cases. It seems it depends on whether Float is `Flonum` or not.

amd64:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060@\x06", where @\x06 is an object link
```

i686:
```ruby
Marshal.dump([0.0, 0.0]) # => "\x04\b[\af\x060f\x060", so f\x060 is dumped twice
```

Both dumps are loaded correctly, so it seems there is no any compatibility issue.

Should dumping be consistent and don't depend on architecture?

>From https://github.com/ruby/ruby/pull/12679#discussion_r1937116017



-- 
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] 6+ messages in thread

end of thread, other threads:[~2025-02-09  9:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-03 13:02 [ruby-core:120869] [Ruby master Misc#21110] Should Marshal.dump always use object links for repeated Float values? andrykonchin (Andrew Konchin) via ruby-core
2025-02-03 13:08 ` [ruby-core:120870] " Eregon (Benoit Daloze) via ruby-core
2025-02-03 14:51 ` [ruby-core:120871] " nobu (Nobuyoshi Nakada) via ruby-core
2025-02-03 15:20 ` [ruby-core:120872] " Eregon (Benoit Daloze) via ruby-core
2025-02-05 11:17 ` [ruby-core:120881] " nobu (Nobuyoshi Nakada) via ruby-core
2025-02-09  9:15 ` [ruby-core:120924] " herwin (Herwin W) 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).